From 074589c36937a468587abe37bc4ce0fbddf80b20 Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Wed, 5 Sep 2012 16:07:44 +0200 Subject: apply datasize (bytes/bits) only to network related data As discussed in https://github.com/pommi/CGP/pull/1. --- conf/config.php | 2 +- plugin/apache.php | 6 +++--- plugin/df.php | 5 ++--- plugin/disk.php | 3 +-- plugin/filecount.php | 3 +-- plugin/interface.php | 4 ++-- plugin/libvirt.php | 7 +++---- plugin/memcached.php | 7 +++---- plugin/memory.php | 3 +-- plugin/netlink.php | 4 ++-- plugin/postgresql.php | 3 +-- plugin/processes.php | 18 ++++++------------ plugin/swap.php | 3 +-- plugin/vserver.php | 7 +++---- plugin/zfs_arc.php | 11 ++++------- 15 files changed, 34 insertions(+), 52 deletions(-) diff --git a/conf/config.php b/conf/config.php index c6fce92..1862044 100644 --- a/conf/config.php +++ b/conf/config.php @@ -26,7 +26,7 @@ $CONFIG['time_range']['uptime'] = 31536000; $CONFIG['showload'] = true; # show graphs in bits or bytes -$CONFIG['datasize'] = 'bytes'; +$CONFIG['network_datasize'] = 'bytes'; # browser cache time for the graphs (in seconds) $CONFIG['cache'] = 90; diff --git a/plugin/apache.php b/plugin/apache.php index 71be4fe..c942255 100644 --- a/plugin/apache.php +++ b/plugin/apache.php @@ -19,15 +19,15 @@ switch ($obj->args['type']) { case 'apache_bytes': $obj->data_sources = array('value'); $obj->ds_names = array( - 'value' => sprintf('%s/s', ucfirst($CONFIG['datasize'])), + 'value' => sprintf('%s/s', ucfirst($CONFIG['network_datasize'])), ); $obj->colors = array( 'value' => '0000ff', ); $obj->rrd_title = sprintf('Webserver Traffic%s', !empty($obj->args['pinstance']) ? ' ('.$obj->args['pinstance'].')' : ''); - $obj->rrd_vertical = sprintf('%s/s', ucfirst($CONFIG['datasize'])); - $obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1; + $obj->rrd_vertical = sprintf('%s/s', ucfirst($CONFIG['network_datasize'])); + $obj->scale = $CONFIG['network_datasize'] == 'bits' ? 8 : 1; break; case 'apache_connections': $obj->data_sources = array('value'); diff --git a/plugin/df.php b/plugin/df.php index 33dded9..b5c7e73 100644 --- a/plugin/df.php +++ b/plugin/df.php @@ -29,9 +29,8 @@ $obj->width = $width; $obj->heigth = $heigth; $obj->rrd_title = sprintf('Free space (%s)', $obj->args['pinstance']); -$obj->rrd_vertical = ucfirst($CONFIG['datasize']); -$obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1; -$obj->rrd_format = '%5.1lf%s'; +$obj->rrd_vertical = 'Bytes'; +$obj->rrd_format = '%5.1lf%sB'; # backwards compatibility if ($CONFIG['version'] < 5) { diff --git a/plugin/disk.php b/plugin/disk.php index a776abd..e3a5f3d 100644 --- a/plugin/disk.php +++ b/plugin/disk.php @@ -33,9 +33,8 @@ switch($obj->args['type']) { break; case 'disk_octets': $obj->rrd_title = sprintf('Disk Traffic (%s)', $obj->args['pinstance']); - $obj->rrd_vertical = sprintf('%s per second', ucfirst($CONFIG['datasize'])); + $obj->rrd_vertical = 'Bytes per second'; $obj->rrd_format = '%5.1lf%s'; - $obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1; break; case 'disk_ops': $obj->rrd_title = sprintf('Disk Operations (%s)', $obj->args['pinstance']); diff --git a/plugin/filecount.php b/plugin/filecount.php index 68545e7..2c318a9 100644 --- a/plugin/filecount.php +++ b/plugin/filecount.php @@ -23,8 +23,7 @@ switch($obj->args['type']) { $obj->ds_names = array('value' => 'Size'); $obj->colors = array('value' => '0000ff'); $obj->rrd_title = sprintf('Filecount: size (%s)', $obj->args['pinstance']); - $obj->rrd_vertical = ucfirst($CONFIG['datasize']); - $obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1; + $obj->rrd_vertical = 'Bytes'; break; case 'files': $obj->ds_names = array('value' => 'Files'); diff --git a/plugin/interface.php b/plugin/interface.php index 107cb27..777f953 100644 --- a/plugin/interface.php +++ b/plugin/interface.php @@ -39,8 +39,8 @@ switch($obj->args['type']) { break; case 'if_octets': $obj->rrd_title = sprintf('Interface Traffic (%s)', $obj->args[$instance]); - $obj->rrd_vertical = sprintf('%s per second', ucfirst($CONFIG['datasize'])); - $obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1; + $obj->rrd_vertical = sprintf('%s per second', ucfirst($CONFIG['network_datasize'])); + $obj->scale = $CONFIG['network_datasize'] == 'bits' ? 8 : 1; break; case 'if_packets': $obj->rrd_title = sprintf('Interface Packets (%s)', $obj->args[$instance]); diff --git a/plugin/libvirt.php b/plugin/libvirt.php index 971b5a7..004eb26 100644 --- a/plugin/libvirt.php +++ b/plugin/libvirt.php @@ -30,8 +30,7 @@ switch($obj->args['type']) { 'write' => '00b000', ); $obj->rrd_title = sprintf('Disk Traffic (%s)', $obj->args['tinstance']); - $obj->rrd_vertical = sprintf('%s per second', ucfirst($CONFIG['datasize'])); - $obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1; + $obj->rrd_vertical = 'Bytes per second'; $obj->rrd_format = '%5.1lf%s'; break; case 'disk_ops': @@ -85,8 +84,8 @@ switch($obj->args['type']) { 'tx' => '00b000', ); $obj->rrd_title = sprintf('Interface Traffic (%s)', $obj->args['tinstance']); - $obj->rrd_vertical = sprintf('%s per second', ucfirst($CONFIG['datasize'])); - $obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1; + $obj->rrd_vertical = sprintf('%s per second', ucfirst($CONFIG['network_datasize'])); + $obj->scale = $CONFIG['network_datasize'] == 'bits' ? 8 : 1; break; case 'if_packets': $obj->data_sources = array('rx', 'tx'); diff --git a/plugin/memcached.php b/plugin/memcached.php index 2230f3f..60887bc 100644 --- a/plugin/memcached.php +++ b/plugin/memcached.php @@ -37,8 +37,7 @@ switch(GET('t')) { 'free' => '0000ff', ); $obj->rrd_title = 'Memcached Memory Usage'; - $obj->rrd_vertical = ucfirst($CONFIG['datasize']); - $obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1; + $obj->rrd_vertical = 'bytes'; break; # memcached_command-(flush|get|set).rrd @@ -105,8 +104,8 @@ switch(GET('t')) { 'tx' => '00b000', ); $obj->rrd_title = 'Memcached Network Traffic'; - $obj->rrd_vertical = ucfirst($CONFIG['datasize']); - $obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1; + $obj->rrd_vertical = ucfirst($CONFIG['network_datasize']); + $obj->scale = $CONFIG['network_datasize'] == 'bits' ? 8 : 1; break; # memcached_ops-(evictions|hits|misses).rrd case 'memcached_ops': diff --git a/plugin/memory.php b/plugin/memory.php index afccc55..14779e2 100644 --- a/plugin/memory.php +++ b/plugin/memory.php @@ -33,8 +33,7 @@ $obj->width = $width; $obj->heigth = $heigth; $obj->rrd_title = 'Physical memory utilization'; -$obj->rrd_vertical = ucfirst($CONFIG['datasize']); -$obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1; +$obj->rrd_vertical = 'Bytes'; $obj->rrd_format = '%5.1lf%s'; collectd_flush($obj->identifiers); diff --git a/plugin/netlink.php b/plugin/netlink.php index 77c0c48..146545e 100644 --- a/plugin/netlink.php +++ b/plugin/netlink.php @@ -64,8 +64,8 @@ switch($obj->args['type']) { 'tx' => '00b000', ); $obj->rrd_title = sprintf('Interface Traffic (%s)', $obj->args['pinstance']); - $obj->rrd_vertical = sprintf('%s/s', ucfirst($CONFIG['datasize'])); - $obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1; + $obj->rrd_vertical = sprintf('%s/s', ucfirst($CONFIG['network_datasize'])); + $obj->scale = $CONFIG['network_datasize'] == 'bits' ? 8 : 1; break; case 'if_packets': $obj->data_sources = array('rx', 'tx'); diff --git a/plugin/postgresql.php b/plugin/postgresql.php index ed984a6..1eadc8d 100644 --- a/plugin/postgresql.php +++ b/plugin/postgresql.php @@ -51,8 +51,7 @@ switch($obj->args['type']) { ); $obj->rrd_title = sprintf('PostgreSQL DB size (%s)', !empty($obj->args['pinstance']) ? $obj->args['pinstance'] : ''); - $obj->rrd_vertical = ucfirst($CONFIG['datasize']); - $obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1; + $obj->rrd_vertical = 'Bytes'; break; case 'pg_n_tup_c': $obj->order = array( diff --git a/plugin/processes.php b/plugin/processes.php index c66d3fb..dca00b7 100644 --- a/plugin/processes.php +++ b/plugin/processes.php @@ -63,8 +63,7 @@ switch($obj->args['type']) 'value' => '0000ff', ); $obj->rrd_title = sprintf('Text Resident Set (%s)', $obj->args['pinstance']); - $obj->rrd_vertical = ucfirst($CONFIG['datasize']); - $obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1; + $obj->rrd_vertical = 'Bytes'; break; case 'ps_count': @@ -106,8 +105,7 @@ switch($obj->args['type']) 'write' => '00b000', ); $obj->rrd_title = sprintf('Disk Traffic (%s)', $obj->args['pinstance']); - $obj->rrd_vertical = sprintf('%s per second', ucfirst($CONFIG['datasize'])); - $obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1; + $obj->rrd_vertical = 'Bytes per second'; break; case 'ps_disk_ops': @@ -132,8 +130,7 @@ switch($obj->args['type']) 'value' => '0000ff', ); $obj->rrd_title = sprintf('Data Resident Set (%s)', $obj->args['pinstance']); - $obj->rrd_vertical = ucfirst($CONFIG['datasize']); - $obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1; + $obj->rrd_vertical = 'Bytes'; break; case 'ps_pagefaults': @@ -158,8 +155,7 @@ switch($obj->args['type']) 'value' => '0000ff', ); $obj->rrd_title = sprintf('Resident Segment Size (%s)', $obj->args['pinstance']); - $obj->rrd_vertical = ucfirst($CONFIG['datasize']); - $obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1; + $obj->rrd_vertical = 'Bytes'; break; case 'ps_stacksize': @@ -170,8 +166,7 @@ switch($obj->args['type']) 'value' => '0000ff', ); $obj->rrd_title = sprintf('Stacksize (%s)', $obj->args['pinstance']); - $obj->rrd_vertical = ucfirst($CONFIG['datasize']); - $obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1; + $obj->rrd_vertical = 'Bytes'; break; case 'ps_vm': @@ -182,8 +177,7 @@ switch($obj->args['type']) 'value' => '0000ff', ); $obj->rrd_title = sprintf('Virtual Memory (%s)', $obj->args['pinstance']); - $obj->rrd_vertical = ucfirst($CONFIG['datasize']); - $obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1; + $obj->rrd_vertical = 'Bytes'; break; } diff --git a/plugin/swap.php b/plugin/swap.php index dee5692..c24d90b 100644 --- a/plugin/swap.php +++ b/plugin/swap.php @@ -27,8 +27,7 @@ switch(GET('t')) { 'used' => 'ff0000', ); $obj->rrd_title = 'Swap utilization'; - $obj->rrd_vertical = ucfirst($CONFIG['datasize']); - $obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1; + $obj->rrd_vertical = 'Bytes'; break; case 'swap_io': require_once 'type/GenericIO.class.php'; diff --git a/plugin/vserver.php b/plugin/vserver.php index 204134e..c727ad9 100644 --- a/plugin/vserver.php +++ b/plugin/vserver.php @@ -51,8 +51,7 @@ switch($obj->args['type']) { $obj->heigth = $heigth; $obj->rrd_title = sprintf('Memory utilization on Vserver %s', $obj->args['pinstance']); - $obj->rrd_vertical = ucfirst($CONFIG['datasize']); - $obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1; + $obj->rrd_vertical = 'Bytes'; $obj->rrd_format = '%5.1lf%s'; collectd_flush($obj->identifiers); @@ -105,8 +104,8 @@ switch($obj->args['type']) { 'unspec-tx' => '000080', ); $obj->rrd_title = sprintf('Traffic on Vserver %s', $obj->args['pinstance']); - $obj->rrd_vertical = sprintf('%s per second', ucfirst($CONFIG['datasize'])); - $obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1; + $obj->rrd_vertical = sprintf('%s per second', ucfirst($CONFIG['network_datasize'])); + $obj->scale = $CONFIG['network_datasize'] == 'bits' ? 8 : 1; $obj->width = $width; $obj->heigth = $heigth; $obj->rrd_format = '%5.1lf%s'; diff --git a/plugin/zfs_arc.php b/plugin/zfs_arc.php index 1cc7e81..d40912d 100644 --- a/plugin/zfs_arc.php +++ b/plugin/zfs_arc.php @@ -60,8 +60,7 @@ switch($obj->args['type']) { 'maxlimit', ); $obj->rrd_title = 'Arc size'; - $obj->rrd_vertical = ucfirst($CONFIG['datasize']); - $obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1; + $obj->rrd_vertical = 'bytes'; break; case 'arc_l2_bytes': $obj->data_sources = array( @@ -77,22 +76,20 @@ switch($obj->args['type']) { 'read' => '0000ff', ); $obj->rrd_title = 'Arc L2 bytes'; - $obj->rrd_vertical = ucfirst($CONFIG['datasize']); - $obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1; + $obj->rrd_vertical = 'bytes'; break; case 'arc_l2_size': $obj->data_sources = array( 'value', ); $obj->ds_names = array( - 'value' => ucfirst($CONFIG['datasize']), + 'value' => 'Bytes', ); $obj->colors = array( 'value' => '0000ff', ); $obj->rrd_title = 'Arc L2 size'; - $obj->rrd_vertical = ucfirst($CONFIG['datasize']); - $obj->scale = $CONFIG['datasize'] == 'bits' ? 8 : 1; + $obj->rrd_vertical = 'bytes'; break; case 'arc_ratio': $obj->data_sources = array('value'); -- cgit v1.1