diff options
Diffstat (limited to 'plugin/battery.php')
| -rw-r--r-- | plugin/battery.php | 42 |
1 files changed, 42 insertions, 0 deletions
diff --git a/plugin/battery.php b/plugin/battery.php new file mode 100644 index 0000000..ade645c --- /dev/null +++ b/plugin/battery.php | |||
| @@ -0,0 +1,42 @@ | |||
| 1 | <?php | ||
| 2 | |||
| 3 | # Collectd Battery plugin | ||
| 4 | |||
| 5 | require_once 'conf/common.inc.php'; | ||
| 6 | require_once 'type/Default.class.php'; | ||
| 7 | require_once 'inc/collectd.inc.php'; | ||
| 8 | |||
| 9 | ## LAYOUT | ||
| 10 | # battery-X/ | ||
| 11 | # battery-X/charge.rrd | ||
| 12 | # battery-X/current.rrd | ||
| 13 | # battery-X/voltage.rrd | ||
| 14 | |||
| 15 | $obj = new Type_Default($CONFIG); | ||
| 16 | $obj->width = $width; | ||
| 17 | $obj->heigth = $heigth; | ||
| 18 | $obj->colors = array( | ||
| 19 | 'value' => '0000f0', | ||
| 20 | ); | ||
| 21 | switch($obj->args['type']) { | ||
| 22 | case 'charge': | ||
| 23 | $obj->ds_names = array('value' => 'Charge'); | ||
| 24 | $obj->rrd_title = sprintf('Charge (Battery %s)', $obj->args['pinstance']); | ||
| 25 | $obj->rrd_vertical = 'Ampere hours'; | ||
| 26 | break; | ||
| 27 | case 'current': | ||
| 28 | $obj->ds_names = array('value' => 'Current'); | ||
| 29 | $obj->rrd_title = sprintf('Current (Battery %s)', $obj->args['pinstance']); | ||
| 30 | $obj->rrd_vertical = 'Ampere'; | ||
| 31 | break; | ||
| 32 | case 'voltage': | ||
| 33 | $obj->ds_names = array('value' => 'Voltage'); | ||
| 34 | $obj->rrd_title = sprintf('Voltage (Battery %s)', $obj->args['pinstance']); | ||
| 35 | $obj->rrd_vertical = 'Volt'; | ||
| 36 | break; | ||
| 37 | } | ||
| 38 | $obj->rrd_format = '%4.1lf'; | ||
| 39 | |||
| 40 | collectd_flush($obj->identifiers); | ||
| 41 | $obj->rrd_graph(); | ||
| 42 | |||
