aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/plugin/netlink.php
blob: 2dfbab69880bdf16675782b5017a208ffb030cf7 (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
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
<?php

# Collectd Netlink Plugin

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

$obj = new Type_GenericStacked($CONFIG, $_GET);

$obj->rrd_format = '%5.1lf%s';

switch($obj->args['type']) {
	case 'if_collisions':
		$obj->data_sources = array('value');
		$obj->ds_names = array('value' => 'Collisions');
		$obj->colors = array('value' => '0000ff');
		$obj->rrd_title = sprintf('Collisions (%s)', $obj->args['pinstance']);
		$obj->rrd_vertical = 'Collisions/s';
		break;
	case 'if_dropped':
		$obj->data_sources = array('rx', 'tx');
		$obj->ds_names = array(
			'rx' => 'Receive',
			'tx' => 'Transmit',
		);
		$obj->colors = array(
			'rx' => '0000ff',
			'tx' => '00b000',
		);
		$obj->rrd_title = sprintf('Dropped Packets (%s)', $obj->args['pinstance']);
		$obj->rrd_vertical = 'Packets/s';
		break;
	case 'if_errors':
		$obj->data_sources = array('rx', 'tx');
		$obj->ds_names = array(
			'rx' => 'Receive',
			'tx' => 'Transmit',
		);
		$obj->colors = array(
			'rx' => '0000ff',
			'tx' => '00b000',
		);
		$obj->rrd_title = sprintf('Interface Errors (%s)', $obj->args['pinstance']);
		$obj->rrd_vertical = 'Errors/s';
		break;
	case 'if_multicast':
		$obj->data_sources = array('value');
		$obj->ds_names = array('value' => 'Packets');
		$obj->colors = array('value' => '0000ff');
		$obj->rrd_title = sprintf('Multicast Packets (%s)', $obj->args['pinstance']);
		$obj->rrd_vertical = 'Packets/s';
		break;
	case 'if_octets':
		$obj->data_sources = array('rx', 'tx');
		$obj->ds_names = array(
			'rx' => 'Receive',
			'tx' => 'Transmit',
		);
		$obj->colors = array(
			'rx' => '0000ff',
			'tx' => '00b000',
		);
		$obj->rrd_title = sprintf('Interface Traffic (%s)', $obj->args['pinstance']);
		$obj->rrd_vertical = sprintf('%s/s', ucfirst($CONFIG['network_datasize']));
		$obj->scale = $CONFIG['network_datasize'] == 'bits' ? 8 : 1;
		break;
	case 'if_packets':
		$obj->data_sources = array('rx', 'tx');
		$obj->ds_names = array(
			'rx' => 'Receive',
			'tx' => 'Transmit',
		);
		$obj->colors = array(
			'rx' => '0000ff',
			'tx' => '00b000',
		);
		$obj->rrd_title = sprintf('Interface Packets (%s)', $obj->args['pinstance']);
		$obj->rrd_vertical = 'Packets/s';
		break;
	case 'if_rx_errors':
		$obj->data_sources = array('value');
		$obj->ds_names = array(
			'crc'    => 'CRC',
			'fifo'   => 'FiFo',
			'frame'  => 'Frame',
			'length' => 'Lenght',
			'missed' => 'Missed',
			'over'   => 'Over',
		);
		$obj->colors = array(
			'crc'    => '00e000',
			'fifo'   => 'f000c0',
			'frame'  => 'ffb000',
			'length' => 'f00000',
			'missed' => '0000f0',
			'over'   => '00e0ff',
		);
		$obj->rrd_title = sprintf('Interface receive errors (%s)', $obj->args['pinstance']);
		$obj->rrd_vertical = 'Errors/s';
		break;
	case 'if_tx_errors':
		$obj->data_sources = array('value');
		$obj->ds_names = array(
			'aborted'  => 'Aborted',
			'carrier'  => 'Carrier',
			'fifo'     => 'FiFo',
			'heartbeat'=> 'Heartbeat',
			'window'   => 'Window',
		);
		$obj->colors = array(
			'aborted'  => 'f00000',
			'carrier'  => '00e0ff',
			'fifo'     => '00e000',
			'heartbeat'=> 'ffb000',
			'window'   => 'f000c0',
		);
		$obj->rrd_title = sprintf('Interface transmit errors (%s)', $obj->args['pinstance']);
		$obj->rrd_vertical = 'Errors/s';
		break;
}

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