--- projects/cms/source/reports/rrdgraphing/graph.pl 2002/10/13 02:27:39 1.9 +++ projects/cms/source/reports/rrdgraphing/graph.pl 2002/10/13 15:14:00 1.10 @@ -26,7 +26,7 @@ # Generates graphs from rrd databases for i-scream data. # # $Author: tdb $ -# $Id: graph.pl,v 1.9 2002/10/13 02:27:39 tdb Exp $ +# $Id: graph.pl,v 1.10 2002/10/13 15:14:00 tdb Exp $ #------------------------------------------------------------ ## TODO @@ -34,7 +34,7 @@ # -- allow configurable periods of graphs # -- comments, types, etc -my($version) = '$Id: graph.pl,v 1.9 2002/10/13 02:27:39 tdb Exp $'; +my($version) = '$Id: graph.pl,v 1.10 2002/10/13 15:14:00 tdb Exp $'; $| = 1; @@ -140,7 +140,7 @@ foreach my $machine (@rrddirlist) { push @data, "LINE2:$1:swap:swap#FF00FF:OK:swap cpu "; push @data, "LINE2:$1:iowait:iowait#FF0000:OK:iowait cpu"; push @rawdata, "--upper-limit=100"; - &makegraph($machine, $1, "CPU Usage for $machine", \@data, \@rawdata); + &makegraph($machine, $1, "CPU Usage for $machine", "% cpu time", \@data, \@rawdata); } if($rrd =~ /^(mem)\.rrd$/) { my(@data); @@ -156,14 +156,14 @@ foreach my $machine (@rrddirlist) { push @rawdata, "--base=1024"; # add some nice values to the legend &addlegend(\@rawdata, "inuse"); - &makegraph($machine, $1, "Memory Usage for $machine", \@data, \@rawdata); + &makegraph($machine, $1, "Memory Usage for $machine", "megabytes", \@data, \@rawdata); } if($rrd =~ /^(load)\.rrd$/) { my(@data); push @data, "LINE2:$1:load1:load1#CCCCFF:OK: 1 min load average"; push @data, "LINE2:$1:load5:load5#7777FF:OK: 5 min load average"; push @data, "LINE2:$1:load15:load15#0000FF:OK:15 min load average"; - &makegraph($machine, $1, "Loads for $machine", \@data); + &makegraph($machine, $1, "Loads for $machine", "load average", \@data); } if($rrd =~ /^(proc)\.rrd$/) { my(@data); @@ -172,7 +172,7 @@ foreach my $machine (@rrddirlist) { 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 "; - &makegraph($machine, $1, "Processes on $machine", \@data); + &makegraph($machine, $1, "Processes on $machine", "no. of processes", \@data); } if($rrd =~ /^(swap)\.rrd$/) { my(@data); @@ -188,12 +188,12 @@ foreach my $machine (@rrddirlist) { push @rawdata, "--base=1024"; # add some nice values to the legend &addlegend(\@rawdata, "inuse"); - &makegraph($machine, $1, "Swap Usage for $machine", \@data, \@rawdata); + &makegraph($machine, $1, "Swap Usage for $machine", "megabytes", \@data, \@rawdata); } if($rrd =~ /^(users)\.rrd$/) { my(@data); push @data, "AREA:$1:count:count#CCCCFF:OK:user count"; - &makegraph($machine, $1, "User Count for $machine", \@data); + &makegraph($machine, $1, "User Count for $machine", "no. of users", \@data); } if($rrd =~ /^(disk)-(\S+).rrd$/) { my(@data); @@ -206,7 +206,7 @@ foreach my $machine (@rrddirlist) { my($nicename) = $2; $nicename =~ s/$hex_slash/\//g; $nicename =~ s/$hex_underscore/_/g; - &makegraph($machine, "$type-$name", "Disk Usage for $machine on $nicename", \@data, \@rawdata); + &makegraph($machine, "$type-$name", "Disk Usage for $machine on $nicename", "kilobytes", \@data, \@rawdata); } # probably a queue with a name like this :) if($rrd =~ /^(\d+)_0\.rrd$/) { @@ -226,7 +226,7 @@ foreach my $machine (@rrddirlist) { chomp $comment if defined $comment; } $comment = "unknown queue" if not defined $comment; - &makegraph($machine, $baserrd, $comment, \@data, \@rawdata); + &makegraph($machine, $baserrd, $comment, "", \@data, \@rawdata); } } # have a last check, maybe we can remove the directory now? @@ -295,6 +295,8 @@ exit(0); # (eg. cpu) # $title = the title for the graph # (eg. kernow CPU usage) +# $vlabel = the vertical label to apply to the left side of the graph +# (eg. kb/s) # $dataref = a reference to an array containing information for the graph # elements of format: "gtype:rrdname:dsname:name#colour:legend:comment with spaces" # (if gtype is "NONE" only a DEF of 'name' will be defined, no line will be plotted) @@ -304,7 +306,7 @@ exit(0); # sub makegraph() { - my($machine, $type, $title, $dataref, $rawcmdref) = @_; + my($machine, $type, $title, $vlabel, $dataref, $rawcmdref) = @_; # pass in these arrays by reference my(@data) = @$dataref if defined $dataref; my(@rawcmd) = @$rawcmdref if defined $rawcmdref; @@ -333,6 +335,7 @@ sub makegraph() { push @rrdcmd, "--title=$title"; push @rrdcmd, "--imgformat=PNG"; push @rrdcmd, "--lower-limit=0"; + push @rrdcmd, "--vertical-label=$vlabel"; # not entirely convinced this is good... push @rrdcmd, "--alt-autoscale-max"; # add any further raw commands