From 95c70c919837f588389f525fe2cf4aba479e9f91 Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Thu, 31 Dec 2009 11:42:56 +0100 Subject: 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. --- plugin/cpu.php | 21 ++++----------------- 1 file changed, 4 insertions(+), 17 deletions(-) (limited to 'plugin/cpu.php') 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 @@ require_once 'conf/common.inc.php'; require_once 'type/GenericStacked.class.php'; +require_once 'inc/collectd.inc.php'; ## LAYOUT # cpu-X/ @@ -16,19 +17,7 @@ require_once 'type/GenericStacked.class.php'; # cpu-X/cpu-user.rrd # cpu-X/cpu-wait.rrd -# grouped -require_once 'inc/collectd.inc.php'; -$tinstance = collectd_plugindetail($host, $plugin, 'ti'); - -$obj = new Type_GenericStacked; -$obj->datadir = $CONFIG['datadir']; -$obj->args = array( - 'host' => $host, - 'plugin' => $plugin, - 'pinstance' => $pinstance, - 'type' => $type, - 'tinstance' => $tinstance, -); +$obj = new Type_GenericStacked($CONFIG['datadir']); $obj->data_sources = array('value'); $obj->order = array('idle', 'nice', 'user', 'wait', 'system', 'softirq', 'interrupt', 'steal'); $obj->ds_names = array( @@ -53,14 +42,12 @@ $obj->colors = array( ); $obj->width = $width; $obj->heigth = $heigth; -$obj->seconds = $seconds; -$obj->rrd_title = sprintf('CPU-%s usage', $pinstance); +$obj->rrd_title = sprintf('CPU-%s usage', $obj->args['pinstance']); $obj->rrd_vertical = 'Jiffies'; $obj->rrd_format = '%5.2lf'; -collectd_flush(ident_from_args($obj->args)); - +collectd_flush($obj->identifiers); $obj->rrd_graph(); ?> -- cgit v1.1