diff options
| author | Pim van den Berg | 2014-05-03 19:17:16 +0200 |
|---|---|---|
| committer | Pim van den Berg | 2014-05-12 21:32:24 +0200 |
| commit | 0a547add2f4cc264380d2dab2c472efe5a1d7094 (patch) | |
| tree | 55bb43a3e31c5814848d61eea92c8438e4a37886 /plugin/libvirt.php | |
| parent | type/base: set default title to "Plugin Type (PluginInstance) (Category)" (diff) | |
| download | apt-panopticon_cgp-0a547add2f4cc264380d2dab2c472efe5a1d7094.zip apt-panopticon_cgp-0a547add2f4cc264380d2dab2c472efe5a1d7094.tar.gz apt-panopticon_cgp-0a547add2f4cc264380d2dab2c472efe5a1d7094.tar.bz2 apt-panopticon_cgp-0a547add2f4cc264380d2dab2c472efe5a1d7094.tar.xz | |
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.
Diffstat (limited to '')
| -rw-r--r-- | plugin/libvirt.php | 144 |
1 files changed, 0 insertions, 144 deletions
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 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | # Collectd libvirt plugin | ||
| 4 | |||
| 5 | require_once 'conf/common.inc.php'; | ||
| 6 | |||
| 7 | # LAYOUT | ||
| 8 | # libvirt/ | ||
| 9 | # libvirt/disk_octets-XXXX.rrd | ||
| 10 | # libvirt/disk_ops-XXXX.rrd | ||
| 11 | # libvirt/if_dropped-XXXX.rrd | ||
| 12 | # libvirt/if_errors-XXXX.rrd | ||
| 13 | # libvirt/if_octets-XXXX.rrd | ||
| 14 | # libvirt/if_packets-XXXX.rrd | ||
| 15 | # libvirt/virt_cpu_total.rrd | ||
| 16 | |||
| 17 | require_once 'type/GenericIO.class.php'; | ||
| 18 | $obj = new Type_GenericIO($CONFIG, $_GET); | ||
| 19 | |||
| 20 | switch($obj->args['type']) { | ||
| 21 | case 'disk_octets': | ||
| 22 | $obj->data_sources = array('read', 'write'); | ||
| 23 | $obj->legend = array( | ||
| 24 | 'read' => 'Read', | ||
| 25 | 'write' => 'Written', | ||
| 26 | ); | ||
| 27 | $obj->colors = array( | ||
| 28 | 'read' => '0000ff', | ||
| 29 | 'write' => '00b000', | ||
| 30 | ); | ||
| 31 | $obj->rrd_title = sprintf('Disk Traffic (%s)', $obj->args['tinstance']); | ||
| 32 | $obj->rrd_vertical = 'Bytes per second'; | ||
| 33 | $obj->rrd_format = '%5.1lf%s'; | ||
| 34 | break; | ||
| 35 | case 'disk_ops': | ||
| 36 | $obj->data_sources = array('read', 'write'); | ||
| 37 | $obj->legend = array( | ||
| 38 | 'read' => 'Read', | ||
| 39 | 'write' => 'Written', | ||
| 40 | ); | ||
| 41 | $obj->colors = array( | ||
| 42 | 'read' => '0000ff', | ||
| 43 | 'write' => '00b000', | ||
| 44 | ); | ||
| 45 | $obj->rrd_title = sprintf('Disk Operations (%s)', $obj->args['tinstance']); | ||
| 46 | $obj->rrd_vertical = 'Ops per second'; | ||
| 47 | $obj->rrd_format = '%5.1lf%s'; | ||
| 48 | break; | ||
| 49 | case 'if_dropped': | ||
| 50 | $obj->data_sources = array('rx', 'tx'); | ||
| 51 | $obj->legend = array( | ||
| 52 | 'rx' => 'Receive', | ||
| 53 | 'tx' => 'Transmit', | ||
| 54 | ); | ||
| 55 | $obj->colors = array( | ||
| 56 | 'rx' => '0000ff', | ||
| 57 | 'tx' => '00b000', | ||
| 58 | ); | ||
| 59 | $obj->rrd_title = sprintf('Interface Packets Dropped (%s)', $obj->args['tinstance']); | ||
| 60 | $obj->rrd_vertical = 'Packets dropped per second'; | ||
| 61 | break; | ||
| 62 | case 'if_errors': | ||
| 63 | $obj->data_sources = array('rx', 'tx'); | ||
| 64 | $obj->legend = array( | ||
| 65 | 'rx' => 'Receive', | ||
| 66 | 'tx' => 'Transmit', | ||
| 67 | ); | ||
| 68 | $obj->colors = array( | ||
| 69 | 'rx' => '0000ff', | ||
| 70 | 'tx' => '00b000', | ||
| 71 | ); | ||
| 72 | $obj->rrd_title = sprintf('Interface Errors (%s)', $obj->args['tinstance']); | ||
| 73 | $obj->rrd_vertical = 'Errors per second'; | ||
| 74 | break; | ||
| 75 | case 'if_octets': | ||
| 76 | $obj->data_sources = array('rx', 'tx'); | ||
| 77 | $obj->legend = array( | ||
| 78 | 'rx' => 'Receive', | ||
| 79 | 'tx' => 'Transmit', | ||
| 80 | ); | ||
| 81 | $obj->colors = array( | ||
| 82 | 'rx' => '0000ff', | ||
| 83 | 'tx' => '00b000', | ||
| 84 | ); | ||
| 85 | $obj->rrd_title = sprintf('Interface Traffic (%s)', $obj->args['tinstance']); | ||
| 86 | $obj->rrd_vertical = sprintf('%s per second', ucfirst($CONFIG['network_datasize'])); | ||
| 87 | $obj->scale = $CONFIG['network_datasize'] == 'bits' ? 8 : 1; | ||
| 88 | break; | ||
| 89 | case 'if_packets': | ||
| 90 | $obj->data_sources = array('rx', 'tx'); | ||
| 91 | $obj->legend = array( | ||
| 92 | 'rx' => 'Receive', | ||
| 93 | 'tx' => 'Transmit', | ||
| 94 | ); | ||
| 95 | $obj->colors = array( | ||
| 96 | 'rx' => '0000ff', | ||
| 97 | 'tx' => '00b000', | ||
| 98 | ); | ||
| 99 | $obj->rrd_title = sprintf('Interface Packets (%s)', $obj->args['tinstance']); | ||
| 100 | $obj->rrd_vertical = 'Packets per second'; | ||
| 101 | break; | ||
| 102 | case 'virt_cpu_total': | ||
| 103 | require_once 'type/Default.class.php'; | ||
| 104 | $obj = new Type_Default($CONFIG, $_GET); | ||
| 105 | |||
| 106 | $obj->data_sources = array('value'); | ||
| 107 | $obj->legend = array( | ||
| 108 | 'value' => 'CPU time', | ||
| 109 | ); | ||
| 110 | $obj->colors = array( | ||
| 111 | 'value' => '0000ff', | ||
| 112 | ); | ||
| 113 | $obj->rrd_title = 'CPU usage'; | ||
| 114 | $obj->rrd_vertical = 'CPU time'; | ||
| 115 | break; | ||
| 116 | case 'virt_vcpu': | ||
| 117 | require_once 'type/Default.class.php'; | ||
| 118 | $obj = new Type_Default($CONFIG, $_GET); | ||
| 119 | |||
| 120 | $obj->data_sources = array('value'); | ||
| 121 | $obj->legend = array( | ||
| 122 | 'value' => 'VCPU time', | ||
| 123 | ); | ||
| 124 | $obj->colors = array( | ||
| 125 | 'value' => '0000ff', | ||
| 126 | ); | ||
| 127 | $obj->rrd_title = 'VCPU usage'; | ||
| 128 | $obj->rrd_vertical = 'VCPU time'; | ||
| 129 | break; | ||
| 130 | } | ||
| 131 | |||
| 132 | $obj->rrd_format = '%5.1lf%s'; | ||
| 133 | |||
| 134 | if ($CONFIG['version'] < 5 && count($obj->data_sources) == 1) { | ||
| 135 | $obj->data_sources = array('ns'); | ||
| 136 | |||
| 137 | $obj->legend['ns'] = $obj->legend['value']; | ||
| 138 | unset($obj->legend['value']); | ||
| 139 | |||
| 140 | $obj->colors['ns'] = $obj->colors['value']; | ||
| 141 | unset($obj->colors['value']); | ||
| 142 | } | ||
| 143 | |||
| 144 | $obj->rrd_graph(); | ||
