mirror of
https://github.com/munin-monitoring/contrib.git
synced 2025-07-21 18:41:03 +00:00
refactoring and python3 compatibility
This commit is contained in:
parent
8cb47cbfbb
commit
2385a6f570
1 changed files with 10 additions and 14 deletions
|
@ -25,17 +25,13 @@ def config(vm_names):
|
|||
graph_vlabel Bytes
|
||||
graph_category virtualization
|
||||
graph_info This graph shows the current amount of memory used by virtual machines
|
||||
graph_args --base 1024"""
|
||||
print base_config
|
||||
draw = "AREA"
|
||||
graph_args --base 1024 -l 0"""
|
||||
print(base_config)
|
||||
for vm in vm_names:
|
||||
print "%s_mem.label %s" % (vm, vm)
|
||||
print "%s_mem.type GAUGE" % vm
|
||||
if draw == 'AREA':
|
||||
print "%s_mem.min 0" % vm
|
||||
print "%s_mem.draw %s" % (vm, draw)
|
||||
print "%s_mem.info memory used by virtual machine %s" % (vm, vm)
|
||||
draw = "STACK"
|
||||
print("%s_mem.label %s" % (vm, vm))
|
||||
print("%s_mem.type GAUGE" % vm)
|
||||
print("%s_mem.draw %s" % (vm, "AREASTACK"))
|
||||
print("%s_mem.info memory used by virtual machine %s" % (vm, vm))
|
||||
|
||||
|
||||
def clean_vm_name(vm_name):
|
||||
|
@ -68,12 +64,12 @@ def fetch(vms):
|
|||
cmdline = open("/proc/%s/cmdline" % pid, "r")
|
||||
amount = re.sub(r"^.*-m\x00(.*)\x00-smp.*$",r"\1", cmdline.readline())
|
||||
amount = int(amount) * 1024 * 1024
|
||||
print "%s_mem.value %s" % (vms[pid], amount)
|
||||
print("%s_mem.value %s" % (vms[pid], amount))
|
||||
except:
|
||||
cmdline = open("/proc/%s/cmdline" % pid, "r")
|
||||
amount = re.sub(r"^.*-m\x00(\d+).*$",r"\1", cmdline.readline())
|
||||
amount = int(amount) * 1024 * 1024
|
||||
print "%s_mem.value %s" % (vms[pid], amount)
|
||||
print("%s_mem.value %s" % (vms[pid], amount))
|
||||
|
||||
def detect_kvm():
|
||||
''' Check if kvm is installed
|
||||
|
@ -103,9 +99,9 @@ if __name__ == "__main__":
|
|||
if len(sys.argv) > 1:
|
||||
if sys.argv[1] in ['autoconf', 'detect']:
|
||||
if detect_kvm():
|
||||
print "yes"
|
||||
print("yes")
|
||||
else:
|
||||
print "no"
|
||||
print("no")
|
||||
elif sys.argv[1] == "config":
|
||||
config(find_vm_names(list_pids()).values())
|
||||
else:
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue