Prometheus exporter for OpenNebula
One day this will be a full-fledged exporter. For now, here's a quick hack:
-
Save this as e.g.
/var/lib/one/opennebula_exporter
andchmod a+x
:#!/usr/bin/env sh /usr/bin/onevm list --csv --list STAT | awk '!/STAT/ { stat[$0] += 1 } END { for (i in stat) print "opennebula_vm_count{state=\""i"\"}", stat[i] }' | sort > "$FILE.tmp" /usr/bin/onehost list --csv --list STAT | awk '!/STAT/ { stat[$0] += 1 } END { for (i in stat) print "opennebula_host_count{state=\""i"\"}", stat[i] }' | sort >> "$FILE.tmp" mv "$FILE.tmp" "$FILE"
-
Add a cron job:
* * * * * /var/lib/one/opennebula_exporter
-
Configure node_exporter to collect the file: add the flag
--collector.textfile.directory=/service/node_exporter/textfiles
Make sure the directory exists and has correct permissions.
-
Enjoy your shiny new metric.