aboutsummaryrefslogtreecommitdiffstatshomepage
path: root/plugin/disk.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/disk.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/disk.php')
-rw-r--r--plugin/disk.php24
1 files changed, 7 insertions, 17 deletions
diff --git a/plugin/disk.php b/plugin/disk.php
index 620b188..f1100d6 100644
--- a/plugin/disk.php
+++ b/plugin/disk.php
@@ -13,15 +13,7 @@ require_once 'inc/collectd.inc.php';
13# disk-XXXX/disk_ops.rrd 13# disk-XXXX/disk_ops.rrd
14# disk-XXXX/disk_time.rrd 14# disk-XXXX/disk_time.rrd
15 15
16$obj = new Type_GenericIO; 16$obj = new Type_GenericIO($CONFIG['datadir']);
17$obj->datadir = $CONFIG['datadir'];
18$obj->args = array(
19 'host' => $host,
20 'plugin' => $plugin,
21 'pinstance' => $pinstance,
22 'type' => $type,
23 'tinstance' => $tinstance,
24);
25$obj->data_sources = array('read', 'write'); 17$obj->data_sources = array('read', 'write');
26$obj->ds_names = array( 18$obj->ds_names = array(
27 'read' => 'Read ', 19 'read' => 'Read ',
@@ -33,33 +25,31 @@ $obj->colors = array(
33); 25);
34$obj->width = $width; 26$obj->width = $width;
35$obj->heigth = $heigth; 27$obj->heigth = $heigth;
36$obj->seconds = $seconds; 28switch($obj->args['type']) {
37switch($type) {
38 case 'disk_merged': 29 case 'disk_merged':
39 $obj->rrd_title = sprintf('Disk Merged Operations (%s)', $pinstance); 30 $obj->rrd_title = sprintf('Disk Merged Operations (%s)', $obj->args['pinstance']);
40 $obj->rrd_vertical = 'Merged operations/s'; 31 $obj->rrd_vertical = 'Merged operations/s';
41 $obj->rrd_format = '%5.1lf'; 32 $obj->rrd_format = '%5.1lf';
42 break; 33 break;
43 case 'disk_octets': 34 case 'disk_octets':
44 $obj->rrd_title = sprintf('Disk Traffic (%s)', $pinstance); 35 $obj->rrd_title = sprintf('Disk Traffic (%s)', $obj->args['pinstance']);
45 $obj->rrd_vertical = 'Bytes per second'; 36 $obj->rrd_vertical = 'Bytes per second';
46 $obj->rrd_format = '%5.1lf%s'; 37 $obj->rrd_format = '%5.1lf%s';
47 break; 38 break;
48 case 'disk_ops': 39 case 'disk_ops':
49 $obj->rrd_title = sprintf('Disk Operations (%s)', $pinstance); 40 $obj->rrd_title = sprintf('Disk Operations (%s)', $obj->args['pinstance']);
50 $obj->rrd_vertical = 'Ops per second'; 41 $obj->rrd_vertical = 'Ops per second';
51 $obj->rrd_format = '%5.1lf'; 42 $obj->rrd_format = '%5.1lf';
52 break; 43 break;
53 case 'disk_time': 44 case 'disk_time':
54 $obj->rrd_title = sprintf('Disk time per operation (%s)', $pinstance); 45 $obj->rrd_title = sprintf('Disk time per operation (%s)', $obj->args['pinstance']);
55 $obj->rrd_vertical = 'Avg. Time/Op'; 46 $obj->rrd_vertical = 'Avg. Time/Op';
56 $obj->rrd_format = '%5.1lf%ss'; 47 $obj->rrd_format = '%5.1lf%ss';
57 $obj->scale = '0.001'; 48 $obj->scale = '0.001';
58 break; 49 break;
59} 50}
60 51
61collectd_flush(ident_from_args($obj->args)); 52collectd_flush($obj->identifiers);
62
63$obj->rrd_graph(); 53$obj->rrd_graph();
64 54
65?> 55?>