Skip to content

Commit 9f08810

Browse files
committed
fix graph by syncing output and config
What gets configured matches now what will be reported.
1 parent e321cc4 commit 9f08810

File tree

1 file changed

+20
-14
lines changed

1 file changed

+20
-14
lines changed

plugins/virtualization/kvm_net_rh

+20-14
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
import re, os, sys
2121
from subprocess import Popen, PIPE
2222

23-
def config(vm_names):
23+
def config(vms):
2424
''' Print the plugin's config
2525
@param vm_names : a list of "cleaned" vms' name
2626
'''
@@ -31,16 +31,20 @@ graph_info This graph shows the network I/O of the virtual machines
3131
graph_args --base 1024
3232
"""
3333
print base_config
34-
for vm in vm_names:
35-
print "%s_in.label %s" % (vm, vm)
36-
print "%s_in.type COUNTER" % vm
37-
print "%s_in.min 0" % vm
38-
print "%s_in.draw LINE2" % vm
39-
print "%s_out.negative %s_in" % (vm, vm)
40-
print "%s_out.label %s" % (vm, vm)
41-
print "%s_out.type COUNTER" % vm
42-
print "%s_out.min 0" % vm
43-
print "%s_out.draw LINE2" % vm
34+
for pid in vms:
35+
macs = get_vm_macs(pid)
36+
i = 0
37+
for mac in macs:
38+
print "%s_eth%s_in.label %s" % (vms[pid],i, vms[pid])
39+
print "%s_eth%s_in.type COUNTER" % (vms[pid], i)
40+
print "%s_eth%s_in.min 0" % (vms[pid],i)
41+
print "%s_eth%s_in.draw LINE2" % (vms[pid],i)
42+
print "%s_eth%s_out.negative %s_in" % (vms[pid], i, vms[pid])
43+
print "%s_eth%s_out.label %s" % (vms[pid], i, vms[pid])
44+
print "%s_eth%s_out.type COUNTER" % (vms[pid], i)
45+
print "%s_eth%s_out.min 0" % (vms[pid], i)
46+
print "%s_eth%s_out.draw LINE2" % (vms[pid], i)
47+
i += 1
4448

4549
def clean_vm_name(vm_name):
4650
''' Replace all special chars
@@ -67,12 +71,14 @@ def fetch(vms):
6771
interfaces[s[0]] = (s[1],s[2])
6872
for pid in vms:
6973
macs = get_vm_macs(pid)
74+
i = 0
7075
for mac in macs:
7176
inf = macs_to_inf[mac]
7277
values = interfaces[inf]
7378
if len(values) == 2:
74-
print "%s_%s_in.value %s" % (vms[pid], inf, values[0])
75-
print "%s_%s_out.value %s" % (vms[pid], inf, values[1])
79+
print "%s_eth%s_in.value %s" % (vms[pid], i, values[0])
80+
print "%s_eth%s_out.value %s" % (vms[pid], i, values[1])
81+
i += 1
7682

7783
def detect_kvm():
7884
''' Check if kvm is installed
@@ -135,7 +141,7 @@ if __name__ == "__main__":
135141
else:
136142
print "no"
137143
elif sys.argv[1] == "config":
138-
config(find_vm_names(list_pids()).values())
144+
config(find_vm_names(list_pids()))
139145
else:
140146
fetch(find_vm_names(list_pids()))
141147
else:

0 commit comments

Comments
 (0)