1 |
tdb |
1.1 |
#!/usr/local/bin/perl -w |
2 |
|
|
|
3 |
|
|
$| = 1; |
4 |
|
|
|
5 |
|
|
use strict; |
6 |
|
|
|
7 |
|
|
my(@rrdlist) = `ls *.rrd`; |
8 |
|
|
|
9 |
|
|
foreach my $rrd (@rrdlist) { |
10 |
|
|
chop $rrd; |
11 |
|
|
if($rrd =~ /^(\d+)_0\.rrd$/) { |
12 |
|
|
my($baserrd) = $1; |
13 |
|
|
my($def) = ""; |
14 |
|
|
my($line) = ""; |
15 |
|
|
my($i) = 0; |
16 |
|
|
while( -f "$baserrd\_$i.rrd" ) { |
17 |
|
|
print "rrd: $baserrd $i\n"; |
18 |
|
|
$def = $def . "DEF:size$i=$baserrd\_$i.rrd:size:MAX "; |
19 |
|
|
$line = $line . "LINE2:size$i" . &get_colour($i) .":\"queue$i size\" "; |
20 |
|
|
++$i; |
21 |
|
|
} |
22 |
|
|
$def = $def . "DEF:total=$baserrd\_0.rrd:total:AVERAGE"; |
23 |
|
|
$line = $line . "LINE2:total#FF0000:\"packets/sec - currently\""; |
24 |
|
|
my($comment) = `cat $baserrd.def` if -f "$baserrd.def"; |
25 |
|
|
chop $comment; |
26 |
|
|
my($info) = "--title \"$comment\" --imgformat PNG"; |
27 |
|
|
my($legend) = "GPRINT:total:LAST:\"%lf %spackets/sec\""; |
28 |
|
|
my($cmd) = "$info $def $line $legend"; |
29 |
|
|
my($init); |
30 |
|
|
# 3h graph |
31 |
|
|
$init = "rrdtool graph $baserrd-3h.png --start -10800 --lower-limit 0"; |
32 |
|
|
print `$init $cmd`; |
33 |
|
|
# 1d graph |
34 |
|
|
$init = "rrdtool graph $baserrd-1d.png --start -86400 --lower-limit 0"; |
35 |
|
|
print `$init $cmd`; |
36 |
|
|
# 1w graph |
37 |
|
|
$init = "rrdtool graph $baserrd-1w.png --start -604800 --lower-limit 0"; |
38 |
|
|
print `$init $cmd`; |
39 |
|
|
# 1m graph |
40 |
|
|
$init = "rrdtool graph $baserrd-1m.png --start -2678400 --lower-limit 0"; |
41 |
|
|
print `$init $cmd`; |
42 |
|
|
} |
43 |
|
|
} |
44 |
|
|
|
45 |
|
|
sub get_colour { |
46 |
|
|
my($col) = @_; |
47 |
|
|
if($col == 0) { |
48 |
|
|
return "#0000FF"; |
49 |
|
|
} |
50 |
|
|
elsif($col == 1) { |
51 |
|
|
return "#00FF00"; |
52 |
|
|
} |
53 |
|
|
elsif($col == 2) { |
54 |
|
|
return "#FF00FF"; |
55 |
|
|
} |
56 |
|
|
elsif($col == 3) { |
57 |
|
|
return "#FFFF00"; |
58 |
|
|
} |
59 |
|
|
elsif($col == 4) { |
60 |
|
|
return "#00FFFF"; |
61 |
|
|
} |
62 |
|
|
else { |
63 |
|
|
return "#000066"; |
64 |
|
|
} |
65 |
|
|
} |