From d21f4a765b82e4c02ff15bf730b0e1f0d68d5471 Mon Sep 17 00:00:00 2001 From: Pim van den Berg Date: Tue, 24 Jun 2014 12:38:10 +0200 Subject: add percentile support to network traffic graphs Set $CONFIG['percentile'] to a number and a XXth percentile line + legend will be added to all network traffic (if_octets) graphs. Closes #81 --- type/GenericIO.class.php | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'type/GenericIO.class.php') diff --git a/type/GenericIO.class.php b/type/GenericIO.class.php index fac7034..a9d58cd 100644 --- a/type/GenericIO.class.php +++ b/type/GenericIO.class.php @@ -33,6 +33,8 @@ class Type_GenericIO extends Type_Base { if ($i == 1) $rrdgraph[] = sprintf('CDEF:avg_%s_neg=avg_%1$s_raw,%s%s,*', crc32hex($sources[$i]), $this->negative_io ? '-' : '', $this->scale); $rrdgraph[] = sprintf('VDEF:tot_%1$s=avg_%1$s,TOTAL', crc32hex($sources[$i])); + if ($this->percentile) + $rrdgraph[] = sprintf('VDEF:pct_%1$s=avg_%1$s_raw,%2$s,PERCENT', crc32hex($sources[$i]), $this->percentile); $i++; } } @@ -66,6 +68,15 @@ class Type_GenericIO extends Type_Base { $i++; } + if ($this->percentile) { + $rrdgraph[] = sprintf('"COMMENT: \l"'); + foreach($sources as $source) { + $legend = empty($this->legend[$source]) ? $source : $this->legend[$source]; + $rrdgraph[] = sprintf('"HRULE:pct_%s#%s:%sth Percentile %s"', crc32hex($source), $this->get_faded_color($this->colors[$source], '000000', 0.6), $this->percentile, $this->rrd_escape($legend)); + $rrdgraph[] = sprintf('"GPRINT:pct_%s:%s\l"', crc32hex($source), $this->rrd_format); + } + } + return $rrdgraph; } } -- cgit v1.1