Révision acdaeb6d
Update kvm_cpu
in python3 filter returns an object, not an list. I think a list is required here? at least the plugin works as soon as list(...) is added.
need to change from pid to pid.decode, as pid is binary and not a string.
| plugins/libvirt/kvm_cpu | ||
|---|---|---|
| 47 | 47 |
@param vm_names : a list of "cleaned" vms' name |
| 48 | 48 |
''' |
| 49 | 49 |
percent = 100 * len( |
| 50 |
filter(lambda x: x[0:3] == 'cpu' and x[3] != ' ', open('/proc/stat', 'r').readlines()))
|
|
| 50 |
list(filter(lambda x: x[0:3] == 'cpu' and x[3] != ' ', open('/proc/stat', 'r').readlines())))
|
|
| 51 | 51 |
|
| 52 | 52 |
base_config = """graph_title KVM Virtual Machine CPU usage |
| 53 | 53 |
graph_vlabel %% |
| ... | ... | |
| 97 | 97 |
''' |
| 98 | 98 |
result = {}
|
| 99 | 99 |
for pid in pids: |
| 100 |
cmdline = open("/proc/%s/cmdline" % pid, "r")
|
|
| 100 |
cmdline = open("/proc/%s/cmdline" % pid.decode(), "r")
|
|
| 101 | 101 |
result[pid] = clean_vm_name( |
| 102 | 102 |
re.sub(r"^.*guest=([a-zA-Z0-9.-_-]*).*$", r"\1", cmdline.readline())) |
| 103 | 103 |
return result |
| ... | ... | |
| 116 | 116 |
@param dictionary {kvm_pid: cleaned vm name}
|
| 117 | 117 |
''' |
| 118 | 118 |
for pid, name in vms.items(): |
| 119 |
user, system = open("/proc/%s/stat" % pid, 'r').readline().split(' ')[13:15]
|
|
| 119 |
user, system = open("/proc/%s/stat" % pid.decode(), 'r').readline().split(' ')[13:15]
|
|
| 120 | 120 |
print('%s_cpu.value %d' % (name, int(user) + int(system)))
|
| 121 | 121 |
|
| 122 | 122 |
|
Formats disponibles : Unified diff