aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/plugin/battery.php
diff options
context:
space:
mode:
authorPim van den Berg2010-10-12 19:01:49 +0200
committerPim van den Berg2010-10-12 19:01:49 +0200
commit4dd7e1b28bfdad22ad704ef7b8ac6386bbcad08e (patch)
treeccd8c6a0f2301458c9392798d2057e3a00bd1326 /plugin/battery.php
parentplugin: remove php close tags (diff)
downloadapt-panopticon_cgp-4dd7e1b28bfdad22ad704ef7b8ac6386bbcad08e.zip
apt-panopticon_cgp-4dd7e1b28bfdad22ad704ef7b8ac6386bbcad08e.tar.gz
apt-panopticon_cgp-4dd7e1b28bfdad22ad704ef7b8ac6386bbcad08e.tar.bz2
apt-panopticon_cgp-4dd7e1b28bfdad22ad704ef7b8ac6386bbcad08e.tar.xz
plugin: add battery plugin
Diffstat (limited to '')
-rw-r--r--plugin/battery.php42
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
5require_once 'conf/common.inc.php';
6require_once 'type/Default.class.php';
7require_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);
21switch($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
40collectd_flush($obj->identifiers);
41$obj->rrd_graph();
42