From 6bc103c0c6880673f207c87466f4fcac2645bd8c Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Sun, 10 Apr 2011 19:56:08 +0200 Subject: plugin: deduplicate rrd_format code --- plugin/dns.php | 5 ++--- plugin/mysql.php | 7 +------ plugin/ntpd.php | 6 ++---- plugin/ping.php | 5 ++--- plugin/processes.php | 13 +------------ plugin/vmem.php | 5 ++--- 6 files changed, 10 insertions(+), 31 deletions(-) (limited to 'plugin') diff --git a/plugin/dns.php b/plugin/dns.php index 15143b5..d0784df 100644 --- a/plugin/dns.php +++ b/plugin/dns.php @@ -15,6 +15,8 @@ require_once 'inc/collectd.inc.php'; $obj = new Type_GenericStacked($CONFIG); $obj->width = $width; $obj->heigth = $heigth; +$obj->rrd_format = '%5.1lf%s'; + switch($obj->args['type']) { case 'dns_octets': $obj->data_sources = array( @@ -31,19 +33,16 @@ switch($obj->args['type']) { ); $obj->rrd_title = 'DNS traffic'; $obj->rrd_vertical = 'Bit/s'; - $obj->rrd_format = '%5.1lf%s'; break; case 'dns_opcode': $obj->data_sources = array('value'); $obj->rrd_title = 'DNS Opcode Query'; $obj->rrd_vertical = 'Queries/s'; - $obj->rrd_format = '%5.1lf%s'; break; case 'dns_qtype': $obj->data_sources = array('value'); $obj->rrd_title = 'DNS QType'; $obj->rrd_vertical = 'Queries/s'; - $obj->rrd_format = '%5.1lf%s'; break; } diff --git a/plugin/mysql.php b/plugin/mysql.php index c73c37a..aac9e88 100644 --- a/plugin/mysql.php +++ b/plugin/mysql.php @@ -9,13 +9,13 @@ require_once 'inc/collectd.inc.php'; $obj = new Type_GenericStacked($CONFIG); $obj->width = $width; $obj->heigth = $heigth; +$obj->rrd_format = '%5.1lf%s'; switch($obj->args['type']) { case 'mysql_commands': $obj->rrd_title = sprintf('MySQL commands (%s)', $obj->args['pinstance']); $obj->rrd_vertical = 'Issues/s'; - $obj->rrd_format = '%5.1lf%s'; break; case 'mysql_handler': $obj->colors = array( @@ -33,7 +33,6 @@ switch($obj->args['type']) ); $obj->rrd_title = sprintf('MySQL handler (%s)', $obj->args['pinstance']); $obj->rrd_vertical = 'Invocations'; - $obj->rrd_format = '%5.1lf%s'; break; case 'mysql_locks': $obj->colors = array( @@ -42,7 +41,6 @@ switch($obj->args['type']) ); $obj->rrd_title = sprintf('MySQL locks (%s)', $obj->args['pinstance']); $obj->rrd_vertical = 'locks'; - $obj->rrd_format = '%5.1lf%s'; break; case 'mysql_octets': $obj->data_sources = array('rx', 'tx'); @@ -56,7 +54,6 @@ switch($obj->args['type']) ); $obj->rrd_title = sprintf('MySQL traffic (%s)', $obj->args['pinstance']); $obj->rrd_vertical = 'Bits per second'; - $obj->rrd_format = '%5.1lf%s'; break; case 'mysql_qcache': $obj->data_sources = array('not_cached', 'inserts', 'hits', 'lowmem_prunes', 'queries_in_cache'); @@ -76,7 +73,6 @@ switch($obj->args['type']) ); $obj->rrd_title = sprintf('MySQL query cache (%s)', $obj->args['pinstance']); $obj->rrd_vertical = 'Queries/s'; - $obj->rrd_format = '%5.1lf%s'; break; case 'mysql_threads': $obj->data_sources = array('cached', 'connected', 'running', 'created'); @@ -94,7 +90,6 @@ switch($obj->args['type']) ); $obj->rrd_title = sprintf('MySQL threads (%s)', $obj->args['pinstance']); $obj->rrd_vertical = 'Threads'; - $obj->rrd_format = '%5.1lf%s'; break; } diff --git a/plugin/ntpd.php b/plugin/ntpd.php index c85ce8c..18187a9 100644 --- a/plugin/ntpd.php +++ b/plugin/ntpd.php @@ -19,30 +19,28 @@ $obj->ds_names = array('ping' => 'Ping time', 'ping_droprate' => 'Ping droprate'); $obj->width = $width; $obj->heigth = $heigth; +$obj->rrd_format = '%5.1lf%s'; + switch($obj->args['type']) { case 'delay': $obj->data_sources = array('seconds'); $obj->rrd_title = sprintf('Delay'); $obj->rrd_vertical = 'Seconds'; - $obj->rrd_format = '%5.1lf%s'; break; case 'frequency_offset': $obj->data_sources = array('ppm'); $obj->rrd_title = 'Frequency offset'; $obj->rrd_vertical = 'ppm'; - $obj->rrd_format = '%5.1lf%s'; break; case 'time_dispersion': $obj->data_sources = array('seconds'); $obj->rrd_title = 'Time dispersion'; $obj->rrd_vertical = 'Seconds'; - $obj->rrd_format = '%5.1lf%s'; break; case 'time_offset': $obj->data_sources = array('seconds'); $obj->rrd_title = 'Time offset'; $obj->rrd_vertical = 'Seconds'; - $obj->rrd_format = '%5.1lf%s'; break; } diff --git a/plugin/ping.php b/plugin/ping.php index 1ea53de..9780969 100644 --- a/plugin/ping.php +++ b/plugin/ping.php @@ -19,22 +19,21 @@ $obj->ds_names = array('ping' => 'Ping time', 'ping_droprate' => 'Ping droprate'); $obj->width = $width; $obj->heigth = $heigth; +$obj->rrd_format = '%5.1lf'; + switch($obj->args['type']) { case 'ping': $obj->data_sources = array('ping'); $obj->rrd_title = 'Ping latency'; $obj->rrd_vertical = 'Milliseconds'; - $obj->rrd_format = '%5.1lf'; break; case 'ping_stddev': $obj->rrd_title = 'Ping stddev'; $obj->rrd_vertical = ''; - $obj->rrd_format = '%5.1lf'; break; case 'ping_droprate': $obj->rrd_title = 'Ping droprate'; $obj->rrd_vertical = ''; - $obj->rrd_format = '%5.1lf'; break; } diff --git a/plugin/processes.php b/plugin/processes.php index 466e1e3..dca00b7 100644 --- a/plugin/processes.php +++ b/plugin/processes.php @@ -18,6 +18,7 @@ require_once 'inc/collectd.inc.php'; $obj = new Type_GenericStacked($CONFIG); $obj->width = $width; $obj->heigth = $heigth; +$obj->rrd_format = '%5.1lf%s'; switch($obj->args['type']) { @@ -41,7 +42,6 @@ switch($obj->args['type']) ); $obj->rrd_title = 'Processes'; $obj->rrd_vertical = 'Processes'; - $obj->rrd_format = '%5.1lf%s'; break; case 'fork_rate': @@ -53,7 +53,6 @@ switch($obj->args['type']) ); $obj->rrd_title = 'Fork rate'; $obj->rrd_vertical = 'forks/s'; - $obj->rrd_format = '%5.1lf%s'; break; case 'ps_code': @@ -65,7 +64,6 @@ switch($obj->args['type']) ); $obj->rrd_title = sprintf('Text Resident Set (%s)', $obj->args['pinstance']); $obj->rrd_vertical = 'Bytes'; - $obj->rrd_format = '%5.1lf%s'; break; case 'ps_count': @@ -80,7 +78,6 @@ switch($obj->args['type']) ); $obj->rrd_title = sprintf('Number of Processes/Threads (%s)', $obj->args['pinstance']); $obj->rrd_vertical = 'Amount'; - $obj->rrd_format = '%5.1lf%s'; break; case 'ps_cputime': @@ -95,7 +92,6 @@ switch($obj->args['type']) ); $obj->rrd_title = sprintf('CPU time (%s)', $obj->args['pinstance']); $obj->rrd_vertical = 'CPU time [s]'; - $obj->rrd_format = '%5.1lf%s'; break; case 'ps_disk_octets': @@ -110,7 +106,6 @@ switch($obj->args['type']) ); $obj->rrd_title = sprintf('Disk Traffic (%s)', $obj->args['pinstance']); $obj->rrd_vertical = 'Bytes per second'; - $obj->rrd_format = '%5.1lf%s'; break; case 'ps_disk_ops': @@ -125,7 +120,6 @@ switch($obj->args['type']) ); $obj->rrd_title = sprintf('Disk Operations (%s)', $obj->args['pinstance']); $obj->rrd_vertical = 'Ops per second'; - $obj->rrd_format = '%5.1lf%s'; break; case 'ps_data': @@ -137,7 +131,6 @@ switch($obj->args['type']) ); $obj->rrd_title = sprintf('Data Resident Set (%s)', $obj->args['pinstance']); $obj->rrd_vertical = 'Bytes'; - $obj->rrd_format = '%5.1lf%s'; break; case 'ps_pagefaults': @@ -152,7 +145,6 @@ switch($obj->args['type']) ); $obj->rrd_title = sprintf('PageFaults (%s)', $obj->args['pinstance']); $obj->rrd_vertical = 'Pagefaults'; - $obj->rrd_format = '%5.1lf%s'; break; case 'ps_rss': @@ -164,7 +156,6 @@ switch($obj->args['type']) ); $obj->rrd_title = sprintf('Resident Segment Size (%s)', $obj->args['pinstance']); $obj->rrd_vertical = 'Bytes'; - $obj->rrd_format = '%5.1lf%s'; break; case 'ps_stacksize': @@ -176,7 +167,6 @@ switch($obj->args['type']) ); $obj->rrd_title = sprintf('Stacksize (%s)', $obj->args['pinstance']); $obj->rrd_vertical = 'Bytes'; - $obj->rrd_format = '%5.1lf%s'; break; case 'ps_vm': @@ -188,7 +178,6 @@ switch($obj->args['type']) ); $obj->rrd_title = sprintf('Virtual Memory (%s)', $obj->args['pinstance']); $obj->rrd_vertical = 'Bytes'; - $obj->rrd_format = '%5.1lf%s'; break; } diff --git a/plugin/vmem.php b/plugin/vmem.php index ea541fc..2fae536 100644 --- a/plugin/vmem.php +++ b/plugin/vmem.php @@ -16,6 +16,8 @@ require_once 'inc/collectd.inc.php'; $obj = new Type_GenericStacked($CONFIG); $obj->width = $width; $obj->heigth = $heigth; +$obj->rrd_format = '%5.1lf%s'; + switch($obj->args['type']) { case 'vmpage_faults': $obj->data_sources = array('minflt', 'majflt'); @@ -25,7 +27,6 @@ switch($obj->args['type']) { 'majflt' => 'Major'); $obj->rrd_title = 'Page faults'; $obj->rrd_vertical = ''; - $obj->rrd_format = '%5.1lf%s'; break; case 'vmpage_io': $obj->data_sources = array('in', 'out'); @@ -39,7 +40,6 @@ switch($obj->args['type']) { 'swap-out' => 'ffff00'); $obj->rrd_title = 'Page IO'; $obj->rrd_vertical = ''; - $obj->rrd_format = '%5.1lf%s'; break; case 'vmpage_number': $obj->data_sources = array('value'); @@ -55,7 +55,6 @@ switch($obj->args['type']) { 'writeback', 'writeback_temp'); $obj->rrd_title = 'Pages'; $obj->rrd_vertical = ''; - $obj->rrd_format = '%5.1lf%s'; break; } -- cgit v1.1