mirror of
https://github.com/munin-monitoring/contrib.git
synced 2018-11-08 00:59:34 +01:00
kvm_net: fix python code style issues
This commit is contained in:
parent
a9059703a6
commit
aa8f1a59c4
@ -32,8 +32,10 @@ GPLv3
|
||||
=cut
|
||||
"""
|
||||
|
||||
import re, os, sys
|
||||
import os
|
||||
import re
|
||||
from subprocess import Popen, PIPE
|
||||
import sys
|
||||
|
||||
|
||||
def config(vm_names):
|
||||
@ -78,7 +80,6 @@ def fetch(vms):
|
||||
|
||||
@param dictionnary {kvm_pid: cleaned vm name}
|
||||
"""
|
||||
res = {}
|
||||
for pid in vms:
|
||||
tap = get_vm_mac(pid)
|
||||
try:
|
||||
@ -105,10 +106,11 @@ def find_vm_names(pids):
|
||||
|
||||
@return a dictionnary of {pids : cleaned vm name}
|
||||
"""
|
||||
vm_name_regex = re.compile(r"^.*-name\x00([a-zA-Z0-9.-_-]*)\x00\-.*$")
|
||||
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(vm_name_regex.sub(r"\1", cmdline.readline()))
|
||||
return result
|
||||
|
||||
|
||||
@ -119,7 +121,7 @@ def get_vm_mac(pid):
|
||||
"""
|
||||
cmdline = open("/proc/%s/cmdline" % pid, "r")
|
||||
line = cmdline.readline()
|
||||
mac = re.sub(r"^.*ifname=(tap[^,]+),.*$",r"\1", line)
|
||||
mac = re.sub(r"^.*ifname=(tap[^,]+),.*$", r"\1", line)
|
||||
return mac
|
||||
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user