--- projects/cms/source/reports/rrdgraphing/graph.pl 2003/03/10 11:34:43 1.12 +++ projects/cms/source/reports/rrdgraphing/graph.pl 2004/03/04 11:27:30 1.13 @@ -27,7 +27,7 @@ # Generates graphs from rrd databases for i-scream data. # # $Author: tdb $ -# $Id: graph.pl,v 1.12 2003/03/10 11:34:43 tdb Exp $ +# $Id: graph.pl,v 1.13 2004/03/04 11:27:30 tdb Exp $ #------------------------------------------------------------ ## TODO @@ -35,8 +35,12 @@ # -- allow configurable periods of graphs # -- comments, types, etc -my($version) = '$Id: graph.pl,v 1.12 2003/03/10 11:34:43 tdb Exp $'; +BEGIN { + push (@INC, "/usr/local/packages/rrdtool/lib/perl5/site_perl/5.8.2/sun4-solaris"); +} +my($version) = '$Id: graph.pl,v 1.13 2004/03/04 11:27:30 tdb Exp $'; + $| = 1; use strict; @@ -101,10 +105,10 @@ if($opts{q}) { # Read the contents of the base directory # and pull out the list of subdirectories (except . and .. :) opendir(DIR, $rrddir); -my(@rrddirlist) = grep { -d "$rrddir/$_" && !/^\.$/ && !/^\.\.$/ } readdir(DIR); +my(@rrddirlist) = sort grep { -d "$rrddir/$_" && !/^\.$/ && !/^\.\.$/ } readdir(DIR); closedir DIR; -# look through each directoty, as they might +# look through each directory, as they might # contain rrds for a particular machine foreach my $machine (@rrddirlist) { # Read the contents of the directory @@ -135,11 +139,11 @@ foreach my $machine (@rrddirlist) { if($rrd =~ /^(cpu)\.rrd$/) { my(@data); my(@rawdata); - push @data, "LINE2:$1:idle:idle#00FF00:OK:idle cpu "; - push @data, "LINE2:$1:user:user#0000FF:OK:user cpu "; - push @data, "LINE2:$1:kernel:kernel#00FFFF:OK:kernel cpu"; - push @data, "LINE2:$1:swap:swap#FF00FF:OK:swap cpu "; - push @data, "LINE2:$1:iowait:iowait#FF0000:OK:iowait cpu"; + push @data, "AREA:$1:swap:swap#FF00FF:OK:swap cpu "; + push @data, "STACK:$1:iowait:iowait#FF0000:OK:iowait cpu"; + push @data, "STACK:$1:kernel:kernel#00FFFF:OK:kernel cpu"; + push @data, "STACK:$1:user:user#0000FF:OK:user cpu "; + #push @data, "STACK:$1:idle:idle#00FF00:OK:idle cpu "; push @rawdata, "--upper-limit=100"; &makegraph($machine, $1, "CPU Usage for $machine", "% cpu time", \@data, \@rawdata); } @@ -150,15 +154,18 @@ foreach my $machine (@rrddirlist) { # although we need it to work out peruse... 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,*"; # and add it to the graph push @rawdata, "AREA:peruse#CCCCFF:% memory in use"; + &addlegend(\@rawdata, "peruse"); + push @rawdata, "LINE2:percacuse#0000FF:% memory cache "; + &addlegend(\@rawdata, "percacuse"); push @rawdata, "--upper-limit=100"; push @rawdata, "--base=1024"; - # add some nice values to the legend - &addlegend(\@rawdata, "peruse"); # put the total memory on the graph so we can map percentages to real values push @rawdata, "GPRINT:total:LAST:Current total memory\\: \%.2lf %sb\\c"; &makegraph($machine, $1, "Memory Usage for $machine", "% memory in use", \@data, \@rawdata); @@ -172,11 +179,11 @@ foreach my $machine (@rrddirlist) { } if($rrd =~ /^(proc)\.rrd$/) { my(@data); - push @data, "LINE2:$1:cpu:cpu#00FF00:OK:cpu processes "; - push @data, "LINE2:$1:sleeping:sleeping#0000FF:OK:sleeping processes"; - push @data, "LINE2:$1:stopped:stopped#00FFFF:OK:stopped processes "; - push @data, "LINE2:$1:total:total#FF00FF:OK:total processes "; - push @data, "LINE2:$1:zombie:zombie#FF0000:OK:zombie processes "; + push @data, "AREA:$1:stopped:stopped#00FFFF:OK:stopped processes "; + push @data, "STACK:$1:zombie:zombie#FF0000:OK:zombie processes "; + push @data, "STACK:$1:cpu:cpu#00FF00:OK:cpu processes "; + push @data, "STACK:$1:sleeping:sleeping#0000FF:OK:sleeping processes"; + #push @data, "LINE2:$1:total:total#FF00FF:OK:total processes "; &makegraph($machine, $1, "Processes on $machine", "no. of processes", \@data); } if($rrd =~ /^(swap)\.rrd$/) { @@ -206,7 +213,7 @@ foreach my $machine (@rrddirlist) { } if($rrd =~ /^(paging)\.rrd$/) { my(@data); - push @data, "LINE2:$1:pageins:pageins#00FF00:OK:pages paged in "; + push @data, "AREA:$1:pageins:pageins#00FF00:OK:pages paged in "; push @data, "LINE2:$1:pageouts:pageouts#0000FF:OK:pages paged out"; &makegraph($machine, $1, "Paging on $machine", "pages per second", \@data); } @@ -243,7 +250,7 @@ foreach my $machine (@rrddirlist) { if($rrd =~ /^(diskio)-(\S+)\.rrd$/) { my(@data); my(@rawdata); - push @data, "LINE2:$1-$2:rbytes:rbytes#00FF00:OK:read bytes "; + 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"; &makegraph($machine, "$1-$2", "Disk IO for $machine on $2", "bytes per second", \@data, \@rawdata); @@ -251,11 +258,17 @@ foreach my $machine (@rrddirlist) { if($rrd =~ /^(net)-(\S+)\.rrd$/) { my(@data); my(@rawdata); - push @data, "LINE2:$1-$2:rx:rx#00FF00:OK:received bytes "; + 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"; &makegraph($machine, "$1-$2", "Network IO for $machine on $2", "bytes per second", \@data, \@rawdata); } + if($rrd =~ /^(mailq)-(\S+)\.rrd$/) { + my(@data); + my(@rawdata); + push @data, "LINE2:$1-$2:size:size#0000FF:OK:messages"; + &makegraph($machine, "$1-$2", "Mail Queue ($2) Size for $machine", "messages in queue", \@data, \@rawdata); + } # probably a queue with a name like this :) if($rrd =~ /^(\d+)_0\.rrd$/) { my(@data); @@ -295,7 +308,7 @@ if($deleteimgs) { # Read the contents of the graphs directory # and pull out the list of subdirectories (except . and .. :) opendir(DIR, $imgdir); - my(@imgdirlist) = grep { -d "$imgdir/$_" && !/^\.$/ && !/^\.\.$/ } readdir(DIR); + my(@imgdirlist) = sort grep { -d "$imgdir/$_" && !/^\.$/ && !/^\.\.$/ } readdir(DIR); closedir DIR; # look through each directoty, as they might