From 0a547add2f4cc264380d2dab2c472efe5a1d7094 Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Sat, 3 May 2014 19:17:16 +0200 Subject: graph.php: use JSON plugins instead of including PHP plugin files A couple of big changes here. A lot of logic moved to graph.php. The PHP plugin files have been rewritten to JSON. In these JSON files *everything* is optional. Also *NOT* having a JSON plugin file won't block you from having a graph. The JSON will just make the graphs prettier (by having a title, y-axis title, legend, colors, etc..). The Collectd types.db file is parsed and used to determine RRD content. When things are not defined in the JSON it will fallback to a default. --- plugin/libvirt.php | 144 ----------------------------------------------------- 1 file changed, 144 deletions(-) delete mode 100644 plugin/libvirt.php (limited to 'plugin/libvirt.php') diff --git a/plugin/libvirt.php b/plugin/libvirt.php deleted file mode 100644 index bcaeeb9..0000000 --- a/plugin/libvirt.php +++ /dev/null @@ -1,144 +0,0 @@ -args['type']) { - case 'disk_octets': - $obj->data_sources = array('read', 'write'); - $obj->legend = 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->legend = 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->legend = 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->legend = 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->legend = 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 = sprintf('%s per second', ucfirst($CONFIG['network_datasize'])); - $obj->scale = $CONFIG['network_datasize'] == 'bits' ? 8 : 1; - break; - case 'if_packets': - $obj->data_sources = array('rx', 'tx'); - $obj->legend = 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, $_GET); - - $obj->data_sources = array('value'); - $obj->legend = array( - 'value' => 'CPU time', - ); - $obj->colors = array( - 'value' => '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, $_GET); - - $obj->data_sources = array('value'); - $obj->legend = array( - 'value' => 'VCPU time', - ); - $obj->colors = array( - 'value' => '0000ff', - ); - $obj->rrd_title = 'VCPU usage'; - $obj->rrd_vertical = 'VCPU time'; - break; -} - -$obj->rrd_format = '%5.1lf%s'; - -if ($CONFIG['version'] < 5 && count($obj->data_sources) == 1) { - $obj->data_sources = array('ns'); - - $obj->legend['ns'] = $obj->legend['value']; - unset($obj->legend['value']); - - $obj->colors['ns'] = $obj->colors['value']; - unset($obj->colors['value']); -} - -$obj->rrd_graph(); -- cgit v1.1