diff options
Diffstat (limited to 'plugin')
-rw-r--r-- | plugin/nut.php | 57 |
1 files changed, 57 insertions, 0 deletions
diff --git a/plugin/nut.php b/plugin/nut.php new file mode 100644 index 0000000..82b967e --- /dev/null +++ b/plugin/nut.php | |||
@@ -0,0 +1,57 @@ | |||
1 | <?php | ||
2 | |||
3 | # Collectd NUT 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 | # nut-XXXX/ | ||
11 | # nut-XXXX/percent-XXXX.rrd | ||
12 | # nut-XXXX/temerature-XXXX.rrd | ||
13 | # nut-XXXX/voltage-XXXX.rrd | ||
14 | # nut-XXXX/timeleft-XXXX.rrd | ||
15 | |||
16 | $obj = new Type_Default($CONFIG); | ||
17 | $obj->width = $width; | ||
18 | $obj->heigth = $heigth; | ||
19 | $obj->generate_colors(); | ||
20 | switch($obj->args['type']) { | ||
21 | case 'percent': | ||
22 | $obj->data_sources = array('percent'); | ||
23 | $obj->ds_names = array('charge' => 'Charge', | ||
24 | 'load' => 'Load'); | ||
25 | $obj->rrd_title = sprintf('Charge & load (%s)', $obj->args['pinstance']); | ||
26 | $obj->rrd_vertical = '%'; | ||
27 | $obj->rrd_format = '%5.1lf'; | ||
28 | break; | ||
29 | case 'temperature': | ||
30 | $obj->data_sources = array('value'); | ||
31 | $obj->ds_names = array('value' => 'Temperature'); | ||
32 | $obj->rrd_title = sprintf('Temperature (%s)', $obj->args['pinstance']); | ||
33 | $obj->rrd_vertical = '°C'; | ||
34 | $obj->rrd_format = '%5.1lf%s'; | ||
35 | break; | ||
36 | case 'timeleft': | ||
37 | $obj->data_sources = array('timeleft'); | ||
38 | $obj->ds_names = array('timeleft' => 'Timeleft'); | ||
39 | $obj->rrd_title = sprintf('Timeleft (%s)', $obj->args['pinstance']); | ||
40 | $obj->rrd_vertical = 'Seconds'; | ||
41 | $obj->rrd_format = '%5.1lf'; | ||
42 | break; | ||
43 | case 'voltage': | ||
44 | $obj->data_sources = array('value'); | ||
45 | $obj->ds_names = array('battery' => 'Battery', | ||
46 | 'input' => 'Input', | ||
47 | 'output' => 'Output'); | ||
48 | $obj->rrd_title = sprintf('Voltage (%s)', $obj->args['pinstance']); | ||
49 | $obj->rrd_vertical = 'Volts'; | ||
50 | $obj->rrd_format = '%5.1lf'; | ||
51 | break; | ||
52 | } | ||
53 | |||
54 | collectd_flush($obj->identifiers); | ||
55 | $obj->rrd_graph(); | ||
56 | |||
57 | ?> | ||