Added kvm_virsh to telegraf plugins

The KVM virsh plugin already existed however the setup was not using the
new playbook plugin system. This change moves the kvm vish plugin into
that system and updates the plugin to use the influxdb line format
instead of the json format which was recently deprecated.

Change-Id: Ib23a0a231044389aab5669dc0c467175cd220423
Signed-off-by: Kevin Carter <kevin.carter@rackspace.com>
This commit is contained in:
Kevin Carter authored and Kevin Carter (cloudnull) committed 2017-01-10 18:02:49 +00:00
1 parent 4f64e92864
commit 229739377d
2 files changed
+16 -4

No files matched your search

@@ -92,5 +92,13 @@
- "python /opt/telegraf/vm_quota.py"
group: "{{ groups['utility_all'][0] }}"
when_group: "{{ (groups['nova_compute'] | length) > 0 }}"
kvm:
plugin_name: "kvm_virsh.py"
command:
- "python /opt/telegraf/kvm_virsh.py"
group: "{{ groups['nova_compute'] }}"
when_group: "{{ (groups['nova_compute'] | length) > 0 and (nova_virt_type | default('qemu') in ['kvm', 'qemu']) }}"
influx_telegraf_targets:
- "{{ influxdb_host|default(internal_lb_vip_address) }}:{{ influxdb_port }}"
@@ -1,5 +1,4 @@
#!/usr/bin/env python
import json
import libvirt
import socket
@@ -15,9 +14,14 @@ try:
domain
).maxVcpus()
return_data['kvm_host_id'] = abs(hash(socket.getfqdn()))
except Exception:
raise SystemExit('Plugin failure')
except Exception as exp:
raise SystemExit('Plugin failure -- Reason: "%s"' % exp)
else:
print(json.dumps(return_data))
line_data = 'kvm '
for key, value in return_data.items():
line_data += '%s=%s,' % (key.replace(' ', '_'), value)
else:
line_data = line_data.rstrip(',')
print(line_data)
finally:
conn.close()