From e7193cd45a03e438719b156f330c2c7061484b1b Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Mon, 4 Jul 2011 20:58:29 +0200 Subject: plugin: add libvirt plugin --- inc/collectd.inc.php | 2 +- plugin/libvirt.php | 137 +++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 138 insertions(+), 1 deletion(-) create mode 100644 plugin/libvirt.php diff --git a/inc/collectd.inc.php b/inc/collectd.inc.php index e5a7df4..51aedba 100644 --- a/inc/collectd.inc.php +++ b/inc/collectd.inc.php @@ -107,7 +107,7 @@ function group_plugindata($plugindata) { # type instances should be grouped in 1 graph foreach ($plugindata as $item) { # backwards compatibility - if ($CONFIG['version'] >= 5 || !preg_match('/^(df|interface)$/', $item['p'])) + if ($CONFIG['version'] >= 5 || !preg_match('/^(df|interface|libvirt)$/', $item['p'])) unset($item['ti']); $data[] = $item; } diff --git a/plugin/libvirt.php b/plugin/libvirt.php new file mode 100644 index 0000000..0d5071a --- /dev/null +++ b/plugin/libvirt.php @@ -0,0 +1,137 @@ +args['type']) { + case 'disk_octets': + $obj->data_sources = array('read', 'write'); + $obj->ds_names = array( + 'read' => 'Read', + 'write' => 'Written', + ); + $obj->colors = array( + 'read' => '0000ff', + 'write' => '00b000', + ); + $obj->rrd_title = sprintf('Disk Traffic (%s)', $obj->args['tinstance']); + $obj->rrd_vertical = 'Bytes per second'; + $obj->rrd_format = '%5.1lf%s'; + break; + case 'disk_ops': + $obj->data_sources = array('read', 'write'); + $obj->ds_names = array( + 'read' => 'Read', + 'write' => 'Written', + ); + $obj->colors = array( + 'read' => '0000ff', + 'write' => '00b000', + ); + $obj->rrd_title = sprintf('Disk Operations (%s)', $obj->args['tinstance']); + $obj->rrd_vertical = 'Ops per second'; + $obj->rrd_format = '%5.1lf%s'; + break; + case 'if_dropped': + $obj->data_sources = array('rx', 'tx'); + $obj->ds_names = array( + 'rx' => 'Receive', + 'tx' => 'Transmit', + ); + $obj->colors = array( + 'rx' => '0000ff', + 'tx' => '00b000', + ); + $obj->rrd_title = sprintf('Interface Packets Dropped (%s)', $obj->args['tinstance']); + $obj->rrd_vertical = 'Packets dropped per second'; + break; + case 'if_errors': + $obj->data_sources = array('rx', 'tx'); + $obj->ds_names = array( + 'rx' => 'Receive', + 'tx' => 'Transmit', + ); + $obj->colors = array( + 'rx' => '0000ff', + 'tx' => '00b000', + ); + $obj->rrd_title = sprintf('Interface Errors (%s)', $obj->args['tinstance']); + $obj->rrd_vertical = 'Errors per second'; + break; + case 'if_octets': + $obj->data_sources = array('rx', 'tx'); + $obj->ds_names = array( + 'rx' => 'Receive', + 'tx' => 'Transmit', + ); + $obj->colors = array( + 'rx' => '0000ff', + 'tx' => '00b000', + ); + $obj->rrd_title = sprintf('Interface Traffic (%s)', $obj->args['tinstance']); + $obj->rrd_vertical = 'Bytes per second'; + break; + case 'if_packets': + $obj->data_sources = array('rx', 'tx'); + $obj->ds_names = array( + 'rx' => 'Receive', + 'tx' => 'Transmit', + ); + $obj->colors = array( + 'rx' => '0000ff', + 'tx' => '00b000', + ); + $obj->rrd_title = sprintf('Interface Packets (%s)', $obj->args['tinstance']); + $obj->rrd_vertical = 'Packets per second'; + break; + case 'virt_cpu_total': + require_once 'type/Default.class.php'; + $obj = new Type_Default($CONFIG); + + $obj->data_sources = array('ns'); + $obj->ds_names = array( + 'ns' => 'CPU time', + ); + $obj->colors = array( + 'ns' => '0000ff', + ); + $obj->rrd_title = 'CPU usage'; + $obj->rrd_vertical = 'CPU time'; + break; + case 'virt_vcpu': + require_once 'type/Default.class.php'; + $obj = new Type_Default($CONFIG); + + $obj->data_sources = array('ns'); + $obj->ds_names = array( + 'ns' => 'VCPU time', + ); + $obj->colors = array( + 'ns' => '0000ff', + ); + $obj->rrd_title = 'VCPU usage'; + $obj->rrd_vertical = 'VCPU time'; + break; +} + +$obj->width = $width; +$obj->heigth = $heigth; +$obj->rrd_format = '%5.1lf%s'; + +collectd_flush($obj->identifiers); +$obj->rrd_graph(); -- cgit v1.1