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.3 by tdb, Sun Mar 10 03:19:57 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";
54 >            push @data, "LINE2:$1:idle:idle#00FF00:idle cpu";
55 >            push @data, "LINE2:$1:user:user#0000FF:user cpu";
56 >            push @data, "LINE2:$1:kernel:kernel#00FFFF:kernel cpu";
57 >            push @data, "LINE2:$1:swap:swap#FF00FF:swap cpu";
58 >            push @data, "LINE2:$1:iowait:iowait#FF0000:iowait cpu";
59              &makegraph($machine, $1, "CPU Usage for $machine", \@data);
60          }
61          if($rrd =~ /^(mem)\.rrd$/) {
62              my(@data);
63 <            push @data, "LINE2:$1:free#00FF00:free memory";
64 <            push @data, "LINE2:$1:total#0000FF:total memory";
63 >            push @data, "LINE2:$1:free:free#00FF00:free memory";
64 >            push @data, "LINE2:$1:total:total#0000FF:total memory";
65              &makegraph($machine, $1, "Memory Usage for $machine", \@data);
66          }
67          if($rrd =~ /^(load)\.rrd$/) {
68              my(@data);
69 <            push @data, "LINE2:$1:load1#00FF00:1 minute load average";
70 <            push @data, "LINE2:$1:load5#0000FF:5 minute load average";
71 <            push @data, "LINE2:$1:load15#FF0000:15 minute load average";
69 >            push @data, "LINE2:$1:load1:load1#00FF00:1 minute load average";
70 >            push @data, "LINE2:$1:load5:load5#0000FF:5 minute load average";
71 >            push @data, "LINE2:$1:load15:load15#FF0000:15 minute load average";
72              &makegraph($machine, $1, "Loads for $machine", \@data);
73          }
74          if($rrd =~ /^(proc)\.rrd$/) {
75              my(@data);
76 <            push @data, "LINE2:$1:cpu#00FF00:cpu processes";
77 <            push @data, "LINE2:$1:sleeping#0000FF:sleeping processes";
78 <            push @data, "LINE2:$1:stopped#00FFFF:stopped processes";
79 <            push @data, "LINE2:$1:total#FF00FF:total processes";
80 <            push @data, "LINE2:$1:zombie#FF0000:zombie processes";
76 >            push @data, "LINE2:$1:cpu:cpu#00FF00:cpu processes";
77 >            push @data, "LINE2:$1:sleeping:sleeping#0000FF:sleeping processes";
78 >            push @data, "LINE2:$1:stopped:stopped#00FFFF:stopped processes";
79 >            push @data, "LINE2:$1:total:total#FF00FF:total processes";
80 >            push @data, "LINE2:$1:zombie:zombie#FF0000:zombie processes";
81              &makegraph($machine, $1, "Processes on $machine", \@data);
82          }
83          if($rrd =~ /^(swap)\.rrd$/) {
84              my(@data);
85 <            push @data, "LINE2:$1:free#00FF00:free swap";
86 <            push @data, "LINE2:$1:total#0000FF:total swap";
85 >            push @data, "LINE2:$1:free:free#00FF00:free swap";
86 >            push @data, "LINE2:$1:total:total#0000FF:total swap";
87              &makegraph($machine, $1, "Swap Usage for $machine", \@data);
88          }
89          if($rrd =~ /^(users)\.rrd$/) {
90              my(@data);
91 <            push @data, "LINE2:$1:count#00FF00:user count";
91 >            push @data, "LINE2:$1:count:count#00FF00:user count";
92              &makegraph($machine, $1, "User Count for $machine", \@data);
93          }
94          if($rrd =~ /^(disk)-(\S+).rrd$/) {
95              my(@data);
96 <            push @data, "LINE2:$1-$2:kbytes#0000FF:total size";
97 <            push @data, "LINE2:$1-$2:used#00FF00:used";
96 >            push @data, "LINE2:$1-$2:kbytes:kbytes#0000FF:total size";
97 >            push @data, "LINE2:$1-$2:used:used#00FF00:used";
98              my($type) = $1;
99              my($name) = $2;
100              my($nicename) = $2;
# Line 109 | Line 109 | foreach my $machine (@rrddirlist) {
109              my($baserrd) = $1;
110              my($i) = 0;
111              while( -f "$rrddir/$machine/$baserrd\_$i.rrd" ) {
112 <                push @data, "LINE2:$baserrd\_$i:size" . &get_colour($i) . ":queue$i size ";
112 >                push @data, "LINE2:$baserrd\_$i:size:size$i" . &get_colour($i) . ":queue$i size ";
113                  ++$i;
114              }
115 <            push @data, "LINE2:$baserrd\_0:total#FF0000:packets/sec - currently";
116 <            push @rawdata, "GPRINT:total:LAST:\"%lf %spackets/sec\"";
115 >            push @data, "LINE2:$baserrd\_0:total:total#FF0000:packets/sec - currently";
116 >            push @rawdata, "GPRINT:total:LAST:%lf %spackets/sec";
117              my($comment);
118              if(-f "$rrddir/$machine/$baserrd.def") {
119                  open(DEF, "$rrddir/$machine/$baserrd.def");
# Line 136 | Line 136 | foreach my $machine (@rrddirlist) {
136   # $title     = the title for the graph
137   #              (eg. kernow CPU usage)
138   # $dataref   = a reference to an array containing information for the graph
139 < #              elements of format: "gtype:rrdname:name#colour:comment with spaces"
139 > #              elements of format: "gtype:rrdname:dsname:name#colour:comment with spaces"
140   # $rawcmdref = a reference to an array containing raw rrd commands
141   #              elements a single command each, no spaces
142   #
143 +
144   sub makegraph() {
145      my($machine, $type, $title, $dataref, $rawcmdref) = @_;
146      # pass in these arrays by reference
# Line 152 | Line 153 | sub makegraph() {
153      }
154      my(@rrdcmd);
155      foreach my $dataitem (@data) {
156 <        # dataitem should be: "gtype:rrdname:name#colour:comment with spaces"
157 <        if($dataitem =~ /^(\S+):(\S+):(\S+)#(.{6}):(.*)$/) {
158 <            push @rrdcmd, "DEF:$3=$rrddir/$machine/$2.rrd:$3:MAX";
159 <            push @rrdcmd, "$1:$3#$4:$5";
156 >        # dataitem should be: "gtype:rrdname:dsname:name#colour:comment with spaces"
157 >        if($dataitem =~ /^(\S+):(\S+):(\S+):(\S+)#(.{6}):(.*)$/) {
158 >            push @rrdcmd, "DEF:$4=$rrddir/$machine/$2.rrd:$3:MAX";
159 >            push @rrdcmd, "$1:$4#$5:$6";
160          }
161      }
162      push @rrdcmd, "--title=$title";
# Line 165 | Line 166 | sub makegraph() {
166      push @rrdcmd, @rawcmd;
167      RRDs::graph ("$imgdir/$machine/$type-3h.png", "--start=-10800", @rrdcmd);
168      my($err_3h) = RRDs::error;
169 <    print STDERR "Error generating 3h graph for $machine\_$type: $err_3h\n" if $err_3h;
169 >    print STDERR "Error generating 3h graph for $machine/$type: $err_3h\n" if $err_3h;
170      RRDs::graph ("$imgdir/$machine/$type-1d.png", "--start=-86400", @rrdcmd);
171      my($err_1d) = RRDs::error;
172 <    print STDERR "Error generating 1d graph for $machine\_$type: $err_1d\n" if $err_1d;
172 >    print STDERR "Error generating 1d graph for $machine/$type: $err_1d\n" if $err_1d;
173      RRDs::graph ("$imgdir/$machine/$type-1w.png", "--start=-604800", @rrdcmd);
174      my($err_1w) = RRDs::error;
175 <    print STDERR "Error generating 1w graph for $machine\_$type: $err_1w\n" if $err_1w;
175 >    print STDERR "Error generating 1w graph for $machine/$type: $err_1w\n" if $err_1w;
176      RRDs::graph ("$imgdir/$machine/$type-1m.png", "--start=-2678400", @rrdcmd);
177      my($err_1m) = RRDs::error;
178 <    print STDERR "Error generating 1m graph for $machine\_$type: $err_1m\n" if $err_1m;
178 >    print STDERR "Error generating 1m graph for $machine/$type: $err_1m\n" if $err_1m;
179      return;
180   }
181  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines