ViewVC Help
View File | Revision Log | Show Annotations | Revision Graph | Root Listing
root/i-scream/experimental/reports/graphing/graph.pl
(Generate patch)

Comparing experimental/reports/graphing/graph.pl (file contents):
Revision 1.1 by tdb, Sat Mar 9 19:53:24 2002 UTC vs.
Revision 1.7 by tdb, Wed Mar 13 20:50:48 2002 UTC

# Line 51 | Line 51 | foreach my $machine (@rrddirlist) {
51          chomp $rrd;
52          if($rrd =~ /^(cpu)\.rrd$/) {
53              my(@data);
54 <            push @data, "LINE2:$1:idle#00FF00:idle cpu";
55 <            push @data, "LINE2:$1:user#0000FF:user cpu";
56 <            push @data, "LINE2:$1:kernel#00FFFF:kernel cpu";
57 <            push @data, "LINE2:$1:swap#FF00FF:swap cpu";
58 <            push @data, "LINE2:$1:iowait#FF0000:iowait cpu";
59 <            &makegraph($machine, $1, "CPU Usage for $machine", \@data);
54 >            my(@rawdata);
55 >            push @data, "LINE2:$1:idle:idle#00FF00:idle cpu";
56 >            push @data, "LINE2:$1:user:user#0000FF:user cpu";
57 >            push @data, "LINE2:$1:kernel:kernel#00FFFF:kernel cpu";
58 >            push @data, "LINE2:$1:swap:swap#FF00FF:swap cpu";
59 >            push @data, "LINE2:$1:iowait:iowait#FF0000:iowait cpu";
60 >            push @rawdata, "--upper-limit=100";
61 >            &makegraph($machine, $1, "CPU Usage for $machine", \@data, \@rawdata);
62          }
63          if($rrd =~ /^(mem)\.rrd$/) {
64              my(@data);
65 <            push @data, "LINE2:$1:free#00FF00:free memory";
66 <            push @data, "LINE2:$1:total#0000FF:total memory";
67 <            &makegraph($machine, $1, "Memory Usage for $machine", \@data);
65 >            my(@rawdata);
66 >            # we don't actually want to display free memory,
67 >            # although we need it to do inuse...
68 >            push @data, "NONE:$1:free:free#CCCCFF:free memory";
69 >            push @data, "LINE2:$1:total:total#0000FF:total memory";
70 >            # calculate inuse
71 >            push @rawdata, "CDEF:inuse=total,free,-";
72 >            # and add it to the graph
73 >            push @rawdata, "AREA:inuse#CCCCFF:memory in use";
74 >            push @rawdata, "--base=1024";
75 >            &makegraph($machine, $1, "Memory Usage for $machine", \@data, \@rawdata);
76          }
77          if($rrd =~ /^(load)\.rrd$/) {
78              my(@data);
79 <            push @data, "LINE2:$1:load1#00FF00:1 minute load average";
80 <            push @data, "LINE2:$1:load5#0000FF:5 minute load average";
81 <            push @data, "LINE2:$1:load15#FF0000:15 minute load average";
79 >            push @data, "LINE2:$1:load1:load1#CCCCFF:1 minute load average";
80 >            push @data, "LINE2:$1:load5:load5#7777FF:5 minute load average";
81 >            push @data, "LINE2:$1:load15:load15#0000FF:15 minute load average";
82              &makegraph($machine, $1, "Loads for $machine", \@data);
83          }
84          if($rrd =~ /^(proc)\.rrd$/) {
85              my(@data);
86 <            push @data, "LINE2:$1:cpu#00FF00:cpu processes";
87 <            push @data, "LINE2:$1:sleeping#0000FF:sleeping processes";
88 <            push @data, "LINE2:$1:stopped#00FFFF:stopped processes";
89 <            push @data, "LINE2:$1:total#FF00FF:total processes";
90 <            push @data, "LINE2:$1:zombie#FF0000:zombie processes";
86 >            push @data, "LINE2:$1:cpu:cpu#00FF00:cpu processes";
87 >            push @data, "LINE2:$1:sleeping:sleeping#0000FF:sleeping processes";
88 >            push @data, "LINE2:$1:stopped:stopped#00FFFF:stopped processes";
89 >            push @data, "LINE2:$1:total:total#FF00FF:total processes";
90 >            push @data, "LINE2:$1:zombie:zombie#FF0000:zombie processes";
91              &makegraph($machine, $1, "Processes on $machine", \@data);
92          }
93          if($rrd =~ /^(swap)\.rrd$/) {
94              my(@data);
95 <            push @data, "LINE2:$1:free#00FF00:free swap";
96 <            push @data, "LINE2:$1:total#0000FF:total swap";
97 <            &makegraph($machine, $1, "Swap Usage for $machine", \@data);
95 >            my(@rawdata);
96 >            # we don't actually want to display free swap,
97 >            # although we need it to do inuse...
98 >            push @data, "NONE:$1:free:free#CCCCFF:free swap";
99 >            push @data, "LINE2:$1:total:total#0000FF:total swap";
100 >            # calculate inuse
101 >            push @rawdata, "CDEF:inuse=total,free,-";
102 >            # and add it to the graph
103 >            push @rawdata, "AREA:inuse#CCCCFF:swap in use";
104 >            push @rawdata, "--base=1024";
105 >            &makegraph($machine, $1, "Swap Usage for $machine", \@data, \@rawdata);
106          }
107          if($rrd =~ /^(users)\.rrd$/) {
108              my(@data);
109 <            push @data, "LINE2:$1:count#00FF00:user count";
109 >            push @data, "AREA:$1:count:count#CCCCFF:user count";
110              &makegraph($machine, $1, "User Count for $machine", \@data);
111          }
112          if($rrd =~ /^(disk)-(\S+).rrd$/) {
113              my(@data);
114 <            push @data, "LINE2:$1-$2:kbytes#0000FF:total size";
115 <            push @data, "LINE2:$1-$2:used#00FF00:used";
114 >            my(@rawdata);
115 >            push @data, "LINE2:$1-$2:kbytes:kbytes#0000FF:total size";
116 >            push @data, "AREA:$1-$2:used:used#CCCCFF:used";
117 >            push @rawdata, "--base=1024";
118              my($type) = $1;
119              my($name) = $2;
120              my($nicename) = $2;
121              $nicename =~ s/$hex_slash/\//g;
122              $nicename =~ s/$hex_underscore/_/g;
123 <            &makegraph($machine, "$type-$name", "Disk Usage for $machine on $nicename", \@data);
123 >            &makegraph($machine, "$type-$name", "Disk Usage for $machine on $nicename", \@data, \@rawdata);
124          }
125          # probably a queue with a name like this :)
126          if($rrd =~ /^(\d+)_0\.rrd$/) {
# Line 109 | Line 129 | foreach my $machine (@rrddirlist) {
129              my($baserrd) = $1;
130              my($i) = 0;
131              while( -f "$rrddir/$machine/$baserrd\_$i.rrd" ) {
132 <                push @data, "LINE2:$baserrd\_$i:size" . &get_colour($i) . ":queue$i size ";
132 >                push @data, "LINE2:$baserrd\_$i:size:size$i" . &get_colour($i) . ":queue$i size ";
133                  ++$i;
134              }
135 <            push @data, "LINE2:$baserrd\_0:total#FF0000:packets/sec - currently";
136 <            push @rawdata, "GPRINT:total:LAST:\"%lf %spackets/sec\"";
135 >            push @data, "LINE2:$baserrd\_0:total:total#FF0000:packets/sec - currently";
136 >            push @rawdata, "GPRINT:total:LAST:%lf %spackets/sec";
137              my($comment);
138              if(-f "$rrddir/$machine/$baserrd.def") {
139                  open(DEF, "$rrddir/$machine/$baserrd.def");
# Line 136 | Line 156 | foreach my $machine (@rrddirlist) {
156   # $title     = the title for the graph
157   #              (eg. kernow CPU usage)
158   # $dataref   = a reference to an array containing information for the graph
159 < #              elements of format: "gtype:rrdname:name#colour:comment with spaces"
159 > #              elements of format: "gtype:rrdname:dsname:name#colour:comment with spaces"
160 > #              (if gtype is "NONE" only a DEF of 'name' will be defined, no line will be plotted)
161   # $rawcmdref = a reference to an array containing raw rrd commands
162   #              elements a single command each, no spaces
163   #
164 +
165   sub makegraph() {
166      my($machine, $type, $title, $dataref, $rawcmdref) = @_;
167      # pass in these arrays by reference
# Line 152 | Line 174 | sub makegraph() {
174      }
175      my(@rrdcmd);
176      foreach my $dataitem (@data) {
177 <        # dataitem should be: "gtype:rrdname:name#colour:comment with spaces"
178 <        if($dataitem =~ /^(\S+):(\S+):(\S+)#(.{6}):(.*)$/) {
179 <            push @rrdcmd, "DEF:$3=$rrddir/$machine/$2.rrd:$3:MAX";
180 <            push @rrdcmd, "$1:$3#$4:$5";
177 >        # dataitem should be: "gtype:rrdname:dsname:name#colour:comment with spaces"
178 >        # (if gtype is "NONE" only a DEF of 'name' will be defined, no line will be plotted)
179 >        if($dataitem =~ /^(\S+):(\S+):(\S+):(\S+)#(.{6}):(.*)$/) {
180 >            push @rrdcmd, "DEF:$4=$rrddir/$machine/$2.rrd:$3:AVERAGE";
181 >            if($1 ne "NONE") {
182 >                push @rrdcmd, "$1:$4#$5:$6";
183 >            }
184          }
185      }
186      push @rrdcmd, "--title=$title";
187      push @rrdcmd, "--imgformat=PNG";
188      push @rrdcmd, "--lower-limit=0";
189 +    # not entirely convinced this is good...
190 +    push @rrdcmd, "--alt-autoscale-max";
191      # add any further raw commands
192      push @rrdcmd, @rawcmd;
193      RRDs::graph ("$imgdir/$machine/$type-3h.png", "--start=-10800", @rrdcmd);
194      my($err_3h) = RRDs::error;
195 <    print STDERR "Error generating 3h graph for $machine\_$type: $err_3h\n" if $err_3h;
195 >    print STDERR "Error generating 3h graph for $machine/$type: $err_3h\n" if $err_3h;
196      RRDs::graph ("$imgdir/$machine/$type-1d.png", "--start=-86400", @rrdcmd);
197      my($err_1d) = RRDs::error;
198 <    print STDERR "Error generating 1d graph for $machine\_$type: $err_1d\n" if $err_1d;
198 >    print STDERR "Error generating 1d graph for $machine/$type: $err_1d\n" if $err_1d;
199      RRDs::graph ("$imgdir/$machine/$type-1w.png", "--start=-604800", @rrdcmd);
200      my($err_1w) = RRDs::error;
201 <    print STDERR "Error generating 1w graph for $machine\_$type: $err_1w\n" if $err_1w;
201 >    print STDERR "Error generating 1w graph for $machine/$type: $err_1w\n" if $err_1w;
202      RRDs::graph ("$imgdir/$machine/$type-1m.png", "--start=-2678400", @rrdcmd);
203      my($err_1m) = RRDs::error;
204 <    print STDERR "Error generating 1m graph for $machine\_$type: $err_1m\n" if $err_1m;
204 >    print STDERR "Error generating 1m graph for $machine/$type: $err_1m\n" if $err_1m;
205 >    RRDs::graph ("$imgdir/$machine/$type-1y.png", "--start=-31536000", @rrdcmd);
206 >    my($err_1y) = RRDs::error;
207 >    print STDERR "Error generating 1y graph for $machine/$type: $err_1y\n" if $err_1y;
208      return;
209   }
210  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines