diff options
author | Pim van den Berg | 2009-12-31 11:42:56 +0100 |
---|---|---|
committer | Pim van den Berg | 2009-12-31 13:07:13 +0100 |
commit | 95c70c919837f588389f525fe2cf4aba479e9f91 (patch) | |
tree | ef242a0273458ffcadf8357fd8dd4d64b2fb7105 /plugin/cpu.php | |
parent | always show 'on $host' in the rrd title (diff) | |
download | apt-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/cpu.php')
-rw-r--r-- | plugin/cpu.php | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/plugin/cpu.php b/plugin/cpu.php index 4cc74f6..d4097b0 100644 --- a/plugin/cpu.php +++ b/plugin/cpu.php | |||
@@ -4,6 +4,7 @@ | |||
4 | 4 | ||
5 | require_once 'conf/common.inc.php'; | 5 | require_once 'conf/common.inc.php'; |
6 | require_once 'type/GenericStacked.class.php'; | 6 | require_once 'type/GenericStacked.class.php'; |
7 | require_once 'inc/collectd.inc.php'; | ||
7 | 8 | ||
8 | ## LAYOUT | 9 | ## LAYOUT |
9 | # cpu-X/ | 10 | # cpu-X/ |
@@ -16,19 +17,7 @@ require_once 'type/GenericStacked.class.php'; | |||
16 | # cpu-X/cpu-user.rrd | 17 | # cpu-X/cpu-user.rrd |
17 | # cpu-X/cpu-wait.rrd | 18 | # cpu-X/cpu-wait.rrd |
18 | 19 | ||
19 | # grouped | 20 | $obj = new Type_GenericStacked($CONFIG['datadir']); |
20 | require_once 'inc/collectd.inc.php'; | ||
21 | $tinstance = collectd_plugindetail($host, $plugin, 'ti'); | ||
22 | |||
23 | $obj = new Type_GenericStacked; | ||
24 | $obj->datadir = $CONFIG['datadir']; | ||
25 | $obj->args = array( | ||
26 | 'host' => $host, | ||
27 | 'plugin' => $plugin, | ||
28 | 'pinstance' => $pinstance, | ||
29 | 'type' => $type, | ||
30 | 'tinstance' => $tinstance, | ||
31 | ); | ||
32 | $obj->data_sources = array('value'); | 21 | $obj->data_sources = array('value'); |
33 | $obj->order = array('idle', 'nice', 'user', 'wait', 'system', 'softirq', 'interrupt', 'steal'); | 22 | $obj->order = array('idle', 'nice', 'user', 'wait', 'system', 'softirq', 'interrupt', 'steal'); |
34 | $obj->ds_names = array( | 23 | $obj->ds_names = array( |
@@ -53,14 +42,12 @@ $obj->colors = array( | |||
53 | ); | 42 | ); |
54 | $obj->width = $width; | 43 | $obj->width = $width; |
55 | $obj->heigth = $heigth; | 44 | $obj->heigth = $heigth; |
56 | $obj->seconds = $seconds; | ||
57 | 45 | ||
58 | $obj->rrd_title = sprintf('CPU-%s usage', $pinstance); | 46 | $obj->rrd_title = sprintf('CPU-%s usage', $obj->args['pinstance']); |
59 | $obj->rrd_vertical = 'Jiffies'; | 47 | $obj->rrd_vertical = 'Jiffies'; |
60 | $obj->rrd_format = '%5.2lf'; | 48 | $obj->rrd_format = '%5.2lf'; |
61 | 49 | ||
62 | collectd_flush(ident_from_args($obj->args)); | 50 | collectd_flush($obj->identifiers); |
63 | |||
64 | $obj->rrd_graph(); | 51 | $obj->rrd_graph(); |
65 | 52 | ||
66 | ?> | 53 | ?> |