Feature #3718: Replace NET_TX and NET_RX w/ NETTX and NETRX

in the monitorization probes for VMs
This commit is contained in:
Jaime Melis committed 2015-06-26 16:05:23 +02:00
1 parent 9b8d8f56db
commit 957a48d10f
8 files changed
+46 -46

No files matched your search

+3 -3
View File
@@ -53,8 +53,8 @@ class VirtualMachineDriver < OpenNebulaDriver
POLL_ATTRIBUTE = {
:memory => "MEMORY",
:cpu => "CPU",
:net_tx => "NET_TX",
:net_rx => "NET_RX",
:nettx => "NETTX",
:netrx => "NETRX",
:state => "STATE",
:total_disk_size => "TOTAL_DISK_SIZE",
:disk_size => "DISK_SIZE",
@@ -355,7 +355,7 @@ if __FILE__ == $0
# monitor_info: string in the form "VAR=VAL VAR=VAL ... VAR=VAL"
# known VAR are in POLL_ATTRIBUTES. VM states VM_STATES
monitor_info = "#{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:active]} " \
"#{POLL_ATTRIBUTE[:net_tx]}=12345"
"#{POLL_ATTRIBUTE[:nettx]}=12345"
send_message(ACTION[:poll],RESULT[:success],id,monitor_info)
end
+6 -6
View File
@@ -180,20 +180,20 @@ class DummyDriver < VirtualMachineDriver
end
prev_nettx = 0
if msg.elements["VM/MONITORING/NET_TX"]
prev_nettx = msg.elements["VM/MONITORING/NET_TX"].text.to_i
if msg.elements["VM/MONITORING/NETTX"]
prev_nettx = msg.elements["VM/MONITORING/NETTX"].text.to_i
end
prev_netrx = 0
if msg.elements["VM/MONITORING/NET_RX"]
prev_netrx = msg.elements["VM/MONITORING/NET_RX"].text.to_i
if msg.elements["VM/MONITORING/NETRX"]
prev_netrx = msg.elements["VM/MONITORING/NETRX"].text.to_i
end
# monitor_info: string in the form "VAR=VAL VAR=VAL ... VAR=VAL"
# known VAR are in POLL_ATTRIBUTES. VM states VM_STATES
monitor_info = "#{POLL_ATTRIBUTE[:state]}=#{VM_STATE[:active]} " \
"#{POLL_ATTRIBUTE[:net_tx]}=#{prev_nettx+(50*rand(3))} " \
"#{POLL_ATTRIBUTE[:net_rx]}=#{prev_netrx+(100*rand(4))} " \
"#{POLL_ATTRIBUTE[:nettx]}=#{prev_nettx+(50*rand(3))} " \
"#{POLL_ATTRIBUTE[:netrx]}=#{prev_netrx+(100*rand(4))} " \
"#{POLL_ATTRIBUTE[:memory]}=#{max_memory * (rand(80)+20)/100} " \
"#{POLL_ATTRIBUTE[:cpu]}=#{max_cpu * (rand(95)+5)/100} " \
"#{POLL_ATTRIBUTE[:total_disk_size]}=#{rand(1024)} " \
+2 -2
View File
@@ -373,8 +373,8 @@ private
begin
info = "#{POLL_ATTRIBUTE[:memory]}=0 " \
"#{POLL_ATTRIBUTE[:cpu]}=0 " \
"#{POLL_ATTRIBUTE[:net_tx]}=0 " \
"#{POLL_ATTRIBUTE[:net_rx]}=0 "
"#{POLL_ATTRIBUTE[:nettx]}=0 " \
"#{POLL_ATTRIBUTE[:netrx]}=0 "
state = ""
if !instance
+2 -2
View File
@@ -431,8 +431,8 @@ private
begin
info = "#{POLL_ATTRIBUTE[:memory]}=0 " \
"#{POLL_ATTRIBUTE[:cpu]}=0 " \
"#{POLL_ATTRIBUTE[:net_tx]}=0 " \
"#{POLL_ATTRIBUTE[:net_rx]}=0 "
"#{POLL_ATTRIBUTE[:nettx]}=0 " \
"#{POLL_ATTRIBUTE[:netrx]}=0 "
state = ""
if !instance.exists?
+7 -7
View File
@@ -246,7 +246,7 @@ module KVM
# Aggregate statics of all VM NICs
# @param the ID of the VM as defined in libvirt
# @param text [nil, String] dumpxml output or nil to execute dumpxml
# @return [Hash] with network stats, by name [symbol] :net_rx, :net_tx
# @return [Hash] with network stats, by name [symbol] :netrx, :nettx
def self.get_interface_statistics(vmid, text = nil)
text = dump_xml(vmid) if !text
@@ -264,8 +264,8 @@ module KVM
values = Hash.new
values[:net_rx] = 0
values[:net_tx] = 0
values[:netrx] = 0
values[:nettx] = 0
interfaces.each do |interface|
text=`#{virsh(:domifstat)} #{vmid} #{interface}`
@@ -277,9 +277,9 @@ module KVM
case columns[1]
when 'rx_bytes'
values[:net_rx] += columns[2].to_i
values[:netrx] += columns[2].to_i
when 'tx_bytes'
values[:net_tx]+=columns[2].to_i
values[:nettx]+=columns[2].to_i
end
end
end
@@ -581,8 +581,8 @@ module XEN
dom_hash[:state] = get_state(dom_data[1])
dom_hash[:cpu] = dom_data[3]
dom_hash[:memory] = dom_data[4]
dom_hash[:net_tx] = dom_data[10].to_i * 1024
dom_hash[:net_rx] = dom_data[11].to_i * 1024
dom_hash[:nettx] = dom_data[10].to_i * 1024
dom_hash[:netrx] = dom_data[11].to_i * 1024
if !name.match(/^one-\d/) && vm_templates[name]
dom_hash[:template] =
+2 -2
View File
@@ -384,8 +384,8 @@ private
begin
info = "#{POLL_ATTRIBUTE[:memory]}=0 " \
"#{POLL_ATTRIBUTE[:cpu]}=0 " \
"#{POLL_ATTRIBUTE[:net_tx]}=0 " \
"#{POLL_ATTRIBUTE[:net_rx]}=0 "
"#{POLL_ATTRIBUTE[:nettx]}=0 " \
"#{POLL_ATTRIBUTE[:netrx]}=0 "
state = ""
@@ -719,8 +719,8 @@ class VCenterVm
@used_cpu = 0
@used_memory = 0
@net_rx = 0
@net_tx = 0
@netrx = 0
@nettx = 0
end
############################################################################
@@ -1013,8 +1013,8 @@ class VCenterVm
@used_cpu = 0
@used_memory = 0
@net_rx = 0
@net_tx = 0
@netrx = 0
@nettx = 0
return
end
@@ -1054,8 +1054,8 @@ class VCenterVm
str_info << "STATE=" << @state << " "
str_info << "CPU=" << @used_cpu.to_s << " "
str_info << "MEMORY=" << @used_memory.to_s << " "
str_info << "NET_RX=" << @net_rx.to_s << " "
str_info << "NET_TX=" << @net_tx.to_s << " "
str_info << "NETRX=" << @netrx.to_s << " "
str_info << "NETTX=" << @nettx.to_s << " "
str_info << "ESX_HOST=" << @esx_host.to_s << " "
str_info << "GUEST_STATE=" << @guest_state.to_s << " "
str_info << "VMWARETOOLS_RUNNING_STATUS=" << @vmware_tools.to_s << " "
+18 -18
View File
@@ -253,8 +253,8 @@ class VIVm
@used_cpu = 0
@used_memory = 0
@net_rx = 0
@net_tx = 0
@netrx = 0
@nettx = 0
return
end
@@ -269,24 +269,24 @@ class VIVm
vm_stats = VIDriver::retrieve_stats([@vm],
["net.packetsRx","net.packetsTx"])
@net_rx = 0
@net_tx = 0
@netrx = 0
@nettx = 0
if vm_stats[@vm] && vm_stats[@vm][:metrics]
if vm_stats[@vm][:metrics]["net.packetsRx"]
@net_rx = vm_stats[@vm][:metrics]["net.packetsRx"].first
@netrx = vm_stats[@vm][:metrics]["net.packetsRx"].first
end
if vm_stats[@vm][:metrics]["net.packetsTx"]
@net_tx = vm_stats[@vm][:metrics]["net.packetsTx"].first
@nettx = vm_stats[@vm][:metrics]["net.packetsTx"].first
end
end
# Check for negative values
@used_memory = 0 if @used_memory.to_i < 0
@used_cpu = 0 if @used_cpu.to_i < 0
@net_rx = 0 if @net_rx.to_i < 0
@net_tx = 0 if @net_tx.to_i < 0
@netrx = 0 if @netrx.to_i < 0
@nettx = 0 if @nettx.to_i < 0
end
########################################################################
@@ -300,8 +300,8 @@ class VIVm
str_info << "STATE=" << @state << " "
str_info << "CPU=" << @used_cpu.to_s << " "
str_info << "MEMORY=" << @used_memory.to_s << " "
str_info << "NET_RX=" << @net_rx.to_s << " "
str_info << "NET_TX=" << @net_tx.to_s
str_info << "NETRX=" << @netrx.to_s << " "
str_info << "NETTX=" << @nettx.to_s
end
private
@@ -367,24 +367,24 @@ class VIHost
net = VIDriver::retrieve_stats([@host],
["net.packetsRx","net.packetsTx"])
@net_rx = 0
@net_tx = 0
@netrx = 0
@nettx = 0
if net[@host] && net[@host][:metrics]
if net[@host][:metrics]["net.packetsRx"]
@net_rx = net[@host][:metrics]["net.packetsRx"].first
@netrx = net[@host][:metrics]["net.packetsRx"].first
end
if net[@host][:metrics]["net.packetsTx"]
@net_tx = net[@host][:metrics]["net.packetsTx"].first
@nettx = net[@host][:metrics]["net.packetsTx"].first
end
end
# Check for negative values
@used_memory = 0 if @used_memory.to_i < 0
@used_cpu = 0 if @used_cpu.to_i < 0
@net_rx = 0 if @net_rx.to_i < 0
@net_tx = 0 if @net_tx.to_i < 0
@netrx = 0 if @netrx.to_i < 0
@nettx = 0 if @nettx.to_i < 0
# Check free datastore space
@free_ds_info = VIDriver::retrieve_free_ds(@host)
@@ -409,8 +409,8 @@ class VIHost
str_info << "FREEMEMORY=" << (@total_memory - @used_memory).to_s << "\n"
# Networking
str_info << "NETRX=" << @net_rx.to_s << "\n"
str_info << "NETTX=" << @net_tx.to_s << "\n"
str_info << "NETRX=" << @netrx.to_s << "\n"
str_info << "NETTX=" << @nettx.to_s << "\n"
# Datastores
@free_ds_info.each{|k,v|