Révision 17f78427
Whitespace cleanup
- remove trailing whitespace
- remove empty lines at the end of files
| plugins/libvirt/kvm_mem | ||
|---|---|---|
| 50 | 50 |
vm_name = re.sub(suffix,'',vm_name) |
| 51 | 51 |
|
| 52 | 52 |
return re.sub(r"[^a-zA-Z0-9_]", "_", vm_name) |
| 53 |
|
|
| 53 |
|
|
| 54 | 54 |
def fetch(vms): |
| 55 | 55 |
''' Fetch values for a list of pids |
| 56 | 56 |
@param dictionnary {kvm_pid: cleaned vm name}
|
| ... | ... | |
| 61 | 61 |
cmdline = open("/proc/%s/cmdline" % pid, "r")
|
| 62 | 62 |
amount = re.sub(r"^.*-m\x00(.*)\x00-smp.*$",r"\1", cmdline.readline()) |
| 63 | 63 |
amount = int(amount) * 1024 * 1024 |
| 64 |
print "%s_mem.value %s" % (vms[pid], amount)
|
|
| 64 |
print "%s_mem.value %s" % (vms[pid], amount) |
|
| 65 | 65 |
except: |
| 66 | 66 |
cmdline = open("/proc/%s/cmdline" % pid, "r")
|
| 67 | 67 |
amount = re.sub(r"^.*-m\x00(\d+).*$",r"\1", cmdline.readline()) |
| 68 | 68 |
amount = int(amount) * 1024 * 1024 |
| 69 |
print "%s_mem.value %s" % (vms[pid], amount)
|
|
| 69 |
print "%s_mem.value %s" % (vms[pid], amount) |
|
| 70 | 70 |
|
| 71 | 71 |
def detect_kvm(): |
| 72 | 72 |
''' Check if kvm is installed |
| ... | ... | |
| 84 | 84 |
cmdline = open("/proc/%s/cmdline" % pid, "r")
|
| 85 | 85 |
result[pid] = clean_vm_name(re.sub(r"^.*-name\x00([a-zA-Z0-9.-_-]*)\x00\-.*$",r"\1", cmdline.readline())) |
| 86 | 86 |
return result |
| 87 |
|
|
| 87 |
|
|
| 88 | 88 |
def list_pids(): |
| 89 | 89 |
''' Find the pid of kvm processes |
| 90 | 90 |
@return a list of pids from running kvm |
| 91 | 91 |
''' |
| 92 | 92 |
pid = Popen("pidof qemu-kvm qemu-system-x86_64 kvm", shell=True, stdout=PIPE)
|
| 93 | 93 |
return pid.communicate()[0].split() |
| 94 |
|
|
| 94 |
|
|
| 95 | 95 |
if __name__ == "__main__": |
| 96 | 96 |
if len(sys.argv) > 1: |
| 97 | 97 |
if sys.argv[1] in ['autoconf', 'detect']: |
Formats disponibles : Unified diff