1
0
mirror of https://github.com/OpenNebula/one.git synced 2025-03-16 22:50:10 +03:00

B #2179 Report RSS + swap usage for KVM VMs

_max_memory_ is always equal to Available because:
  1. the memballoon is not used for resizing VM memory 
  2. the memballoon stats reporting is not enabled by default:

  ```
  <memballoon model='virtio'>
        <stats period='10'/>
    </memballoon>
  ```
This commit is contained in:
Jan Orel 2018-10-23 12:23:05 +02:00 committed by Ruben S. Montero
parent 4125cd5b5c
commit 92d1ff6b11

View File

@ -80,13 +80,13 @@ module KVM
cpu = get_cpu_info({one_vm => vm})
resident_mem = psinfo[5].to_i
max_mem = dominfo['Max memory'].split(/\s+/).first.to_i
swap_mem = get_swap_usage(vm[:pid]).to_i
values=Hash.new
values[:state] = get_state(dominfo['State'], vm[:reason])
values[:cpu] = cpu[vm[:pid]] if cpu[vm[:pid]]
values[:memory] = [resident_mem, max_mem].max
values[:memory] = resident_mem + swap_mem
xml = dump_xml(one_vm)
@ -139,13 +139,13 @@ module KVM
dominfo = vm[:dominfo]
resident_mem = ps_data[5].to_i
max_mem = dominfo['Max memory'].split(/\s+/).first.to_i
swap_mem = get_swap_usage(vm[:pid]).to_i
values = Hash.new
values[:state] = get_state(dominfo['State'], vm[:reason])
values[:cpu] = cpu[vm[:pid]] if cpu[vm[:pid]]
values[:memory] = [resident_mem, max_mem].max
values[:memory] = resident_mem + swap_mem
xml = dump_xml(name)
@ -243,6 +243,14 @@ module KVM
ps.split(/\s+/)
end
# Gets the swap allocation of given process
# @param pid [String] process id
# @return [Integer] of swap allocation of given process
def self.get_swap_usage(pid)
swap=`cat /proc/#{pid}/status 2>/dev/null | grep VmSwap`
swap.split()[1] || 0
end
# Gets the info of a domain by its id
# @param the ID of the VM as defined in libvirt
# @return [Hash] with the output of virsh dominfo, indexed by name (Id...)