aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/plugin/battery.php
blob: 740d5cb42da556e18fb7eeeaa3177b04a7ea46be (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
<?php

# Collectd Battery plugin

require_once 'conf/common.inc.php';
require_once 'type/Default.class.php';
require_once 'inc/collectd.inc.php';

## LAYOUT
# battery-X/
# battery-X/charge.rrd
# battery-X/current.rrd
# battery-X/voltage.rrd

$obj = new Type_Default($CONFIG, $_GET);
$obj->colors = array(
	'value' => '0000f0',
);
switch($obj->args['type']) {
	case 'charge':
		$obj->ds_names = array('value' => 'Charge');
		$obj->rrd_title = sprintf('Charge (Battery %s)', $obj->args['pinstance']);
		$obj->rrd_vertical = 'Ampere hours';
	break;
	case 'current':
		$obj->ds_names = array('value' => 'Current');
		$obj->rrd_title = sprintf('Current (Battery %s)', $obj->args['pinstance']);
		$obj->rrd_vertical = 'Ampere';
	break;
	case 'voltage':
		$obj->ds_names = array('value' => 'Voltage');
		$obj->rrd_title = sprintf('Voltage (Battery %s)', $obj->args['pinstance']);
		$obj->rrd_vertical = 'Volt';
	break;
}
$obj->rrd_format = '%4.1lf';

collectd_flush($obj->identifiers);
$obj->rrd_graph();