1 | 1 | simandl | #!/usr/bin/env perl |
2 | | | use strict; |
3 | | | use warnings; |
4 | | | use diagnostics; |
5 | | | |
6 | | | use lib "../../lib"; |
7 | | | use HotSaNICparser; |
8 | | | use HotSaNICdiagram; |
9 | | | use RRDs; |
10 | | | |
11 | | | # read global settings |
12 | | | # |
13 | | | my $MODNAME=HotSaNICparser::get_module_name(); |
14 | | | my %CONFIG=HotSaNICparser::get_config("../.."); |
15 | | | |
16 | | | my $OUTDIR=$CONFIG{"WEBDIR"}."/".lc $MODNAME; |
17 | | | if ( ! -e $OUTDIR ) { mkdir "$OUTDIR",0755; } |
18 | | | |
19 | | | my $IMGFMT=lc $CONFIG{"IMAGEFORMAT"}; |
20 | | | my $TEMPNAME="$OUTDIR/temp.$IMGFMT"; |
21 | | | |
22 | | | my (@ITEMS,$name,$range,$descr,$CPUGRAPH,$NUMCPU); |
23 | | | my $FORCE=@ARGV; |
24 | | | |
25 | | | my ($draw_cpu, $draw_load, $draw_proc, $draw_mem, $draw_users) = 0; |
26 | | | my ($draw_irq, $draw_uptime) = 0; |
27 | | | |
28 | | | # read module-specific settings |
29 | | | # |
30 | | | foreach (HotSaNICparser::read_settings(".")) { |
31 | | | my ($var,$value)=HotSaNICparser::parse_line($_); |
32 | | | if ($var eq "CPUGRAPH") { $CPUGRAPH=$value; } |
33 | | | if ($var eq "NUMCPU") { $NUMCPU=$value; } |
34 | | | if ($var eq "IRQ") { |
35 | | | my ($num,$descr)=split /,/,$value; |
36 | | | $ITEMS[$num]=$descr; |
37 | | | } |
38 | | | if ($var eq "SECTIONS") { |
39 | | | my @sections = split " ", $value; |
40 | | | foreach (@sections){ |
41 | | | if ($_ eq "cpu") {$draw_cpu=1} |
42 | | | if ($_ eq "load") {$draw_load=1} |
43 | | | if ($_ eq "proc") {$draw_proc=1} |
44 | | | if ($_ eq "mem") {$draw_mem=1} |
45 | | | if ($_ eq "users") {$draw_users=1} |
46 | | | if ($_ eq "int") {$draw_irq=1} |
47 | | | if ($_ eq "uptime") {$draw_uptime=1} |
48 | | | } |
49 | | | } |
50 | | | } |
51 | | | |
52 | | | |
53 | | | if ($NUMCPU < 1) { $NUMCPU=1; } |
54 | | | |
55 | | | # generate diagrams |
56 | | | # |
57 | | | |
58 | | | if ($draw_load) {plot_load()} |
59 | | | if ($draw_proc) {plot_proc()} |
60 | | | if ($draw_cpu) {plot_cpu()} |
61 | | | if ($draw_mem) {plot_mem()} |
62 | | | if ($draw_mem) {plot_swap()} |
63 | | | if ($draw_users) {plot_user()} |
64 | | | if ($draw_irq) {plot_irq()} |
65 | | | if ($draw_uptime) {plot_uptime()} |
66 | | | |
67 | | | exit 0; |
68 | | | |
69 | | | |
70 | | | |
71 | | | |
72 | | | sub plot_load { |
73 | | | |
74 | | | print "creating images for loadavg...\n"; |
75 | | | |
76 | | | opendir(DIR,"./rrd"); |
77 | | | my @files=readdir(DIR); |
78 | | | closedir(DIR); |
79 | | | my @results=grep /load.*\.rrd/,@files; |
80 | | | foreach (@results) { s/\.rrd//g; } |
81 | | | |
82 | | | # if database exists, create images... |
83 | | | if (@results) { |
84 | | | foreach my $dev (@results) { |
85 | | | |
86 | | | print " $dev:\n"; |
87 | | | |
88 | | | foreach $range ("1h","6h","1day","1week","1month","1year") { |
89 | | | my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range); |
90 | | | |
91 | | | my $FILENAME="$OUTDIR/$dev-$file.$IMGFMT"; |
92 | | | |
93 | | | my $make=$FORCE; |
94 | | | if ($range eq "1h") { $make++; } |
95 | | | elsif (! -e "$FILENAME") { $make++; } |
96 | | | else { |
97 | | | my (undef,undef,undef,undef,undef,undef,undef,undef,undef,$mtime,undef,undef,undef) = stat( "$FILENAME" ); |
98 | | | if (time > ($mtime+$build)) { $make++; } |
99 | | | } |
100 | | | |
101 | | | if ($make>0) { |
102 | | | |
103 | | | my ($prints,$xs,$ys); |
104 | | | |
105 | | | if ($range eq "1h") { |
106 | | | ($prints,$xs,$ys)=RRDs::graph $TEMPNAME, "-i", |
107 | | | "-s","-$range", "-w",$CONFIG{"WIDTH"}, "-h",$CONFIG{"HEIGHT"}, |
108 | | | "-a", uc($IMGFMT), "-u 1", "--alt-autoscale-max", "-l 0", "--title", "system-load - last $descr ($DATESTRING)", |
109 | | | "DEF:ld1=rrd/$dev.rrd:load1:AVERAGE", |
110 | | | "DEF:ld2=rrd/$dev.rrd:load5:AVERAGE", |
111 | | | "DEF:ld3=rrd/$dev.rrd:load15:AVERAGE", |
112 | | | "AREA:ld1#ff0000: 1 min avg", |
113 | | | "GPRINT:ld1:MIN:(min\\:%1.2lf", |
114 | | | "GPRINT:ld1:MAX:max\\:%1.2lf)\\n", |
115 | | | "LINE2:ld2#aa0000: 5 min avg", |
116 | | | "GPRINT:ld2:MIN:(min\\:%1.2lf", |
117 | | | "GPRINT:ld2:MAX:max\\:%1.2lf)\\n", |
118 | | | "LINE2:ld3#330000:15 min avg", |
119 | | | "GPRINT:ld3:MIN:(min\\:%1.2lf", |
120 | | | "GPRINT:ld3:MAX:max\\:%1.2lf)\\n", |
121 | | | "HRULE:0#000000" or die "$!"; |
122 | | | } |
123 | | | else { |
124 | | | ($prints,$xs,$ys)=RRDs::graph $TEMPNAME, "-i", |
125 | | | "-s","-$range", "-w",$CONFIG{"WIDTH"}, "-h",$CONFIG{"HEIGHT"}, |
126 | | | "-a", uc($IMGFMT), "-u 1", "--alt-autoscale-max", "-l 0", "--title", "system-load - last $descr ($DATESTRING)", |
127 | | | "DEF:avg1=rrd/$dev.rrd:load1:AVERAGE", |
128 | | | "DEF:min1=rrd/$dev.rrd:load1:MIN", |
129 | | | "DEF:max1=rrd/$dev.rrd:load1:MAX", |
130 | | | "DEF:avg5=rrd/$dev.rrd:load5:AVERAGE", |
131 | | | "DEF:avg15=rrd/$dev.rrd:load15:AVERAGE", |
132 | | | "AREA:max1#ffc0c0:min/max", |
133 | | | "LINE1:max1#a0a0a0:", |
134 | | | "AREA:min1#ffffff:", |
135 | | | "LINE1:min1#a0a0a0:", |
136 | | | "GPRINT:min1:MIN:(min\\:%1.2lf", |
137 | | | "GPRINT:min1:MAX:- %1.2lf", |
138 | | | "GPRINT:max1:MIN: max\\:%1.2lf", |
139 | | | "GPRINT:max1:MAX:- %1.2lf)", |
140 | | | "LINE1:avg1#ff0000:avg (1 min)", |
141 | | | "LINE1:avg5#aa0000:avg (5 min)", |
142 | | | "LINE1:avg15#330000:avg (15 min)", |
143 | | | "HRULE:0#000000" or die "$!"; |
144 | | | } |
145 | | | |
146 | | | rename $TEMPNAME,$FILENAME; |
147 | | | printf " %-7s %d"."x%d %s\n",$descr,$xs,$ys,$FILENAME; |
148 | | | |
149 | | | } |
150 | | | } |
151 | | | } |
152 | | | } |
153 | | | else { print " No database found\n Please check if the daemon is running.\n"; } |
154 | | | print "\n"; |
155 | | | } |
156 | | | |
157 | | | |
158 | | | sub plot_proc { |
159 | | | |
160 | | | print "creating images for processes...\n"; |
161 | | | |
162 | | | opendir(DIR,"./rrd"); |
163 | | | my @files=readdir(DIR); |
164 | | | closedir(DIR); |
165 | | | my @results=grep /proc.*\.rrd/,@files; |
166 | | | foreach (@results) { s/\.rrd//g; } |
167 | | | |
168 | | | # if database exists, create images... |
169 | | | if (@results) { |
170 | | | foreach my $dev (@results) { |
171 | | | |
172 | | | print " $dev:\n"; |
173 | | | |
174 | | | foreach $range ("1h","6h","1day","1week","1month","1year") { |
175 | | | my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range); |
176 | | | |
177 | | | my $FILENAME="$OUTDIR/$dev-$file.$IMGFMT"; |
178 | | | |
179 | | | my $make=$FORCE; |
180 | | | if ($range eq "1h") { $make++; } |
181 | | | elsif (! -e "$FILENAME") { $make++; } |
182 | | | else { |
183 | | | my (undef,undef,undef,undef,undef,undef,undef,undef,undef,$mtime,undef,undef,undef) = stat( "$FILENAME" ); |
184 | | | if (time > ($mtime+$build)) { $make++; } |
185 | | | } |
186 | | | |
187 | | | if ($make>0) { |
188 | | | |
189 | | | my ($prints,$xs,$ys); |
190 | | | |
191 | | | ($prints,$xs,$ys)=RRDs::graph $TEMPNAME, "-i", |
192 | | | "-s","-$range", "-w",$CONFIG{"WIDTH"}, "-h",$CONFIG{"HEIGHT"}, |
193 | | | "-a", uc($IMGFMT), "-l 0", "--title", "processes - last $descr ($DATESTRING)", |
194 | | | "DEF:slpmin=rrd/$dev.rrd:procslp:MIN", |
195 | | | "DEF:slpavg=rrd/$dev.rrd:procslp:AVERAGE", |
196 | | | "DEF:slpmax=rrd/$dev.rrd:procslp:MAX", |
197 | | | "DEF:runmin=rrd/$dev.rrd:procrun:MIN", |
198 | | | "DEF:runavg=rrd/$dev.rrd:procrun:AVERAGE", |
199 | | | "DEF:runmax=rrd/$dev.rrd:procrun:MAX", |
200 | | | "DEF:zmbmin=rrd/$dev.rrd:proczmb:MIN", |
201 | | | "DEF:zmbavg=rrd/$dev.rrd:proczmb:AVERAGE", |
202 | | | "DEF:zmbmax=rrd/$dev.rrd:proczmb:MAX", |
203 | | | "DEF:stpmin=rrd/$dev.rrd:procstp:MIN", |
204 | | | "DEF:stpavg=rrd/$dev.rrd:procstp:AVERAGE", |
205 | | | "DEF:stpmax=rrd/$dev.rrd:procstp:MAX", |
206 | | | "DEF:dscmin=rrd/$dev.rrd:procdsc:MIN", |
207 | | | "DEF:dscavg=rrd/$dev.rrd:procdsc:AVERAGE", |
208 | | | "DEF:dscmax=rrd/$dev.rrd:procdsc:MAX", |
209 | | | "AREA:slpavg#00ff00:sleeping", |
210 | | | "GPRINT:slpmin:MIN:(min\\:%3.0lf,", |
211 | | | "GPRINT:slpavg:AVERAGE:avg\\:%3.0lf,", |
212 | | | "GPRINT:slpmax:MAX: max\\:%3.0lf)\\n", |
213 | | | "STACK:dscavg#008800:disc ", |
214 | | | "GPRINT:dscmin:MIN:(min\\:%3.0lf,", |
215 | | | "GPRINT:dscavg:AVERAGE:avg\\:%3.0lf,", |
216 | | | "GPRINT:dscmax:MAX: max\\:%3.0lf)\\n", |
217 | | | "STACK:runavg#0000ff:running ", |
218 | | | "GPRINT:runmin:MIN:(min\\:%3.0lf,", |
219 | | | "GPRINT:runavg:AVERAGE:avg\\:%3.0lf,", |
220 | | | "GPRINT:runmax:MAX: max\\:%3.0lf)\\n", |
221 | | | "STACK:zmbavg#ff0000:zombie ", |
222 | | | "GPRINT:zmbmin:MIN:(min\\:%3.0lf,", |
223 | | | "GPRINT:zmbavg:AVERAGE:avg\\:%3.0lf,", |
224 | | | "GPRINT:zmbmax:MAX: max\\:%3.0lf)\\n", |
225 | | | "STACK:stpavg#505050:stopped ", |
226 | | | "GPRINT:stpmin:MIN:(min\\:%3.0lf,", |
227 | | | "GPRINT:stpavg:AVERAGE:avg\\:%3.0lf,", |
228 | | | "GPRINT:stpmax:MAX: max\\:%3.0lf)\\n", |
229 | | | "HRULE:0#000000"; |
230 | | | |
231 | | | rename $TEMPNAME,$FILENAME; |
232 | | | printf " %-7s %d"."x%d %s\n",$descr,$xs,$ys,$FILENAME; |
233 | | | |
234 | | | } |
235 | | | } |
236 | | | } |
237 | | | } |
238 | | | else { print " No database found\n Please check if the daemon is running.\n"; } |
239 | | | print "\n"; |
240 | | | } |
241 | | | |
242 | | | |
243 | | | sub plot_cpu { |
244 | | | |
245 | | | print "creating images for CPU-usage...\n"; |
246 | | | |
247 | | | my ($PERCENT,$SIGN,$SIGN1); |
248 | | | |
249 | | | if ($CPUGRAPH eq "percent" ) { $PERCENT="100"; $SIGN=" (%)"; $SIGN1=" %% "; } |
250 | | | else { $PERCENT="1"; $SIGN=""; $SIGN1=""; } |
251 | | | |
252 | | | opendir(DIR,"./rrd"); |
253 | | | my @files=readdir(DIR); |
254 | | | closedir(DIR); |
255 | | | my @results=grep /cpu.*\.rrd/,@files; |
256 | | | foreach (@results) { s/\.rrd//g; } |
257 | | | |
258 | | | # if database exists, create images... |
259 | | | if (@results) { |
260 | | | foreach my $dev (@results) { |
261 | | | |
262 | | | print " $dev:\n"; |
263 | | | |
264 | | | foreach $range ("1h","6h","1day","1week","1month","1year") { |
265 | | | my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range); |
266 | | | |
267 | | | my $FILENAME="$OUTDIR/$dev-$file.$IMGFMT"; |
268 | | | |
269 | | | my $make=$FORCE; |
270 | | | if ($range eq "1h") { $make++; } |
271 | | | elsif (! -e "$FILENAME") { $make++; } |
272 | | | else { |
273 | | | my (undef,undef,undef,undef,undef,undef,undef,undef,undef,$mtime,undef,undef,undef) = stat( "$FILENAME" ); |
274 | | | if (time > ($mtime+$build)) { $make++; } |
275 | | | } |
276 | | | |
277 | | | if ($make>0) { |
278 | | | |
279 | | | my ($prints,$xs,$ys); |
280 | | | |
281 | | | # for multicpu: plot range 0..1 for cpu0, cpu1, ... else range 0...$NUMCPU |
282 | | | # |
283 | | | my $NUM=$NUMCPU; |
284 | | | if ( $dev =~ /[0-9]/ ) { $NUM=1; } |
285 | | | |
286 | | | if ( ($^O eq "linux") || ($^O eq "solaris") ) { |
287 | | | ($prints,$xs,$ys)=RRDs::graph $TEMPNAME, "-i", "-b", "1024", |
288 | | | "-s","-$range", "-w",$CONFIG{"WIDTH"}, "-h",$CONFIG{"HEIGHT"}, |
289 | | | "-u $NUMCPU", "-l 0", "-r", "--title", "CPU usage - last $descr ($DATESTRING)", |
290 | | | "-a", uc($IMGFMT), |
291 | | | "DEF:usrdat=rrd/$dev.rrd:cpuusr:AVERAGE", |
292 | | | "DEF:nicdat=rrd/$dev.rrd:cpunic:AVERAGE", |
293 | | | "DEF:sysdat=rrd/$dev.rrd:cpusys:AVERAGE", |
294 | | | "DEF:idldat=rrd/$dev.rrd:cpuidl:AVERAGE", |
295 | | | "CDEF:usravg=usrdat,$NUM,$PERCENT,*,*", |
296 | | | "CDEF:nicavg=nicdat,$NUM,$PERCENT,*,*", |
297 | | | "CDEF:sysavg=sysdat,$NUM,$PERCENT,*,*", |
298 | | | "CDEF:idlavg=idldat,$NUM,$PERCENT,*,*", |
299 | | | # "DEF:usrdx=rrd/$dev.rrd:cpuusr:MAX", |
300 | | | # "DEF:nicdx=rrd/$dev.rrd:cpunic:MAX", |
301 | | | # "DEF:sysdt=rrd/$dev.rrd:cpusys:MAX", |
302 | | | # "CDEF:usrmax=usrdx,$NUM,$PERCENT,*,*", |
303 | | | # "CDEF:nicmax=nicdx,$NUM,$PERCENT,*,*", |
304 | | | # "CDEF:sysmax=sysdx,$NUM,$PERCENT,*,*", |
305 | | | "AREA:sysavg#ff0000:system\\g", |
306 | | | "GPRINT:sysavg:MIN: (min\\:%7.2lf$SIGN1,\\g", |
307 | | | "GPRINT:sysavg:AVERAGE: avg\\:%7.2lf$SIGN1,\\g", |
308 | | | "GPRINT:sysavg:MAX: max\\:%7.2lf$SIGN1)\\n", |
309 | | | "STACK:usravg#0000ff:user\\g", |
310 | | | "GPRINT:usravg:MIN: (min\\:%7.2lf$SIGN1,\\g", |
311 | | | "GPRINT:usravg:AVERAGE: avg\\:%7.2lf$SIGN1,\\g", |
312 | | | "GPRINT:usravg:MAX: max\\:%7.2lf$SIGN1)\\n", |
313 | | | "STACK:nicavg#ffff00:nice\\g", |
314 | | | "GPRINT:nicavg:MIN: (min\\:%7.2lf$SIGN1,\\g", |
315 | | | "GPRINT:nicavg:AVERAGE: avg\\:%7.2lf$SIGN1,\\g", |
316 | | | "GPRINT:nicavg:MAX: max\\:%7.2lf$SIGN1)\\n", |
317 | | | "STACK:idlavg#00ff00:idle\\g", |
318 | | | "GPRINT:idlavg:MIN: (min\\:%7.2lf$SIGN1,\\g", |
319 | | | "GPRINT:idlavg:AVERAGE: avg\\:%7.2lf$SIGN1,\\g", |
320 | | | "GPRINT:idlavg:MAX: max\\:%7.2lf$SIGN1)\\n", |
321 | | | # "LINE1:sysmax#ff0000:", |
322 | | | # "LINE1:usrmax#0000ff:", |
323 | | | # "LINE1:nicmax#ffff00:", |
324 | | | "HRULE:0#000000"; |
325 | | | } |
326 | | | elsif ( ($^O eq "freebsd") || ($^O eq "netbsd")) { |
327 | | | ($prints,$xs,$ys)=RRDs::graph $TEMPNAME, "-i", "-b", "1024", |
328 | | | "-s","-$range", "-w",$CONFIG{"WIDTH"}, "-h",$CONFIG{"HEIGHT"}, |
329 | | | "-u $NUMCPU", "-l 0", "--title", "CPU usage - last $descr ($DATESTRING)", |
330 | | | "-a", uc($IMGFMT), |
331 | | | "DEF:usravg=rrd/$dev.rrd:cpuusr:AVERAGE", |
332 | | | "DEF:nicavg=rrd/$dev.rrd:cpunic:AVERAGE", |
333 | | | "DEF:sysavg=rrd/$dev.rrd:cpusys:AVERAGE", |
334 | | | "DEF:idlavg=rrd/$dev.rrd:cpuidl:AVERAGE", |
335 | | | "DEF:intavg=rrd/$dev.rrd:cpuint:AVERAGE", |
336 | | | "AREA:sysavg#ff0000:system", |
337 | | | "GPRINT:sysavg:MIN:(min\\:%1.2lf,", |
338 | | | "GPRINT:sysavg:AVERAGE:avg\\:%1.2lf,", |
339 | | | "GPRINT:sysavg:MAX: max\\:%1.2lf)\\n", |
340 | | | "STACK:intavg#ff8c05:interrupt", |
341 | | | "GPRINT:intavg:MIN:(min\\:%1.2lf,", |
342 | | | "GPRINT:intavg:AVERAGE:avg\\:%1.2lf,", |
343 | | | "GPRINT:intavg:MAX: max\\:%1.2lf)\\n", |
344 | | | "STACK:usravg#0000ff:user", |
345 | | | "GPRINT:usravg:MIN:(min\\:%1.2lf,", |
346 | | | "GPRINT:usravg:AVERAGE:avg\\:%1.2lf,", |
347 | | | "GPRINT:usravg:MAX: max\\:%1.2lf)\\n", |
348 | | | "STACK:nicavg#ffff00:nice", |
349 | | | "GPRINT:nicavg:MIN:(min\\:%1.2lf,", |
350 | | | "GPRINT:nicavg:AVERAGE:avg\\:%1.2lf,", |
351 | | | "GPRINT:nicavg:MAX: max\\:%1.2lf)\\n", |
352 | | | "STACK:idlavg#00ffff:idle", |
353 | | | "GPRINT:idlavg:MIN:(min\\:%1.2lf,", |
354 | | | "GPRINT:idlavg:AVERAGE:avg\\:%1.2lf,", |
355 | | | "GPRINT:idlavg:MAX: max\\:%1.2lf)\\n", |
356 | | | "HRULE:0#000000"; |
357 | | | } |
358 | | | |
359 | | | rename $TEMPNAME,$FILENAME; |
360 | | | printf " %-7s %d"."x%d %s\n",$descr,$xs,$ys,$FILENAME; |
361 | | | |
362 | | | } |
363 | | | } |
364 | | | } |
365 | | | } |
366 | | | else { print " No database found\n Please check if the daemon is running.\n"; } |
367 | | | print "\n"; |
368 | | | } |
369 | | | |
370 | | | |
371 | | | sub plot_mem { |
372 | | | |
373 | | | print "creating images for memory-usage...\n"; |
374 | | | |
375 | | | opendir(DIR,"./rrd"); |
376 | | | my @files=readdir(DIR); |
377 | | | closedir(DIR); |
378 | | | my @results=grep /mem.*\.rrd/,@files; |
379 | | | foreach (@results) { s/\.rrd//g; } |
380 | | | |
381 | | | # if database exists, create images... |
382 | | | if (@results) { |
383 | | | foreach my $dev (@results) { |
384 | | | |
385 | | | print " $dev:\n"; |
386 | | | |
387 | | | foreach $range ("1h","6h","1day","1week","1month","1year") { |
388 | | | my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range); |
389 | | | |
390 | | | my $FILENAME="$OUTDIR/$dev-$file.$IMGFMT"; |
391 | | | |
392 | | | my $make=$FORCE; |
393 | | | if ($range eq "1h") { $make++; } |
394 | | | elsif (! -e "$FILENAME") { $make++; } |
395 | | | else { |
396 | | | my (undef,undef,undef,undef,undef,undef,undef,undef,undef,$mtime,undef,undef,undef) = stat( "$FILENAME" ); |
397 | | | if (time > ($mtime+$build)) { $make++; } |
398 | | | } |
399 | | | |
400 | | | if ($make>0) { |
401 | | | |
402 | | | my ($prints,$xs,$ys); |
403 | | | |
404 | | | if ($^O eq "linux") { |
405 | | | ($prints,$xs,$ys)=RRDs::graph $TEMPNAME, "-i", "-b", "1024", |
406 | | | "-s","-$range", "-w",$CONFIG{"WIDTH"}, "-h",$CONFIG{"HEIGHT"}, |
407 | | | "-u 1", "--alt-autoscale-max", "-l 0", "--title", "memory usage - last $descr ($DATESTRING)", |
408 | | | "-a", uc($IMGFMT), |
409 | | | "DEF:memfre=rrd/$dev.rrd:memfre:AVERAGE", |
410 | | | "DEF:memshr=rrd/$dev.rrd:memshr:AVERAGE", |
411 | | | "DEF:membuf=rrd/$dev.rrd:membuf:AVERAGE", |
412 | | | "DEF:memcac=rrd/$dev.rrd:memcac:AVERAGE", |
413 | | | "AREA:memcac#ffa000:cached ", |
414 | | | "GPRINT:memcac:MIN:(min\\:%7.2lf%s,", |
415 | | | "GPRINT:memcac:AVERAGE:avg\\:%7.2lf%s,", |
416 | | | "GPRINT:memcac:MAX: max\\:%7.2lf%s)\\n", |
417 | | | "STACK:memshr#ffff00:shared ", |
418 | | | "GPRINT:memshr:MIN:(min\\:%7.2lf%s,", |
419 | | | "GPRINT:memshr:AVERAGE:avg\\:%7.2lf%s,", |
420 | | | "GPRINT:memshr:MAX: max\\:%7.2lf%s)\\n", |
421 | | | "STACK:membuf#00ff00:buffered", |
422 | | | "GPRINT:membuf:MIN:(min\\:%7.2lf%s,", |
423 | | | "GPRINT:membuf:AVERAGE:avg\\:%7.2lf%s,", |
424 | | | "GPRINT:membuf:MAX: max\\:%7.2lf%s)\\n", |
425 | | | "STACK:memfre#00c000:free ", |
426 | | | "GPRINT:memfre:MIN:(min\\:%7.2lf%s,", |
427 | | | "GPRINT:memfre:AVERAGE:avg\\:%7.2lf%s,", |
428 | | | "GPRINT:memfre:MAX: max\\:%7.2lf%s)\\n", |
429 | | | "HRULE:0#000000"; |
430 | | | } |
431 | | | if ($^O eq "solaris") { |
432 | | | ($prints,$xs,$ys)=RRDs::graph $TEMPNAME, "-i", "-b", "1024", |
433 | | | "-s","-$range", "-w",$CONFIG{"WIDTH"}, "-h",$CONFIG{"HEIGHT"}, |
434 | | | "-u 1", "--alt-autoscale-max", "-l 0", "--title", "memory usage - last $descr ($DATESTRING)", |
435 | | | "-a", uc($IMGFMT), |
436 | | | "DEF:memfre=rrd/$dev.rrd:memfre:AVERAGE", |
437 | | | "DEF:memshr=rrd/$dev.rrd:memshr:AVERAGE", |
438 | | | "AREA:memshr#ff0000:used ", |
439 | | | "GPRINT:memshr:MIN:(min\\:%7.2lf%s,", |
440 | | | "GPRINT:memshr:AVERAGE:avg\\:%7.2lf%s,", |
441 | | | "GPRINT:memshr:MAX: max\\:%7.2lf%s)\\n", |
442 | | | "STACK:memfre#00c000:free ", |
443 | | | "GPRINT:memfre:MIN:(min\\:%7.2lf%s,", |
444 | | | "GPRINT:memfre:AVERAGE:avg\\:%7.2lf%s,", |
445 | | | "GPRINT:memfre:MAX: max\\:%7.2lf%s)\\n", |
446 | | | "HRULE:0#000000"; |
447 | | | } |
448 | | | elsif ($^O eq "freebsd") { |
449 | | | ($prints,$xs,$ys)=RRDs::graph $TEMPNAME, "-i", "-b", "1024", |
450 | | | "-s","-$range", "-w",$CONFIG{"WIDTH"}, "-h",$CONFIG{"HEIGHT"}, |
451 | | | "-u 1", "--alt-autoscale-max", "-l 0", "--title", "memory usage - last $descr ($DATESTRING)", |
452 | | | "-a", uc($IMGFMT), |
453 | | | "DEF:memfree=rrd/$dev.rrd:memfree:AVERAGE", |
454 | | | "DEF:memwire=rrd/$dev.rrd:memwire:AVERAGE", |
455 | | | "DEF:memactv=rrd/$dev.rrd:memactv:AVERAGE", |
456 | | | "DEF:meminac=rrd/$dev.rrd:meminac:AVERAGE", |
457 | | | "DEF:memcach=rrd/$dev.rrd:memcach:AVERAGE", |
458 | | | "AREA:memwire#0000ff:wired", |
459 | | | "GPRINT:memwire:MIN:(min\\:%1.2lf%s,", |
460 | | | "GPRINT:memwire:AVERAGE:avg\\:%1.2lf%s,", |
461 | | | "GPRINT:memwire:MAX: max\\:%1.2lf%s)\\n", |
462 | | | "STACK:memactv#ff0000:active", |
463 | | | "GPRINT:memactv:MIN:(min\\:%1.2lf%s,", |
464 | | | "GPRINT:memactv:AVERAGE:avg\\:%1.2lf%s,", |
465 | | | "GPRINT:memactv:MAX: max\\:%1.2lf%s)\\n", |
466 | | | "STACK:memcach#ffa000:cached", |
467 | | | "GPRINT:memcach:MIN:(min\\:%1.2lf%s,", |
468 | | | "GPRINT:memcach:AVERAGE:avg\\:%1.2lf%s,", |
469 | | | "GPRINT:memcach:MAX: max\\:%1.2lf%s)\\n", |
470 | | | "STACK:meminac#00ff00:inactive", |
471 | | | "GPRINT:meminac:MIN:(min\\:%1.2lf%s,", |
472 | | | "GPRINT:meminac:AVERAGE:avg\\:%1.2lf%s,", |
473 | | | "GPRINT:meminac:MAX: max\\:%1.2lf%s)\\n", |
474 | | | "STACK:memfree#00c000:free", |
475 | | | "GPRINT:memfree:MIN:(min\\:%1.2lf%s,", |
476 | | | "GPRINT:memfree:AVERAGE:avg\\:%1.2lf%s,", |
477 | | | "GPRINT:memfree:MAX: max\\:%1.2lf%s)\\n", |
478 | | | "HRULE:0#000000"; |
479 | | | } |
480 | | | elsif ($^O eq "netbsd") { |
481 | | | ($prints,$xs,$ys)=RRDs::graph $TEMPNAME, "-i", "-b", "1024", |
482 | | | "-s","-$range", "-w",$CONFIG{"WIDTH"}, "-h",$CONFIG{"HEIGHT"}, |
483 | | | "-u 1", "--alt-autoscale-max", "-l 0", "--title", "memory usage - last $descr ($DATESTRING)", |
484 | | | "-a", uc($IMGFMT), |
485 | | | "DEF:memfree=rrd/$dev.rrd:memfree:AVERAGE", |
486 | | | "DEF:meminac=rrd/$dev.rrd:meminac:AVERAGE", |
487 | | | "DEF:memacti=rrd/$dev.rrd:memacti:AVERAGE", |
488 | | | "DEF:memwire=rrd/$dev.rrd:memwire:AVERAGE", |
489 | | | "DEF:memcach=rrd/$dev.rrd:memcach:AVERAGE", |
490 | | | "AREA:memcach#0000ff:cached", |
491 | | | "GPRINT:memcach:MIN:(min\\:%1.2lf%s,", |
492 | | | "GPRINT:memcach:AVERAGE:avg\\:%1.2lf%s,", |
493 | | | "GPRINT:memcach:MAX: max\\:%1.2lf%s)\\n", |
494 | | | "STACK:memwire#00dd55:wired", |
495 | | | "GPRINT:memwire:MIN:(min\\:%1.2lf%s,", |
496 | | | "GPRINT:memwire:AVERAGE:avg\\:%1.2lf%s,", |
497 | | | "GPRINT:memwire:MAX: max\\:%1.2lf%s)\\n", |
498 | | | "STACK:memacti#ff0000:active", |
499 | | | "GPRINT:memacti:MIN:(min\\:%1.2lf%s,", |
500 | | | "GPRINT:memacti:AVERAGE:avg\\:%1.2lf%s,", |
501 | | | "GPRINT:memacti:MAX: max\\:%1.2lf%s)\\n", |
502 | | | "STACK:meminac#993300:inactive", |
503 | | | "GPRINT:meminac:MIN:(min\\:%1.2lf%s,", |
504 | | | "GPRINT:meminac:AVERAGE:avg\\:%1.2lf%s,", |
505 | | | "GPRINT:meminac:MAX: max\\:%1.2lf%s)\\n", |
506 | | | "STACK:memfree#00ff00:free", |
507 | | | "GPRINT:memfree:MIN:(min\\:%1.2lf%s,", |
508 | | | "GPRINT:memfree:AVERAGE:avg\\:%1.2lf%s,", |
509 | | | "GPRINT:memfree:MAX: max\\:%1.2lf%s)\\n", |
510 | | | "HRULE:0#000000"; |
511 | | | } |
512 | | | elsif ($^O eq "darwin") { |
513 | | | ($prints,$xs,$ys)=RRDs::graph $TEMPNAME, "-i", "-b", "1024", |
514 | | | "-s","-$range", "-w",$CONFIG{"WIDTH"}, "-h",$CONFIG{"HEIGHT"}, |
515 | | | "-u 1", "--alt-autoscale-max", "-l 0", "--title", "memory usage - last $descr ($DATESTRING)", |
516 | | | "-a", uc($IMGFMT), |
517 | | | "DEF:memfree=rrd/$dev.rrd:memfree:AVERAGE", |
518 | | | "DEF:memwire=rrd/$dev.rrd:memwire:AVERAGE", |
519 | | | "DEF:memactv=rrd/$dev.rrd:memactv:AVERAGE", |
520 | | | "DEF:meminac=rrd/$dev.rrd:meminac:AVERAGE", |
521 | | | "AREA:memwire#0000ff:wired", |
522 | | | "GPRINT:memwire:MIN:(min\\:%1.2lf%s,", |
523 | | | "GPRINT:memwire:AVERAGE:avg\\:%1.2lf%s,", |
524 | | | "GPRINT:memwire:MAX: max\\:%1.2lf%s)\\n", |
525 | | | "STACK:memactv#ff0000:active", |
526 | | | "GPRINT:memactv:MIN:(min\\:%1.2lf%s,", |
527 | | | "GPRINT:memactv:AVERAGE:avg\\:%1.2lf%s,", |
528 | | | "GPRINT:memactv:MAX: max\\:%1.2lf%s)\\n", |
529 | | | "STACK:meminac#00ff00:inactive", |
530 | | | "GPRINT:meminac:MIN:(min\\:%1.2lf%s,", |
531 | | | "GPRINT:meminac:AVERAGE:avg\\:%1.2lf%s,", |
532 | | | "GPRINT:meminac:MAX: max\\:%1.2lf%s)\\n", |
533 | | | "STACK:memfree#00c000:free", |
534 | | | "GPRINT:memfree:MIN:(min\\:%1.2lf%s,", |
535 | | | "GPRINT:memfree:AVERAGE:avg\\:%1.2lf%s,", |
536 | | | "GPRINT:memfree:MAX: max\\:%1.2lf%s)\\n", |
537 | | | "HRULE:0#000000"; |
538 | | | } |
539 | | | |
540 | | | rename $TEMPNAME,$FILENAME; |
541 | | | printf " %-7s %d"."x%d %s\n",$descr,$xs,$ys,$FILENAME; |
542 | | | |
543 | | | } |
544 | | | } |
545 | | | } |
546 | | | } |
547 | | | else { print " No database found\n Please check if the daemon is running.\n"; } |
548 | | | print "\n"; |
549 | | | } |
550 | | | |
551 | | | |
552 | | | sub plot_swap { |
553 | | | |
554 | | | print "creating images for swapfile-usage...\n"; |
555 | | | |
556 | | | opendir(DIR,"./rrd"); |
557 | | | my @files=readdir(DIR); |
558 | | | closedir(DIR); |
559 | | | my @results=grep /mem.*\.rrd/,@files; |
560 | | | foreach (@results) { s/\.rrd//g; } |
561 | | | |
562 | | | # if database exists, create images... |
563 | | | if (@results) { |
564 | | | foreach my $dev (@results) { |
565 | | | |
566 | | | print " $dev:\n"; |
567 | | | |
568 | | | foreach $range ("1h","6h","1day","1week","1month","1year") { |
569 | | | my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range); |
570 | | | |
571 | | | (my $dev1=$dev) =~ s/^mem/swap/g; |
572 | | | |
573 | | | my $FILENAME="$OUTDIR/$dev1-$file.$IMGFMT"; |
574 | | | |
575 | | | my $make=$FORCE; |
576 | | | if ($range eq "1h") { $make++; } |
577 | | | elsif (! -e "$FILENAME") { $make++; } |
578 | | | else { |
579 | | | my (undef,undef,undef,undef,undef,undef,undef,undef,undef,$mtime,undef,undef,undef) = stat( "$FILENAME" ); |
580 | | | if (time > ($mtime+$build)) { $make++; } |
581 | | | } |
582 | | | |
583 | | | if ($make>0) { |
584 | | | |
585 | | | my ($prints,$xs,$ys); |
586 | | | |
587 | | | ($prints,$xs,$ys)=RRDs::graph $TEMPNAME, "-i", "-b", "1024", |
588 | | | "-s","-$range", "-w",$CONFIG{"WIDTH"}, "-h",$CONFIG{"HEIGHT"}, |
589 | | | "-u 1", "--alt-autoscale-max", "-l 0", "--title", "swapfile usage - last $descr ($DATESTRING)", |
590 | | | "-a", uc($IMGFMT), |
591 | | | "DEF:swpfre=rrd/$dev.rrd:swpfre:AVERAGE", |
592 | | | "DEF:swpuse=rrd/$dev.rrd:swpuse:AVERAGE", |
593 | | | "DEF:maxswpuse=rrd/$dev.rrd:swpuse:MAX", |
594 | | | "AREA:swpuse#c00000:used ", |
595 | | | "GPRINT:swpuse:MIN:(min\\:%7.2lf%s,", |
596 | | | "GPRINT:swpuse:AVERAGE:avg\\:%7.2lf%s,", |
597 | | | "GPRINT:swpuse:MAX: max\\:%7.2lf%s)\\n", |
598 | | | "STACK:swpfre#00c000:free ", |
599 | | | "GPRINT:swpfre:MIN:(min\\:%7.2lf%s,", |
600 | | | "GPRINT:swpfre:AVERAGE:avg\\:%7.2lf%s,", |
601 | | | "GPRINT:swpfre:MAX: max\\:%7.2lf%s)\\n", |
602 | | | "LINE1:maxswpuse#c0c000:max used", |
603 | | | "GPRINT:maxswpuse:MIN:(min\\:%7.2lf%s,", |
604 | | | "GPRINT:maxswpuse:AVERAGE:avg\\:%7.2lf%s,", |
605 | | | "GPRINT:maxswpuse:MAX: max\\:%7.2lf%s)\\n", |
606 | | | "HRULE:0#000000"; |
607 | | | |
608 | | | rename $TEMPNAME,$FILENAME; |
609 | | | printf " %-7s %d"."x%d %s\n",$descr,$xs,$ys,$FILENAME; |
610 | | | |
611 | | | } |
612 | | | } |
613 | | | } |
614 | | | } |
615 | | | else { print " No database found\n Please check if the daemon is running.\n"; } |
616 | | | print "\n"; |
617 | | | } |
618 | | | |
619 | | | |
620 | | | sub plot_user { |
621 | | | |
622 | | | print "creating images for user-stats...\n"; |
623 | | | |
624 | | | opendir(DIR,"./rrd"); |
625 | | | my @files=readdir(DIR); |
626 | | | closedir(DIR); |
627 | | | my @results=grep /users.*\.rrd/,@files; |
628 | | | foreach (@results) { s/\.rrd//g; } |
629 | | | |
630 | | | # if database exists, create images... |
631 | | | if (@results) { |
632 | | | foreach my $dev (@results) { |
633 | | | |
634 | | | print " $dev:\n"; |
635 | | | |
636 | | | foreach $range ("1h","6h","1day","1week","1month","1year") { |
637 | | | my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range); |
638 | | | |
639 | | | my $FILENAME="$OUTDIR/$dev-$file.$IMGFMT"; |
640 | | | |
641 | | | my $make=$FORCE; |
642 | | | if ($range eq "1h") { $make++; } |
643 | | | elsif (! -e "$FILENAME") { $make++; } |
644 | | | else { |
645 | | | my (undef,undef,undef,undef,undef,undef,undef,undef,undef,$mtime,undef,undef,undef) = stat( "$FILENAME" ); |
646 | | | if (time > ($mtime+$build)) { $make++; } |
647 | | | } |
648 | | | |
649 | | | if ($make>0) { |
650 | | | |
651 | | | my ($prints,$xs,$ys); |
652 | | | |
653 | | | ($prints,$xs,$ys)=RRDs::graph $TEMPNAME, "-i", "-b", "1024", |
654 | | | "-s","-$range", "-w",$CONFIG{"WIDTH"}, "-h",$CONFIG{"HEIGHT"}, |
655 | | | "-u 1", "--alt-autoscale-max", "-l 0", "--title", "users - last $descr ($DATESTRING)", |
656 | | | "-a", uc($IMGFMT), |
657 | | | "DEF:ttymin=rrd/$dev.rrd:tty:MIN", |
658 | | | "DEF:ttyavg=rrd/$dev.rrd:tty:AVERAGE", |
659 | | | "DEF:ttymax=rrd/$dev.rrd:tty:MAX", |
660 | | | "DEF:ptymin=rrd/$dev.rrd:pty:MIN", |
661 | | | "DEF:ptyavg=rrd/$dev.rrd:pty:AVERAGE", |
662 | | | "DEF:ptymax=rrd/$dev.rrd:pty:MAX", |
663 | | | "DEF:ptsmin=rrd/$dev.rrd:pts:MIN", |
664 | | | "DEF:ptsavg=rrd/$dev.rrd:pts:AVERAGE", |
665 | | | "DEF:ptsmax=rrd/$dev.rrd:pts:MAX", |
666 | | | "AREA:ttymax#000000:tty users", |
667 | | | "GPRINT:ttymin:MIN:(min\\:%3.0lf%s,", |
668 | | | "GPRINT:ttyavg:AVERAGE:avg\\:%3.0lf%s,", |
669 | | | "GPRINT:ttymax:MAX: max\\:%3.0lf%s)\\n", |
670 | | | "STACK:ptymax#808080:pty users", |
671 | | | "GPRINT:ptymin:MIN:(min\\:%3.0lf%s,", |
672 | | | "GPRINT:ptyavg:AVERAGE:avg\\:%3.0lf%s,", |
673 | | | "GPRINT:ptymax:MAX: max\\:%3.0lf%s)\\n", |
674 | | | "STACK:ptsmax#d0d0d0:pts users", |
675 | | | "GPRINT:ptsmin:MIN:(min\\:%3.0lf%s,", |
676 | | | "GPRINT:ptsavg:AVERAGE:avg\\:%3.0lf%s,", |
677 | | | "GPRINT:ptsmax:MAX: max\\:%3.0lf%s)\\n", |
678 | | | # "CDEF:totavg=ttyavg,ptyavg,ptsavg,+,+", |
679 | | | # "LINE1:totavg#c00000:total average", |
680 | | | # "GPRINT:totavg:MIN:(min\\:%3.0lf%s,", |
681 | | | # "GPRINT:totavg:AVERAGE:avg\\:%3.0lf%s,", |
682 | | | # "GPRINT:totavg:MAX: max\\:%3.0lf%s)\\n", |
683 | | | "HRULE:0#000000"; |
684 | | | |
685 | | | rename $TEMPNAME,$FILENAME; |
686 | | | printf " %-7s %d"."x%d %s\n",$descr,$xs,$ys,$FILENAME; |
687 | | | |
688 | | | } |
689 | | | } |
690 | | | } |
691 | | | } |
692 | | | else { print " No database found\n Please check if the daemon is running.\n"; } |
693 | | | print "\n"; |
694 | | | } |
695 | | | |
696 | | | |
697 | | | sub plot_irq { |
698 | | | |
699 | | | print "creating images for interrupts...\n"; |
700 | | | |
701 | | | for (my $nn=0;$nn<18;$nn++) { |
702 | | | if (!defined $ITEMS[$nn]) { $ITEMS[$nn]="?"; } |
703 | | | if ($ITEMS[$nn] eq "") { $ITEMS[$nn]="?"; } |
704 | | | $ITEMS[$nn]=substr("(".substr($ITEMS[$nn],0,5).") ",0,7); |
705 | | | } |
706 | | | |
707 | | | my $LEGEND="irq/s"; |
708 | | | |
709 | | | # if database exists, create images... |
710 | | | if ( -e "./rrd/irq.rrd") { |
711 | | | |
712 | | | foreach $range ("1h","6h","1day","1week","1month","1year") { |
713 | | | my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range); |
714 | | | |
715 | | | my $FILENAME="$OUTDIR/irq-$file.$IMGFMT"; |
716 | | | |
717 | | | my $make=$FORCE; |
718 | | | if ($range eq "1h") { $make++; } |
719 | | | elsif (! -e "$FILENAME") { $make++; } |
720 | | | else { |
721 | | | my (undef,undef,undef,undef,undef,undef,undef,undef,undef,$mtime,undef,undef,undef) = stat( "$FILENAME" ); |
722 | | | if (time > ($mtime+$build)) { $make++; } |
723 | | | } |
724 | | | |
725 | | | if ($make>0) { |
726 | | | |
727 | | | my ($prints,$xs,$ys); |
728 | | | |
729 | | | ($prints,$xs,$ys)=RRDs::graph $TEMPNAME, "-i", "-b","1024", "-v", $LEGEND, |
730 | | | "-s","-$range", "-w",$CONFIG{"WIDTH"}, "-h",$CONFIG{"HEIGHT"}, |
731 | | | "-l 0", "--title", "total IRQ/s - last $descr ($DATESTRING)", |
732 | | | "-a", uc($IMGFMT), |
733 | | | "DEF:irqiall=rrd/irq.rrd:irqall:MIN", |
734 | | | "DEF:irqaall=rrd/irq.rrd:irqall:AVERAGE", |
735 | | | "DEF:irqxall=rrd/irq.rrd:irqall:MAX", |
736 | | | "DEF:irqa00=rrd/irq.rrd:irq00:AVERAGE", |
737 | | | "DEF:irqa01=rrd/irq.rrd:irq01:AVERAGE", |
738 | | | "DEF:irqa02=rrd/irq.rrd:irq02:AVERAGE", |
739 | | | "DEF:irqa03=rrd/irq.rrd:irq03:AVERAGE", |
740 | | | "DEF:irqa04=rrd/irq.rrd:irq04:AVERAGE", |
741 | | | "DEF:irqa05=rrd/irq.rrd:irq05:AVERAGE", |
742 | | | "DEF:irqa06=rrd/irq.rrd:irq06:AVERAGE", |
743 | | | "DEF:irqa07=rrd/irq.rrd:irq07:AVERAGE", |
744 | | | "DEF:irqa08=rrd/irq.rrd:irq08:AVERAGE", |
745 | | | "DEF:irqa09=rrd/irq.rrd:irq09:AVERAGE", |
746 | | | "DEF:irqa10=rrd/irq.rrd:irq10:AVERAGE", |
747 | | | "DEF:irqa11=rrd/irq.rrd:irq11:AVERAGE", |
748 | | | "DEF:irqa12=rrd/irq.rrd:irq12:AVERAGE", |
749 | | | "DEF:irqa13=rrd/irq.rrd:irq13:AVERAGE", |
750 | | | "DEF:irqa14=rrd/irq.rrd:irq14:AVERAGE", |
751 | | | "DEF:irqa15=rrd/irq.rrd:irq15:AVERAGE", |
752 | | | "AREA:irqxall#c0c0ff:total", |
753 | | | "AREA:irqiall#ffffff:\\g", |
754 | | | "GPRINT:irqiall:MIN: (min\\:%7.2lf %s /\\g", |
755 | | | "GPRINT:irqaall:AVERAGE: avg\\:%7.2lf %s /\\g", |
756 | | | "GPRINT:irqxall:MAX: max\\:%7.2lf %s $LEGEND)\\n", |
757 | | | "LINE1:irqxall#ff0000:", |
758 | | | "LINE1:irqiall#00ff00:", |
759 | | | "LINE1:irqaall#000000:", |
760 | 26 | simandl | "COMMENT:Averages (min/max)\\:\\n", |
761 | 1 | simandl | "LINE2:irqa00#a00000:00".$ITEMS[0], |
762 | | | "GPRINT:irqa00:MIN:%5.1lf%s/\\g", |
763 | | | "GPRINT:irqa00:MAX:%5.1lf%s", |
764 | | | "LINE2:irqa01#ff0000:01".$ITEMS[1], |
765 | | | "GPRINT:irqa01:MIN:%5.1lf%s/\\g", |
766 | | | "GPRINT:irqa01:MAX:%5.1lf%s", |
767 | | | "LINE2:irqa02#ff5050:02".$ITEMS[2], |
768 | | | "GPRINT:irqa02:MIN:%5.1lf%s/\\g", |
769 | | | "GPRINT:irqa02:MAX:%5.1lf%s", |
770 | | | "LINE2:irqa03#ffa0a0:03".$ITEMS[3], |
771 | | | "GPRINT:irqa03:MIN:%5.1lf%s/\\g", |
772 | | | "GPRINT:irqa03:MAX:%5.1lf%s\\n", |
773 | | | "LINE2:irqa04#00a000:04".$ITEMS[4], |
774 | | | "GPRINT:irqa04:MIN:%5.1lf%s/\\g", |
775 | | | "GPRINT:irqa04:MAX:%5.1lf%s", |
776 | | | "LINE2:irqa05#00ff00:05".$ITEMS[5], |
777 | | | "GPRINT:irqa05:MIN:%5.1lf%s/\\g", |
778 | | | "GPRINT:irqa05:MAX:%5.1lf%s", |
779 | | | "LINE2:irqa06#50ff50:06".$ITEMS[6], |
780 | | | "GPRINT:irqa06:MIN:%5.1lf%s/\\g", |
781 | | | "GPRINT:irqa06:MAX:%5.1lf%s", |
782 | | | "LINE2:irqa07#a0ffa0:07".$ITEMS[7], |
783 | | | "GPRINT:irqa07:MIN:%5.1lf%s/\\g", |
784 | | | "GPRINT:irqa07:MAX:%5.1lf%s\\n", |
785 | | | "LINE2:irqa08#0000a0:08".$ITEMS[8], |
786 | | | "GPRINT:irqa08:MIN:%5.1lf%s/\\g", |
787 | | | "GPRINT:irqa08:MAX:%5.1lf%s", |
788 | | | "LINE2:irqa09#0000ff:09".$ITEMS[9], |
789 | | | "GPRINT:irqa09:MIN:%5.1lf%s/\\g", |
790 | | | "GPRINT:irqa09:MAX:%5.1lf%s", |
791 | | | "LINE2:irqa10#5050ff:10".$ITEMS[10], |
792 | | | "GPRINT:irqa10:MIN:%5.1lf%s/\\g", |
793 | | | "GPRINT:irqa10:MAX:%5.1lf%s", |
794 | | | "LINE2:irqa11#a0a0ff:11".$ITEMS[11], |
795 | | | "GPRINT:irqa11:MIN:%5.1lf%s/\\g", |
796 | | | "GPRINT:irqa11:MAX:%5.1lf%s\\n", |
797 | | | "LINE2:irqa12#a000a0:12".$ITEMS[12], |
798 | | | "GPRINT:irqa12:MIN:%5.1lf%s/\\g", |
799 | | | "GPRINT:irqa12:MAX:%5.1lf%s", |
800 | | | "LINE2:irqa13#ff00ff:13".$ITEMS[13], |
801 | | | "GPRINT:irqa13:MIN:%5.1lf%s/\\g", |
802 | | | "GPRINT:irqa13:MAX:%5.1lf%s", |
803 | | | "LINE2:irqa14#ff50ff:14".$ITEMS[14], |
804 | | | "GPRINT:irqa14:MIN:%5.1lf%s/\\g", |
805 | | | "GPRINT:irqa14:MAX:%5.1lf%s", |
806 | | | "LINE2:irqa15#ffa0ff:15".$ITEMS[15], |
807 | | | "GPRINT:irqa15:MIN:%5.1lf%s/\\g", |
808 | | | "GPRINT:irqa15:MAX:%5.1lf%s", |
809 | | | "HRULE:0#000000"; |
810 | | | |
811 | | | rename $TEMPNAME,$FILENAME; |
812 | | | printf " %-7s %d"."x%d %s\n",$descr,$xs,$ys,$FILENAME; |
813 | | | |
814 | | | } |
815 | | | } |
816 | | | } |
817 | | | else { print " No database found\n Please check if the daemon is running.\n"; } |
818 | | | print "\n"; |
819 | | | } |
820 | | | |
821 | | | sub plot_uptime { |
822 | | | |
823 | | | print "creating images for uptime...\n"; |
824 | | | |
825 | | | opendir(DIR,"./rrd"); |
826 | | | my @files=readdir(DIR); |
827 | | | closedir(DIR); |
828 | | | my @results=grep /uptime.*\.rrd/,@files; |
829 | | | foreach (@results) { s/\.rrd//g; } |
830 | | | |
831 | | | # if database exists, create images... |
832 | | | if (@results) { |
833 | | | foreach my $dev (@results) { |
834 | | | |
835 | | | print " $dev:\n"; |
836 | | | |
837 | | | foreach $range ("1day","1week","1month","1year") { |
838 | | | my ($descr,$file,$build,$fullrange,$DATESTRING)=HotSaNICdiagram::get_diagram_properties($range); |
839 | | | |
840 | | | my $FILENAME="$OUTDIR/$dev-$file.$IMGFMT"; |
841 | | | |
842 | | | my $make=$FORCE; |
843 | | | if ($range eq "1h") { $make++; } |
844 | | | elsif (! -e "$FILENAME") { $make++; } |
845 | | | else { |
846 | | | my (undef,undef,undef,undef,undef,undef,undef,undef,undef,$mtime,undef,undef,undef) = stat( "$FILENAME" ); |
847 | | | if (time > ($mtime+$build)) { $make++; } |
848 | | | } |
849 | | | |
850 | | | if ($make>0) { |
851 | | | |
852 | | | my ($prints,$xs,$ys)=RRDs::graph $TEMPNAME, "-i", |
853 | | | "-s","-$range", "-w",$CONFIG{"WIDTH"}, "-h",$CONFIG{"HEIGHT"}, |
854 | | | "-u 2", "--alt-autoscale-max", "-l 0", "--title", "system-uptime - last $descr ($DATESTRING)", |
855 | | | "-a", uc($IMGFMT), |
856 | | | "DEF:up=rrd/$dev.rrd:up:AVERAGE", |
857 | | | "DEF:idle=rrd/$dev.rrd:idle:AVERAGE", |
858 | | | "AREA:up#00c000:uptime", |
859 | | | "GPRINT:up:MAX:(%1.2lf days)\\n", |
860 | | | "AREA:idle#aa0000:idle time", |
861 | | | "GPRINT:idle:MAX:(%1.2lf days)\\n", |
862 | | | "HRULE:0#000000"; |
863 | | | |
864 | | | rename $TEMPNAME,$FILENAME; |
865 | | | printf " %-7s %d"."x%d %s\n",$descr,$xs,$ys,$FILENAME; |
866 | | | |
867 | | | } |
868 | | | } |
869 | | | } |
870 | | | } |
871 | | | else { print " No database found\n Please check if the daemon is running.\n"; } |
872 | | | print "\n"; |
873 | | | } |