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.5 by tdb, Mon Mar 11 00:25:35 2002 UTC

# Line 11 | Line 11
11   #------------------------------------------------------------
12  
13   ## TODO
14 + # allow specification of lower/upper graph bounds
15 + #  -- then replace mem/swap/disk "total" line ;)
16 + # fix mem/swap issues
17 + #  -- should be graphing "in use", not "free"
18   # possibly make more configurable?
19   #  -- allow configurable periods of graphs
20   #  -- comments, types, etc
# Line 51 | Line 55 | foreach my $machine (@rrddirlist) {
55          chomp $rrd;
56          if($rrd =~ /^(cpu)\.rrd$/) {
57              my(@data);
58 <            push @data, "LINE2:$1:idle#00FF00:idle cpu";
59 <            push @data, "LINE2:$1:user#0000FF:user cpu";
60 <            push @data, "LINE2:$1:kernel#00FFFF:kernel cpu";
61 <            push @data, "LINE2:$1:swap#FF00FF:swap cpu";
62 <            push @data, "LINE2:$1:iowait#FF0000:iowait cpu";
63 <            &makegraph($machine, $1, "CPU Usage for $machine", \@data);
58 >            my(@rawdata);
59 >            push @data, "LINE2:$1:idle:idle#00FF00:idle cpu";
60 >            push @data, "LINE2:$1:user:user#0000FF:user cpu";
61 >            push @data, "LINE2:$1:kernel:kernel#00FFFF:kernel cpu";
62 >            push @data, "LINE2:$1:swap:swap#FF00FF:swap cpu";
63 >            push @data, "LINE2:$1:iowait:iowait#FF0000:iowait cpu";
64 >            push @rawdata, "--upper-limit=100";
65 >            &makegraph($machine, $1, "CPU Usage for $machine", \@data, \@rawdata);
66          }
67          if($rrd =~ /^(mem)\.rrd$/) {
68              my(@data);
69 <            push @data, "LINE2:$1:free#00FF00:free memory";
70 <            push @data, "LINE2:$1:total#0000FF:total memory";
71 <            &makegraph($machine, $1, "Memory Usage for $machine", \@data);
69 >            my(@rawdata);
70 >            push @data, "AREA:$1:free:free#CCCCFF:free memory";
71 >            push @data, "LINE2:$1:total:total#0000FF:total memory";
72 >            push @rawdata, "--base=1024";
73 >            &makegraph($machine, $1, "Memory Usage for $machine", \@data, \@rawdata);
74          }
75          if($rrd =~ /^(load)\.rrd$/) {
76              my(@data);
77 <            push @data, "LINE2:$1:load1#00FF00:1 minute load average";
78 <            push @data, "LINE2:$1:load5#0000FF:5 minute load average";
79 <            push @data, "LINE2:$1:load15#FF0000:15 minute load average";
77 >            push @data, "LINE2:$1:load1:load1#CCCCFF:1 minute load average";
78 >            push @data, "LINE2:$1:load5:load5#7777FF:5 minute load average";
79 >            push @data, "LINE2:$1:load15:load15#0000FF:15 minute load average";
80              &makegraph($machine, $1, "Loads for $machine", \@data);
81          }
82          if($rrd =~ /^(proc)\.rrd$/) {
83              my(@data);
84 <            push @data, "LINE2:$1:cpu#00FF00:cpu processes";
85 <            push @data, "LINE2:$1:sleeping#0000FF:sleeping processes";
86 <            push @data, "LINE2:$1:stopped#00FFFF:stopped processes";
87 <            push @data, "LINE2:$1:total#FF00FF:total processes";
88 <            push @data, "LINE2:$1:zombie#FF0000:zombie processes";
84 >            push @data, "LINE2:$1:cpu:cpu#00FF00:cpu processes";
85 >            push @data, "LINE2:$1:sleeping:sleeping#0000FF:sleeping processes";
86 >            push @data, "LINE2:$1:stopped:stopped#00FFFF:stopped processes";
87 >            push @data, "LINE2:$1:total:total#FF00FF:total processes";
88 >            push @data, "LINE2:$1:zombie:zombie#FF0000:zombie processes";
89              &makegraph($machine, $1, "Processes on $machine", \@data);
90          }
91          if($rrd =~ /^(swap)\.rrd$/) {
92              my(@data);
93 <            push @data, "LINE2:$1:free#00FF00:free swap";
94 <            push @data, "LINE2:$1:total#0000FF:total swap";
95 <            &makegraph($machine, $1, "Swap Usage for $machine", \@data);
93 >            my(@rawdata);
94 >            push @data, "AREA:$1:free:free#CCCCFF:free swap";
95 >            push @data, "LINE2:$1:total:total#0000FF:total swap";
96 >            push @rawdata, "--base=1024";
97 >            &makegraph($machine, $1, "Swap Usage for $machine", \@data, \@rawdata);
98          }
99          if($rrd =~ /^(users)\.rrd$/) {
100              my(@data);
101 <            push @data, "LINE2:$1:count#00FF00:user count";
101 >            push @data, "AREA:$1:count:count#CCCCFF:user count";
102              &makegraph($machine, $1, "User Count for $machine", \@data);
103          }
104          if($rrd =~ /^(disk)-(\S+).rrd$/) {
105              my(@data);
106 <            push @data, "LINE2:$1-$2:kbytes#0000FF:total size";
107 <            push @data, "LINE2:$1-$2:used#00FF00:used";
106 >            my(@rawdata);
107 >            push @data, "LINE2:$1-$2:kbytes:kbytes#0000FF:total size";
108 >            push @data, "AREA:$1-$2:used:used#CCCCFF:used";
109 >            push @rawdata, "--base=1024";
110              my($type) = $1;
111              my($name) = $2;
112              my($nicename) = $2;
113              $nicename =~ s/$hex_slash/\//g;
114              $nicename =~ s/$hex_underscore/_/g;
115 <            &makegraph($machine, "$type-$name", "Disk Usage for $machine on $nicename", \@data);
115 >            &makegraph($machine, "$type-$name", "Disk Usage for $machine on $nicename", \@data, \@rawdata);
116          }
117          # probably a queue with a name like this :)
118          if($rrd =~ /^(\d+)_0\.rrd$/) {
# Line 109 | Line 121 | foreach my $machine (@rrddirlist) {
121              my($baserrd) = $1;
122              my($i) = 0;
123              while( -f "$rrddir/$machine/$baserrd\_$i.rrd" ) {
124 <                push @data, "LINE2:$baserrd\_$i:size" . &get_colour($i) . ":queue$i size ";
124 >                push @data, "LINE2:$baserrd\_$i:size:size$i" . &get_colour($i) . ":queue$i size ";
125                  ++$i;
126              }
127 <            push @data, "LINE2:$baserrd\_0:total#FF0000:packets/sec - currently";
128 <            push @rawdata, "GPRINT:total:LAST:\"%lf %spackets/sec\"";
127 >            push @data, "LINE2:$baserrd\_0:total:total#FF0000:packets/sec - currently";
128 >            push @rawdata, "GPRINT:total:LAST:%lf %spackets/sec";
129              my($comment);
130              if(-f "$rrddir/$machine/$baserrd.def") {
131                  open(DEF, "$rrddir/$machine/$baserrd.def");
# Line 136 | Line 148 | foreach my $machine (@rrddirlist) {
148   # $title     = the title for the graph
149   #              (eg. kernow CPU usage)
150   # $dataref   = a reference to an array containing information for the graph
151 < #              elements of format: "gtype:rrdname:name#colour:comment with spaces"
151 > #              elements of format: "gtype:rrdname:dsname:name#colour:comment with spaces"
152   # $rawcmdref = a reference to an array containing raw rrd commands
153   #              elements a single command each, no spaces
154   #
155 +
156   sub makegraph() {
157      my($machine, $type, $title, $dataref, $rawcmdref) = @_;
158      # pass in these arrays by reference
# Line 152 | Line 165 | sub makegraph() {
165      }
166      my(@rrdcmd);
167      foreach my $dataitem (@data) {
168 <        # dataitem should be: "gtype:rrdname:name#colour:comment with spaces"
169 <        if($dataitem =~ /^(\S+):(\S+):(\S+)#(.{6}):(.*)$/) {
170 <            push @rrdcmd, "DEF:$3=$rrddir/$machine/$2.rrd:$3:MAX";
171 <            push @rrdcmd, "$1:$3#$4:$5";
168 >        # dataitem should be: "gtype:rrdname:dsname:name#colour:comment with spaces"
169 >        if($dataitem =~ /^(\S+):(\S+):(\S+):(\S+)#(.{6}):(.*)$/) {
170 >            push @rrdcmd, "DEF:$4=$rrddir/$machine/$2.rrd:$3:MAX";
171 >            push @rrdcmd, "$1:$4#$5:$6";
172          }
173      }
174      push @rrdcmd, "--title=$title";
175      push @rrdcmd, "--imgformat=PNG";
176      push @rrdcmd, "--lower-limit=0";
177 +    # not entirely convinced this is good...
178 +    push @rrdcmd, "--alt-autoscale-max";
179      # add any further raw commands
180      push @rrdcmd, @rawcmd;
181      RRDs::graph ("$imgdir/$machine/$type-3h.png", "--start=-10800", @rrdcmd);
182      my($err_3h) = RRDs::error;
183 <    print STDERR "Error generating 3h graph for $machine\_$type: $err_3h\n" if $err_3h;
183 >    print STDERR "Error generating 3h graph for $machine/$type: $err_3h\n" if $err_3h;
184      RRDs::graph ("$imgdir/$machine/$type-1d.png", "--start=-86400", @rrdcmd);
185      my($err_1d) = RRDs::error;
186 <    print STDERR "Error generating 1d graph for $machine\_$type: $err_1d\n" if $err_1d;
186 >    print STDERR "Error generating 1d graph for $machine/$type: $err_1d\n" if $err_1d;
187      RRDs::graph ("$imgdir/$machine/$type-1w.png", "--start=-604800", @rrdcmd);
188      my($err_1w) = RRDs::error;
189 <    print STDERR "Error generating 1w graph for $machine\_$type: $err_1w\n" if $err_1w;
189 >    print STDERR "Error generating 1w graph for $machine/$type: $err_1w\n" if $err_1w;
190      RRDs::graph ("$imgdir/$machine/$type-1m.png", "--start=-2678400", @rrdcmd);
191      my($err_1m) = RRDs::error;
192 <    print STDERR "Error generating 1m graph for $machine\_$type: $err_1m\n" if $err_1m;
192 >    print STDERR "Error generating 1m graph for $machine/$type: $err_1m\n" if $err_1m;
193      return;
194   }
195  

Diff Legend

Removed lines
+ Added lines
< Changed lines
> Changed lines