11 |
|
#------------------------------------------------------------ |
12 |
|
|
13 |
|
## TODO |
14 |
+ |
# allow specification of lower/upper graph bounds |
15 |
+ |
# -- then replace mem/swap/disk "total" line ;) |
16 |
|
# possibly make more configurable? |
17 |
|
# -- allow configurable periods of graphs |
18 |
|
# -- comments, types, etc |
53 |
|
chomp $rrd; |
54 |
|
if($rrd =~ /^(cpu)\.rrd$/) { |
55 |
|
my(@data); |
56 |
< |
push @data, "LINE2:$1:idle#00FF00:idle cpu"; |
57 |
< |
push @data, "LINE2:$1:user#0000FF:user cpu"; |
58 |
< |
push @data, "LINE2:$1:kernel#00FFFF:kernel cpu"; |
59 |
< |
push @data, "LINE2:$1:swap#FF00FF:swap cpu"; |
60 |
< |
push @data, "LINE2:$1:iowait#FF0000:iowait cpu"; |
56 |
> |
push @data, "LINE2:$1:idle:idle#00FF00:idle cpu"; |
57 |
> |
push @data, "LINE2:$1:user:user#0000FF:user cpu"; |
58 |
> |
push @data, "LINE2:$1:kernel:kernel#00FFFF:kernel cpu"; |
59 |
> |
push @data, "LINE2:$1:swap:swap#FF00FF:swap cpu"; |
60 |
> |
push @data, "LINE2:$1:iowait:iowait#FF0000:iowait cpu"; |
61 |
|
&makegraph($machine, $1, "CPU Usage for $machine", \@data); |
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"; |
65 |
> |
push @data, "LINE2:$1:free:free#00FF00:free memory"; |
66 |
> |
push @data, "LINE2:$1:total:total#0000FF:total memory"; |
67 |
|
&makegraph($machine, $1, "Memory Usage for $machine", \@data); |
68 |
|
} |
69 |
|
if($rrd =~ /^(load)\.rrd$/) { |
70 |
|
my(@data); |
71 |
< |
push @data, "LINE2:$1:load1#00FF00:1 minute load average"; |
72 |
< |
push @data, "LINE2:$1:load5#0000FF:5 minute load average"; |
73 |
< |
push @data, "LINE2:$1:load15#FF0000:15 minute load average"; |
71 |
> |
push @data, "LINE2:$1:load1:load1#00FF00:1 minute load average"; |
72 |
> |
push @data, "LINE2:$1:load5:load5#0000FF:5 minute load average"; |
73 |
> |
push @data, "LINE2:$1:load15:load15#FF0000:15 minute load average"; |
74 |
|
&makegraph($machine, $1, "Loads for $machine", \@data); |
75 |
|
} |
76 |
|
if($rrd =~ /^(proc)\.rrd$/) { |
77 |
|
my(@data); |
78 |
< |
push @data, "LINE2:$1:cpu#00FF00:cpu processes"; |
79 |
< |
push @data, "LINE2:$1:sleeping#0000FF:sleeping processes"; |
80 |
< |
push @data, "LINE2:$1:stopped#00FFFF:stopped processes"; |
81 |
< |
push @data, "LINE2:$1:total#FF00FF:total processes"; |
82 |
< |
push @data, "LINE2:$1:zombie#FF0000:zombie processes"; |
78 |
> |
push @data, "LINE2:$1:cpu:cpu#00FF00:cpu processes"; |
79 |
> |
push @data, "LINE2:$1:sleeping:sleeping#0000FF:sleeping processes"; |
80 |
> |
push @data, "LINE2:$1:stopped:stopped#00FFFF:stopped processes"; |
81 |
> |
push @data, "LINE2:$1:total:total#FF00FF:total processes"; |
82 |
> |
push @data, "LINE2:$1:zombie:zombie#FF0000:zombie processes"; |
83 |
|
&makegraph($machine, $1, "Processes on $machine", \@data); |
84 |
|
} |
85 |
|
if($rrd =~ /^(swap)\.rrd$/) { |
86 |
|
my(@data); |
87 |
< |
push @data, "LINE2:$1:free#00FF00:free swap"; |
88 |
< |
push @data, "LINE2:$1:total#0000FF:total swap"; |
87 |
> |
push @data, "LINE2:$1:free:free#00FF00:free swap"; |
88 |
> |
push @data, "LINE2:$1:total:total#0000FF:total swap"; |
89 |
|
&makegraph($machine, $1, "Swap Usage for $machine", \@data); |
90 |
|
} |
91 |
|
if($rrd =~ /^(users)\.rrd$/) { |
92 |
|
my(@data); |
93 |
< |
push @data, "LINE2:$1:count#00FF00:user count"; |
93 |
> |
push @data, "LINE2:$1:count:count#00FF00:user count"; |
94 |
|
&makegraph($machine, $1, "User Count for $machine", \@data); |
95 |
|
} |
96 |
|
if($rrd =~ /^(disk)-(\S+).rrd$/) { |
97 |
|
my(@data); |
98 |
< |
push @data, "LINE2:$1-$2:kbytes#0000FF:total size"; |
99 |
< |
push @data, "LINE2:$1-$2:used#00FF00:used"; |
98 |
> |
push @data, "LINE2:$1-$2:kbytes:kbytes#0000FF:total size"; |
99 |
> |
push @data, "LINE2:$1-$2:used:used#00FF00:used"; |
100 |
|
my($type) = $1; |
101 |
|
my($name) = $2; |
102 |
|
my($nicename) = $2; |
111 |
|
my($baserrd) = $1; |
112 |
|
my($i) = 0; |
113 |
|
while( -f "$rrddir/$machine/$baserrd\_$i.rrd" ) { |
114 |
< |
push @data, "LINE2:$baserrd\_$i:size$i" . &get_colour($i) . ":queue$i size "; |
114 |
> |
push @data, "LINE2:$baserrd\_$i:size:size$i" . &get_colour($i) . ":queue$i size "; |
115 |
|
++$i; |
116 |
|
} |
117 |
< |
push @data, "LINE2:$baserrd\_0:total#FF0000:packets/sec - currently"; |
117 |
> |
push @data, "LINE2:$baserrd\_0:total:total#FF0000:packets/sec - currently"; |
118 |
|
push @rawdata, "GPRINT:total:LAST:%lf %spackets/sec"; |
119 |
|
my($comment); |
120 |
|
if(-f "$rrddir/$machine/$baserrd.def") { |
138 |
|
# $title = the title for the graph |
139 |
|
# (eg. kernow CPU usage) |
140 |
|
# $dataref = a reference to an array containing information for the graph |
141 |
< |
# elements of format: "gtype:rrdname:name#colour:comment with spaces" |
141 |
> |
# elements of format: "gtype:rrdname:dsname:name#colour:comment with spaces" |
142 |
|
# $rawcmdref = a reference to an array containing raw rrd commands |
143 |
|
# elements a single command each, no spaces |
144 |
|
# |
155 |
|
} |
156 |
|
my(@rrdcmd); |
157 |
|
foreach my $dataitem (@data) { |
158 |
< |
# dataitem should be: "gtype:rrdname:name#colour:comment with spaces" |
159 |
< |
if($dataitem =~ /^(\S+):(\S+):(\S+)#(.{6}):(.*)$/) { |
160 |
< |
push @rrdcmd, "DEF:$3=$rrddir/$machine/$2.rrd:$3:MAX"; |
161 |
< |
push @rrdcmd, "$1:$3#$4:$5"; |
158 |
> |
# dataitem should be: "gtype:rrdname:dsname:name#colour:comment with spaces" |
159 |
> |
if($dataitem =~ /^(\S+):(\S+):(\S+):(\S+)#(.{6}):(.*)$/) { |
160 |
> |
push @rrdcmd, "DEF:$4=$rrddir/$machine/$2.rrd:$3:MAX"; |
161 |
> |
push @rrdcmd, "$1:$4#$5:$6"; |
162 |
|
} |
163 |
|
} |
164 |
|
push @rrdcmd, "--title=$title"; |