aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/plugin/interface.php
blob: f20081301ffc1707603fa0a76c80b76e7e43c96c (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
41
42
43
44
45
46
47
48
49
50
51
<?php

# Collectd Interface plugin

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

# LAYOUT - Collectd 4
# interface/
# interface/if_errors-XXXX.rrd
# interface/if_octets-XXXX.rrd
# interface/if_packets-XXXX.rrd

# LAYOUT - Collectd 5
# interface-XXXX/if_errors.rrd
# interface-XXXX/if_octets.rrd
# interface-XXXX/if_packets.rrd

$obj = new Type_GenericIO($CONFIG);
$obj->data_sources = array('rx', 'tx');
$obj->ds_names = array(
	'rx' => 'Receive',
	'tx' => 'Transmit',
);
$obj->colors = array(
	'rx' => '0000ff',
	'tx' => '00b000',
);
$obj->width = $width;
$obj->heigth = $heigth;
$obj->rrd_format = '%5.1lf%s';

$instance = $CONFIG['version'] < 5 ? 'tinstance' : 'pinstance';
switch($obj->args['type']) {
	case 'if_errors':
		$obj->rrd_title = sprintf('Interface Errors (%s)', $obj->args[$instance]);
		$obj->rrd_vertical = 'Errors per second';
	break;
	case 'if_octets':
		$obj->rrd_title = sprintf('Interface Traffic (%s)', $obj->args[$instance]);
		$obj->rrd_vertical = 'Bytes per second';
	break;
	case 'if_packets':
		$obj->rrd_title = sprintf('Interface Packets (%s)', $obj->args[$instance]);
		$obj->rrd_vertical = 'Packets per second';
	break;
}

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