From e1ea1b6cbe03055cb32463d7046b21a2f9b0fbbd Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Thu, 10 Mar 2011 20:14:21 +0100 Subject: plugin/postgresql: make postgresql plugin compatible with cgp --- plugin/postgresql.php | 96 +++++++++++++++++++++------------------------------ 1 file changed, 40 insertions(+), 56 deletions(-) (limited to 'plugin') diff --git a/plugin/postgresql.php b/plugin/postgresql.php index bca39f9..596f590 100644 --- a/plugin/postgresql.php +++ b/plugin/postgresql.php @@ -1,65 +1,49 @@ width = $width; - $obj->heigth = $heigth; - $obj->ds_names = array( - 'value' => 'Size', - ); - $obj->colors = array( - 'value' => '0000ff', - ); - $obj->rrd_title = sprintf('DB Size %s', - !empty($obj->args['pinstance']) ? $obj->args['pinstance'] : ''); - $obj->rrd_vertical = 'Size'; - $obj->rrd_format = '%5.1lf%s'; - break; - case 'pg_blks': - require_once 'type/GenericStacked.class.php'; - $obj = new Type_GenericStacked($CONFIG); - $obj->width = $width; - $obj->heigth = $heigth; - $obj->generate_colors(); - - $obj->rrd_title = sprintf('%s/%s', $obj->args['pinstance'], $obj->args['type']); - $obj->rrd_vertical = 'Ops per second'; - $obj->rrd_format = '%5.1lf%s'; - break; - case 'pg_n_tup_c': - require_once 'type/GenericStacked.class.php'; - $obj = new Type_GenericStacked($CONFIG); - $obj->width = $width; - $obj->heigth = $heigth; - $obj->generate_colors(); - - $obj->rrd_title = sprintf('%s/%s', $obj->args['pinstance'], $obj->args['type']); - $obj->rrd_vertical = 'Ops per second'; - $obj->rrd_format = '%5.1lf%s'; - break; +require_once 'conf/common.inc.php'; +require_once 'type/GenericStacked.class.php'; +require_once 'inc/collectd.inc.php'; +## LAYOUT +# postgresql-X/pg_blks-heap_hit.rrd +# postgresql-X/pg_blks-heap_read.rrd +# postgresql-X/pg_blks-idx_hit.rrd +# postgresql-X/pg_blks-idx_read.rrd +# postgresql-X/pg_blks-tidx_hit.rrd +# postgresql-X/pg_blks-tidx_read.rrd +# postgresql-X/pg_blks-toast_hit.rrd +# postgresql-X/pg_blks-toast_read.rrd +# postgresql-X/pg_db_size.rrd +# postgresql-X/pg_n_tup_c-del.rrd +# postgresql-X/pg_n_tup_c-hot_upd.rrd +# postgresql-X/pg_n_tup_c-ins.rrd +# postgresql-X/pg_n_tup_c-upd.rrd + +$obj = new Type_GenericStacked($CONFIG); +$obj->width = $width; +$obj->heigth = $heigth; +$obj->rrd_format = '%5.1lf%s'; + +switch($obj->args['type']) { + case 'pg_db_size': + $obj->ds_names = array( + 'value' => 'Size', + ); + $obj->colors = array( + 'value' => '0000ff', + ); + $obj->rrd_title = sprintf('DB Size %s', + !empty($obj->args['pinstance']) ? $obj->args['pinstance'] : ''); + $obj->rrd_vertical = 'Size'; + break; + case 'pg_blks': + case 'pg_n_tup_c': + $obj->rrd_title = sprintf('%s/%s', $obj->args['pinstance'], $obj->args['type']); + $obj->rrd_vertical = 'Ops per second'; + break; } - collectd_flush($obj->identifiers); $obj->rrd_graph(); -- cgit v1.1