make list of procs to facilitate using threadpools
This commit is contained in:
parent
5c39259f0b
commit
eea59a20b3
@ -121,12 +121,19 @@ def read_interface_stats(ifname):
|
|||||||
return stats
|
return stats
|
||||||
|
|
||||||
def collect_kvm_metrics():
|
def collect_kvm_metrics():
|
||||||
for proc in psutil.process_iter(['pid', 'name', 'cmdline', 'cpu_percent', 'memory_percent', 'num_threads']):
|
procs = [
|
||||||
|
(
|
||||||
if 'kvm' == proc.info['name']:
|
# proc object
|
||||||
cmdline = proc.cmdline()
|
proc,
|
||||||
id = flag_to_label_value(cmdline,"-id")
|
# cmdline list
|
||||||
|
proc.cmdline(),
|
||||||
|
# VMID
|
||||||
|
flag_to_label_value(proc.cmdline(),"-id")
|
||||||
|
)
|
||||||
|
for proc in psutil.process_iter(['pid', 'name', 'cmdline', 'cpu_percent', 'memory_percent', 'num_threads'])
|
||||||
|
if proc.info['name'] == 'kvm'
|
||||||
|
]
|
||||||
|
for proc, cmdline, id in procs:
|
||||||
# Extract vm labels from cmdline
|
# Extract vm labels from cmdline
|
||||||
info_label_dict = {get_label_name(l): flag_to_label_value(cmdline,l) for l in label_flags}
|
info_label_dict = {get_label_name(l): flag_to_label_value(cmdline,l) for l in label_flags}
|
||||||
info_label_dict['pid']=str(proc.pid)
|
info_label_dict['pid']=str(proc.pid)
|
||||||
@ -175,8 +182,6 @@ def collect_kvm_metrics():
|
|||||||
gauge = create_or_get_gauge(metric_name, nic_labels.keys())
|
gauge = create_or_get_gauge(metric_name, nic_labels.keys())
|
||||||
gauge.labels(**nic_labels).set(value)
|
gauge.labels(**nic_labels).set(value)
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
def main():
|
def main():
|
||||||
parser = argparse.ArgumentParser(description='PVE metrics exporter for Prometheus')
|
parser = argparse.ArgumentParser(description='PVE metrics exporter for Prometheus')
|
||||||
parser.add_argument('--port', type=int, default=DEFAULT_PORT, help='Port for the exporter to listen on')
|
parser.add_argument('--port', type=int, default=DEFAULT_PORT, help='Port for the exporter to listen on')
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user