Class: Pangea::VMMetrics

Inherits:
XObject show all
Defined in:
lib/pangea/objects.rb

Overview

Metrics associated with a VM

xen-api class: VM_metrics

Instance Method Summary collapse

Methods inherited from XObject

#ref_call, #uuid

Constructor Details

#initialize(link, ref) ⇒ VMMetrics

:nodoc:



479
480
481
482
# File 'lib/pangea/objects.rb', line 479

def initialize(link, ref) #:nodoc:
  super(link, ref)
  @proxy_name = 'VM_metrics'
end

Instance Method Details

#last_updatedObject

xen-api: VM_metrics.get_last_updated



530
531
532
# File 'lib/pangea/objects.rb', line 530

def last_updated
  (ref_call :get_last_updated).to_time
end

#memory_actualObject

xen-api: VM_metrics.get_memory_actual



487
488
489
# File 'lib/pangea/objects.rb', line 487

def memory_actual
  ref_call :get_memory_actual
end

#start_timeObject

xen-api: VM_metrics.get_start_time



523
524
525
# File 'lib/pangea/objects.rb', line 523

def start_time
  (ref_call :get_start_time).to_time
end

#stateObject

xen-api: VM_metrics.get_state



516
517
518
# File 'lib/pangea/objects.rb', line 516

def state
  ref_call :get_state
end

#to_sObject



534
535
536
537
538
539
540
541
542
543
544
545
546
# File 'lib/pangea/objects.rb', line 534

def to_s
  vcpu_u = ""
  vcpus_utilisation.each do |k, v|
    vcpu_u += "#{k}: %0.2f\n" % (v * 100)
  end
  eol = "\n"
  "[VM Metrics]" + eol +
  "State: #{state}" + eol +
  "Start Time: #{start_time}" + eol +
  "Last Updated: #{last_updated}" + eol +
  "VCPUs Utilisation:" + eol +
  vcpu_u
end

#vcpus_numberObject

xen-api: VM_metrics.get_VCPUs_number Number of cpus assigned to the domU



495
496
497
# File 'lib/pangea/objects.rb', line 495

def vcpus_number
  ref_call :get_VCPUs_number
end

#vcpus_utilisationObject

xen-api: VM_metrics.get_VCPUs_utilisation

returns a hash

cpu0 => utilisation,
cpu1 => utilization,
...



509
510
511
# File 'lib/pangea/objects.rb', line 509

def vcpus_utilisation
  ref_call :get_VCPUs_utilisation
end