--- projects/cms/source/reports/rrdgraphing/graph.pl 2005/02/10 17:35:58 1.15 +++ projects/cms/source/reports/rrdgraphing/graph.pl 2005/06/29 10:26:40 1.19 @@ -27,7 +27,7 @@ # Generates graphs from rrd databases for i-scream data. # # $Author: tdb $ -# $Id: graph.pl,v 1.15 2005/02/10 17:35:58 tdb Exp $ +# $Id: graph.pl,v 1.19 2005/06/29 10:26:40 tdb Exp $ #------------------------------------------------------------ ## TODO @@ -35,7 +35,7 @@ # -- allow configurable periods of graphs # -- comments, types, etc -my($version) = '$Id: graph.pl,v 1.15 2005/02/10 17:35:58 tdb Exp $'; +my($version) = '$Id: graph.pl,v 1.19 2005/06/29 10:26:40 tdb Exp $'; $| = 1; @@ -48,7 +48,8 @@ use RRDs; use vars qw{ $imgdir $rrddir $maxrrdage $maximgage $deleterrds $deleteimgs - $hex_slash $hex_underscore $hex_space $hex_colon $hex_bslash + $hex_slash $hex_underscore $hex_space $hex_colon $hex_bslash $hex_rbracket + $hex_lbracket $hex_plus $hex_hash $rrdstep $retry_wait $verbose $quiet }; @@ -156,10 +157,10 @@ foreach my $machine (@rrddirlist) { push @data, "NONE:$1:free:free#CCCCFF:NONE:free memory"; push @data, "NONE:$1:total:total#0000FF:NONE:total memory\\n"; push @data, "NONE:$1:cache:cache#0000FF:NONE:cache memory\\n"; - # calculate peruse - note that we only use 'free' if it's less than total - # (this is to avoid negative percentages :) - push @rawdata, "CDEF:peruse=total,free,total,LT,free,0,IF,-,total,/,100,*"; - push @rawdata, "CDEF:percacuse=cache,total,LT,cache,0,IF,total,/,100,*"; + # calculate peruse - note that we only use 'free' if it's + # less or equal to total (this is to avoid negative percentages :) + push @rawdata, "CDEF:peruse=total,free,total,LE,free,0,IF,-,total,/,100,*"; + push @rawdata, "CDEF:percacuse=cache,total,LE,cache,0,IF,total,/,100,*"; # and add it to the graph push @rawdata, "AREA:peruse#CCCCFF:% memory in use"; &addlegend(\@rawdata, "peruse"); @@ -194,9 +195,9 @@ foreach my $machine (@rrddirlist) { # although we need it to work out peruse... push @data, "NONE:$1:free:free#CCCCFF:NONE:free swap"; push @data, "NONE:$1:total:total#0000FF:NONE:total swap\\n"; - # calculate peruse - note that we only use 'free' if it's less than total - # (this is to avoid negative percentages :) - push @rawdata, "CDEF:peruse=total,free,total,LT,free,0,IF,-,total,/,100,*"; + # calculate peruse - note that we only use 'free' if it's + # less or equal to total (this is to avoid negative percentages :) + push @rawdata, "CDEF:peruse=total,free,total,LE,free,0,IF,-,total,/,100,*"; # and add it to the graph push @rawdata, "AREA:peruse#CCCCFF:% swap in use"; push @rawdata, "--upper-limit=100"; @@ -257,7 +258,7 @@ foreach my $machine (@rrddirlist) { push @data, "AREA:$1-$2:rbytes:rbytes#00FF00:OK:read bytes "; push @data, "LINE2:$1-$2:wbytes:wbytes#0000FF:OK:write bytes"; push @rawdata, "--base=1024"; - # some name tidting + # some name tidying my($type) = $1; my($name) = $2; my($nicename) = $2; @@ -274,7 +275,7 @@ foreach my $machine (@rrddirlist) { push @data, "AREA:$1-$2:rx:rx#00FF00:OK:received bytes "; push @data, "LINE2:$1-$2:tx:tx#0000FF:OK:transfered bytes"; push @rawdata, "--base=1024"; - # some name tidting + # some name tidying my($type) = $1; my($name) = $2; my($nicename) = $2; @@ -283,6 +284,10 @@ foreach my $machine (@rrddirlist) { $nicename =~ s/$hex_bslash/\\/g; $nicename =~ s/$hex_space/ /g; $nicename =~ s/$hex_colon/:/g; + $nicename =~ s/$hex_lbracket/(/g; + $nicename =~ s/$hex_rbracket/)/g; + $nicename =~ s/$hex_plus/+/g; + $nicename =~ s/$hex_hash/#/g; &makegraph($machine, "$type-$name", "Network IO for $machine on $nicename", "bytes per second", \@data, \@rawdata); } if($rrd =~ /^(mailq)-(\S+)\.rrd$/) {