
This change implements metric collection system using influxdata (influxdb and telegraf) with visulization using grafana. No Dashboard automation is provided at this time however a template dashboard can be used by importing the JSON files from the dashboards directory. Change-Id: I5445b01170054393a31afc2a20ffb3ea4eda1209 Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
24 lines
612 B
Python
24 lines
612 B
Python
#!/usr/bin/env python
|
|
import json
|
|
import libvirt
|
|
import socket
|
|
|
|
return_data = dict()
|
|
conn = libvirt.openReadOnly()
|
|
try:
|
|
domains = conn.listDomainsID()
|
|
return_data['kvm_vms'] = len(domains)
|
|
return_data['kvm_total_vcpus'] = conn.getCPUMap()[0]
|
|
return_data['kvm_scheduled_vcpus'] = 0
|
|
for domain in domains:
|
|
return_data['kvm_scheduled_vcpus'] += conn.lookupByID(
|
|
domain
|
|
).maxVcpus()
|
|
return_data['kvm_host_id'] = abs(hash(socket.getfqdn()))
|
|
except Exception:
|
|
raise SystemExit('Plugin failure')
|
|
else:
|
|
print(json.dumps(return_data))
|
|
finally:
|
|
conn.close()
|