aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/plugin/interface.php
diff options
context:
space:
mode:
authorPim van den Berg2009-12-31 11:42:56 +0100
committerPim van den Berg2009-12-31 13:07:13 +0100
commit95c70c919837f588389f525fe2cf4aba479e9f91 (patch)
treeef242a0273458ffcadf8357fd8dd4d64b2fb7105 /plugin/interface.php
parentalways show 'on $host' in the rrd title (diff)
downloadapt-panopticon_cgp-95c70c919837f588389f525fe2cf4aba479e9f91.zip
apt-panopticon_cgp-95c70c919837f588389f525fe2cf4aba479e9f91.tar.gz
apt-panopticon_cgp-95c70c919837f588389f525fe2cf4aba479e9f91.tar.bz2
apt-panopticon_cgp-95c70c919837f588389f525fe2cf4aba479e9f91.tar.xz
rewrite of type classes
A constructor is added to the Type_Default class. The constructor will parse GET values (such as host, plugin, pinstance, type, tinstance, seconds), create an array of all needed rrd files to generate a graph and substract identifiers from these rrd files. Because of the constructor (and related functions) it is not needed to define an array of tinstances to be grouped and shown in one graph. Also $obj->args don't have to be defined per plugin. This will result in smaller plugin files. The type classes are based on the fact that a plugin has multiple type instances OR multiple rrd data sources. This is called the source and is retrieved by rrd_get_sources in each rrd_gen_graph function. Also variables in function rrd_gen_graph have been renamed to better ones.
Diffstat (limited to 'plugin/interface.php')
-rw-r--r--plugin/interface.php23
1 files changed, 7 insertions, 16 deletions
diff --git a/plugin/interface.php b/plugin/interface.php
index 7d8d929..89e4280 100644
--- a/plugin/interface.php
+++ b/plugin/interface.php
@@ -12,15 +12,7 @@ require_once 'inc/collectd.inc.php';
12# interface/if_octets-XXXX.rrd 12# interface/if_octets-XXXX.rrd
13# interface/if_packets-XXXX.rrd 13# interface/if_packets-XXXX.rrd
14 14
15$obj = new Type_GenericIO; 15$obj = new Type_GenericIO($CONFIG['datadir']);
16$obj->datadir = $CONFIG['datadir'];
17$obj->args = array(
18 'host' => $host,
19 'plugin' => $plugin,
20 'pinstance' => $pinstance,
21 'type' => $type,
22 'tinstance' => $tinstance,
23);
24$obj->data_sources = array('rx', 'tx'); 16$obj->data_sources = array('rx', 'tx');
25$obj->ds_names = array( 17$obj->ds_names = array(
26 'rx' => 'Receive ', 18 'rx' => 'Receive ',
@@ -32,25 +24,24 @@ $obj->colors = array(
32); 24);
33$obj->width = $width; 25$obj->width = $width;
34$obj->heigth = $heigth; 26$obj->heigth = $heigth;
35$obj->seconds = $seconds;
36$obj->rrd_format = '%5.1lf%s'; 27$obj->rrd_format = '%5.1lf%s';
37switch($type) { 28
29switch($obj->args['type']) {
38 case 'if_errors': 30 case 'if_errors':
39 $obj->rrd_title = sprintf('Interface Errors (%s)', $tinstance); 31 $obj->rrd_title = sprintf('Interface Errors (%s)', $obj->args['tinstance']);
40 $obj->rrd_vertical = 'Errors per second'; 32 $obj->rrd_vertical = 'Errors per second';
41 break; 33 break;
42 case 'if_octets': 34 case 'if_octets':
43 $obj->rrd_title = sprintf('Interface Traffic (%s)', $tinstance); 35 $obj->rrd_title = sprintf('Interface Traffic (%s)', $obj->args['tinstance']);
44 $obj->rrd_vertical = 'Bits per second'; 36 $obj->rrd_vertical = 'Bits per second';
45 break; 37 break;
46 case 'if_packets': 38 case 'if_packets':
47 $obj->rrd_title = sprintf('Interface Packets (%s)', $tinstance); 39 $obj->rrd_title = sprintf('Interface Packets (%s)', $obj->args['tinstance']);
48 $obj->rrd_vertical = 'Packets per second'; 40 $obj->rrd_vertical = 'Packets per second';
49 break; 41 break;
50} 42}
51 43
52collectd_flush(ident_from_args($obj->args)); 44collectd_flush($obj->identifiers);
53
54$obj->rrd_graph(); 45$obj->rrd_graph();
55 46
56?> 47?>