From 28c4487772240ac028d2af87f9e426b9d795d045 Mon Sep 17 00:00:00 2001 From: Henrik Welk Date: Wed, 6 Aug 2014 15:19:55 +0200 Subject: [PATCH] Fixing Regexp for kvm plugins to be aware of underscores in vm names (otherwise munin will not generate graphs bc. of too long filenames) --- plugins/virtualization/kvm_cpu | 3 ++- plugins/virtualization/kvm_io | 2 +- plugins/virtualization/kvm_mem | 2 +- plugins/virtualization/kvm_net | 2 +- 4 files changed, 5 insertions(+), 4 deletions(-) diff --git a/plugins/virtualization/kvm_cpu b/plugins/virtualization/kvm_cpu index 6aea7688..1a641a77 100755 --- a/plugins/virtualization/kvm_cpu +++ b/plugins/virtualization/kvm_cpu @@ -68,7 +68,7 @@ def find_vm_names(pids): result = {} for pid in pids: cmdline = open("/proc/%s/cmdline" % pid, "r") - result[pid] = clean_vm_name(re.sub(r"^.*-name\x00([a-zA-Z0-9.-]*)\x00\-.*$",r"\1", cmdline.readline())) + result[pid] = clean_vm_name(re.sub(r"^.*-name\x00([a-zA-Z0-9.-_]*)\x00\-.*$",r"\1", cmdline.readline())) return result def list_pids(): @@ -99,3 +99,4 @@ if __name__ == "__main__": fetch(find_vm_names(list_pids())) else: fetch(find_vm_names(list_pids())) + diff --git a/plugins/virtualization/kvm_io b/plugins/virtualization/kvm_io index 8c62b44c..e687235d 100755 --- a/plugins/virtualization/kvm_io +++ b/plugins/virtualization/kvm_io @@ -85,7 +85,7 @@ def find_vm_names(pids): result = {} for pid in pids: cmdline = open("/proc/%s/cmdline" % pid, "r") - result[pid] = clean_vm_name(re.sub(r"^.*-name\x00([a-zA-Z0-9.-]*)\x00\-.*$",r"\1", cmdline.readline())) + result[pid] = clean_vm_name(re.sub(r"^.*-name\x00([a-zA-Z0-9.-_]*)\x00\-.*$",r"\1", cmdline.readline())) return result def list_pids(): diff --git a/plugins/virtualization/kvm_mem b/plugins/virtualization/kvm_mem index c4c0ba34..f1f93674 100755 --- a/plugins/virtualization/kvm_mem +++ b/plugins/virtualization/kvm_mem @@ -82,7 +82,7 @@ def find_vm_names(pids): result = {} for pid in pids: cmdline = open("/proc/%s/cmdline" % pid, "r") - result[pid] = clean_vm_name(re.sub(r"^.*-name\x00([a-zA-Z0-9.-]*)\x00\-.*$",r"\1", cmdline.readline())) + result[pid] = clean_vm_name(re.sub(r"^.*-name\x00([a-zA-Z0-9.-_]*)\x00\-.*$",r"\1", cmdline.readline())) return result def list_pids(): diff --git a/plugins/virtualization/kvm_net b/plugins/virtualization/kvm_net index ed2b7caf..949dd2a9 100755 --- a/plugins/virtualization/kvm_net +++ b/plugins/virtualization/kvm_net @@ -84,7 +84,7 @@ def find_vm_names(pids): result = {} for pid in pids: cmdline = open("/proc/%s/cmdline" % pid, "r") - result[pid] = clean_vm_name(re.sub(r"^.*-name\x00([a-zA-Z0-9.-]*)\x00\-.*$",r"\1", cmdline.readline())) + result[pid] = clean_vm_name(re.sub(r"^.*-name\x00([a-zA-Z0-9.-_]*)\x00\-.*$",r"\1", cmdline.readline())) return result def get_vm_mac(pid):