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/nut.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 'plugin/nut.php')
| -rw-r--r-- | plugin/nut.php | 77 |
1 files changed, 0 insertions, 77 deletions
diff --git a/plugin/nut.php b/plugin/nut.php deleted file mode 100644 index eb2ceb2..0000000 --- a/plugin/nut.php +++ /dev/null | |||
| @@ -1,77 +0,0 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | # Collectd NUT plugin | ||
| 4 | |||
| 5 | require_once 'conf/common.inc.php'; | ||
| 6 | require_once 'type/Default.class.php'; | ||
| 7 | |||
| 8 | ## LAYOUT | ||
| 9 | # nut-XXXX/ | ||
| 10 | # nut-XXXX/frequency-XXXX.rrd | ||
| 11 | # nut-XXXX/percent-XXXX.rrd | ||
| 12 | # nut-XXXX/temerature-XXXX.rrd | ||
| 13 | # nut-XXXX/timeleft-XXXX.rrd | ||
| 14 | # nut-XXXX/voltage-XXXX.rrd | ||
| 15 | |||
| 16 | $obj = new Type_Default($CONFIG, $_GET); | ||
| 17 | switch($obj->args['type']) { | ||
| 18 | case 'frequency': | ||
| 19 | if ($CONFIG['version'] < 5) { | ||
| 20 | $obj->data_sources = array('frequency'); | ||
| 21 | } else { | ||
| 22 | $obj->data_sources = array('value'); | ||
| 23 | } | ||
| 24 | $obj->legend = array('output' => 'Output'); | ||
| 25 | $obj->rrd_title = sprintf('Frequency (%s)', $obj->args['pinstance']); | ||
| 26 | $obj->rrd_vertical = 'Hz'; | ||
| 27 | $obj->rrd_format = '%5.1lf%s'; | ||
| 28 | break; | ||
| 29 | case 'percent': | ||
| 30 | if ($CONFIG['version'] < 5) { | ||
| 31 | $obj->data_sources = array('percent'); | ||
| 32 | } else { | ||
| 33 | $obj->data_sources = array('value'); | ||
| 34 | } | ||
| 35 | $obj->legend = array('charge' => 'Charge', | ||
| 36 | 'load' => 'Load'); | ||
| 37 | $obj->rrd_title = sprintf('Charge & load (%s)', $obj->args['pinstance']); | ||
| 38 | $obj->rrd_vertical = '%'; | ||
| 39 | $obj->rrd_format = '%5.1lf'; | ||
| 40 | break; | ||
| 41 | case 'power': | ||
| 42 | $obj->data_sources = array('value'); | ||
| 43 | $obj->legend = array('ups' => 'UPS'); | ||
| 44 | $obj->rrd_title = sprintf('Power (%s)', $obj->args['pinstance']); | ||
| 45 | $obj->rrd_vertical = 'VA'; | ||
| 46 | $obj->rrd_format = '%5.1lf%s'; | ||
| 47 | break; | ||
| 48 | case 'temperature': | ||
| 49 | $obj->data_sources = array('value'); | ||
| 50 | $obj->legend = array('battery' => 'Battery'); | ||
| 51 | $obj->rrd_title = sprintf('Temperature (%s)', $obj->args['pinstance']); | ||
| 52 | $obj->rrd_vertical = '°C'; | ||
| 53 | $obj->rrd_format = '%5.1lf%s'; | ||
| 54 | break; | ||
| 55 | case 'timeleft': | ||
| 56 | if ($CONFIG['version'] < 5) { | ||
| 57 | $obj->data_sources = array('timeleft'); | ||
| 58 | } else { | ||
| 59 | $obj->data_sources = array('value'); | ||
| 60 | } | ||
| 61 | $obj->legend = array('timeleft' => 'Timeleft'); | ||
| 62 | $obj->rrd_title = sprintf('Timeleft (%s)', $obj->args['pinstance']); | ||
| 63 | $obj->rrd_vertical = 'Seconds'; | ||
| 64 | $obj->rrd_format = '%5.1lf'; | ||
| 65 | break; | ||
| 66 | case 'voltage': | ||
| 67 | $obj->data_sources = array('value'); | ||
| 68 | $obj->legend = array('battery' => 'Battery', | ||
| 69 | 'input' => 'Input', | ||
| 70 | 'output' => 'Output'); | ||
| 71 | $obj->rrd_title = sprintf('Voltage (%s)', $obj->args['pinstance']); | ||
| 72 | $obj->rrd_vertical = 'Volts'; | ||
| 73 | $obj->rrd_format = '%5.1lf'; | ||
| 74 | break; | ||
| 75 | } | ||
| 76 | |||
| 77 | $obj->rrd_graph(); | ||
