'GPRINT:qry_avg:LAST:%5.1lf%s Last',
'GPRINT:qry_avg_sum:LAST:(ca. %5.1lf%sB Total)\l'
],
+ email => [
+ 'DEF:avg={file}:count:AVERAGE',
+ 'DEF:min={file}:count:MIN',
+ 'DEF:max={file}:count:MAX',
+ "AREA:max#$HalfMagenta",
+ "AREA:min#$Canvas",
+ "LINE1:avg#$FullMagenta:Count ",
+ 'GPRINT:min:MIN:%4.1lf Min,',
+ 'GPRINT:avg:AVERAGE:%4.1lf Avg,',
+ 'GPRINT:max:MAX:%4.1lf Max,',
+ 'GPRINT:avg:LAST:%4.1lf Last\l'
+ ],
+ email_size => [
+ 'DEF:avg={file}:size:AVERAGE',
+ 'DEF:min={file}:size:MIN',
+ 'DEF:max={file}:size:MAX',
+ "AREA:max#$HalfMagenta",
+ "AREA:min#$Canvas",
+ "LINE1:avg#$FullMagenta:Count ",
+ 'GPRINT:min:MIN:%4.1lf Min,',
+ 'GPRINT:avg:AVERAGE:%4.1lf Avg,',
+ 'GPRINT:max:MAX:%4.1lf Max,',
+ 'GPRINT:avg:LAST:%4.1lf Last\l'
+ ],
+ spam_score => [
+ 'DEF:avg={file}:score:AVERAGE',
+ 'DEF:min={file}:score:MIN',
+ 'DEF:max={file}:score:MAX',
+ "AREA:max#$HalfMagenta",
+ "AREA:min#$Canvas",
+ "LINE1:avg#$FullMagenta:Count ",
+ 'GPRINT:min:MIN:%4.1lf Min,',
+ 'GPRINT:avg:AVERAGE:%4.1lf Avg,',
+ 'GPRINT:max:MAX:%4.1lf Max,',
+ 'GPRINT:avg:LAST:%4.1lf Last\l'
+ ],
+ spam_check => [
+ 'DEF:avg={file}:hits:AVERAGE',
+ 'DEF:min={file}:hits:MIN',
+ 'DEF:max={file}:hits:MAX',
+ "AREA:max#$HalfMagenta",
+ "AREA:min#$Canvas",
+ "LINE1:avg#$FullMagenta:Count ",
+ 'GPRINT:min:MIN:%4.1lf Min,',
+ 'GPRINT:avg:AVERAGE:%4.1lf Avg,',
+ 'GPRINT:max:MAX:%4.1lf Max,',
+ 'GPRINT:avg:LAST:%4.1lf Last\l'
+ ],
fanspeed => [
'DEF:temp_avg={file}:value:AVERAGE',
'DEF:temp_min={file}:value:MIN',
'GPRINT:temp_max:MAX:%4.1lf Max,',
'GPRINT:temp_avg:LAST:%4.1lf Last\l'
],
+ irq => ['DEF:irq_avg={file}:irq:AVERAGE',
+ 'DEF:irq_min={file}:irq:MIN',
+ 'DEF:irq_max={file}:irq:MAX',
+ "AREA:irq_max#$HalfBlue",
+ "AREA:irq_min#$Canvas",
+ "LINE1:irq_avg#$FullBlue:Interrupts",
+ 'GPRINT:irq_min:MIN:%5.1lf Min,',
+ 'GPRINT:irq_avg:AVERAGE:%5.1lf Avg,',
+ 'GPRINT:irq_max:MAX:%5.1lf Max,',
+ 'GPRINT:irq_avg:LAST:%5.1lf Last'],
if_packets => ['DEF:tx_min={file}:tx:MIN',
'DEF:tx_avg={file}:tx:AVERAGE',
'DEF:tx_max={file}:tx:MAX',
'GPRINT:read_avg:AVERAGE:%5.1lf Avg,',
'GPRINT:read_avg:LAST:%5.1lf Last\l'
],
+ opcode => [
+ 'DEF:avg={file}:value:AVERAGE',
+ 'DEF:min={file}:value:MIN',
+ 'DEF:max={file}:value:MAX',
+ "AREA:max#$HalfBlue",
+ "AREA:min#$Canvas",
+ "LINE1:avg#$FullBlue:Queries/s",
+ 'GPRINT:min:MIN:%9.3lf Min,',
+ 'GPRINT:avg:AVERAGE:%9.3lf Average,',
+ 'GPRINT:max:MAX:%9.3lf Max,',
+ 'GPRINT:avg:LAST:%9.3lf Last\l'
+ ],
partition => [
"DEF:rbyte_avg={file}:rbytes:AVERAGE",
"DEF:rbyte_min={file}:rbytes:MIN",
df => ['-t', '{host}:{inst} usage', '-v', 'Percent', '-l', '0'],
disk => ['-t', '{host} disk {inst} usage', '-v', 'Byte/s'],
dns_traffic => ['-t', '{host} DNS traffic', '-v', 'Bit/s'],
+ email => ['-t', '{host} E-Mail {inst} count', '-v', 'E-Mails'],
+ email_size => ['-t', '{host} E-Mail {inst} size', '-v', 'Bytes'],
+ spam_score => ['-t', '{host} spam score', '-v', 'score'],
+ spam_check => ['-t', '{host} spam checks {inst}', '-v', 'hits'],
fanspeed => ['-t', '{host} fanspeed {inst}', '-v', 'RPM'],
frequency_offset => ['-t', 'NTPd frequency offset ({inst})', '-v', 'Parts per million'],
hddtemp => ['-t', '{host} hdd temperature {inst}', '-v', '°Celsius'],
+ irq => ['-t', '{host} Interrupts {inst}', '-v', 'Ints/s'],
if_errors => ['-t', '{host} {inst} errors', '-v', 'Errors/s'],
if_packets => ['-t', '{host} {inst} packets', '-v', 'Packets/s'],
load => ['-t', '{host} load average', '-v', 'System load', '-X', '0'],
mysql_qcache => ['-t', 'mysql query cache', '-v', 'Queries/s' ],
mysql_threads => ['-t', 'mysql threads', '-v', 'Threads' ],
nfs3_procedures => ['-t', '{host} NFSv3 {inst} procedures', '-v', 'Procedures/s' ],
+ opcode => ['-t', 'OpCode {inst}', '-v', 'Queries/s'],
partition => ['-t', '{host} partition {inst} usage', '-v', 'Byte/s'],
ping => ['-t', '{host} ping to {inst}', '-v', 'ms'],
processes => ['-t', '{host} processes', '-v', 'Processes'],
cpu => \&output_graph_cpu,
cpufreq => 1,
disk => 1,
+ email => \&output_graph_email_count,
+ email_size => \&output_graph_email_size,
+ irq => \&output_graph_irq,
+ spam_score => 1,
+ spam_check => \&output_graph_spam_check,
load => 0,
mails => 0,
memory => 0,
return (@ret);
}
+sub output_graph_irq
+{
+ my @inst = sort { $a <=> $b } @_;
+ my @ret = ();
+
+ die if (@inst < 2);
+
+ my @colors = get_n_colors (scalar (@inst));
+
+ for (my $i = 0; $i < scalar (@inst); $i++)
+ {
+ my $inst = $inst[$i];
+ push (@ret,
+ "DEF:avg_$i=$AbsDir/irq-$inst.rrd:irq:AVERAGE",
+ "DEF:min_$i=$AbsDir/irq-$inst.rrd:irq:MIN",
+ "DEF:max_$i=$AbsDir/irq-$inst.rrd:irq:MAX");
+ }
+
+ for (my $i = 0; $i < scalar (@inst); $i++)
+ {
+ my $inst = $inst[$i];
+ my $color = $colors[$i];
+
+ if (length ($inst) > 15)
+ {
+ $inst = substr ($inst, 0, 12) . '...';
+ }
+ else
+ {
+ $inst = sprintf ('%-15s', $inst);
+ }
+
+ push (@ret,
+ "LINE1:avg_$i#$color:$inst",
+ "GPRINT:min_$i:MIN:%5.1lf Min,",
+ "GPRINT:avg_$i:AVERAGE:%5.1lf Avg,",
+ "GPRINT:max_$i:MAX:%5.1lf Max,",
+ "GPRINT:avg_$i:LAST:%5.1lf Last\\l");
+ }
+
+ return (@ret);
+}
+
+sub output_graph_email_count
+{
+ my @inst = @_;
+ my @ret = ();
+
+ my $c = scalar @inst;
+
+ my @colors = get_n_colors ($c);
+
+ for (my $i = 0; $i < $c; ++$i) {
+ push @ret,
+ "DEF:min_$i=$AbsDir/email-$inst[$i].rrd:count:MIN",
+ "DEF:avg_$i=$AbsDir/email-$inst[$i].rrd:count:AVERAGE",
+ "DEF:max_$i=$AbsDir/email-$inst[$i].rrd:count:MAX";
+ }
+
+ for (my $i = 0; $i < $c; ++$i) {
+ my $s = "";
+
+ if (length $inst[$i] > 10) {
+ $s = substr ($inst[$i], 0, 7) . '...';
+ }
+ else {
+ $s = sprintf '%-10s', $inst[$i];
+ }
+
+ push @ret,
+ "LINE1:avg_$i#$colors[$i]:$s",
+ "GPRINT:min_$i:MIN:%4.1lf Min,",
+ "GPRINT:avg_$i:AVERAGE:%4.1lf Avg,",
+ "GPRINT:max_$i:MAX:%4.1lf Max,",
+ "GPRINT:avg_$i:LAST:%4.1lf Last\\l";
+ }
+ return @ret;
+}
+
+sub output_graph_email_size
+{
+ my @inst = @_;
+ my @ret = ();
+
+ my $c = scalar @inst;
+
+ my @colors = get_n_colors ($c);
+
+ for (my $i = 0; $i < $c; ++$i) {
+ push @ret,
+ "DEF:min_$i=$AbsDir/email_size-$inst[$i].rrd:size:MIN",
+ "DEF:avg_$i=$AbsDir/email_size-$inst[$i].rrd:size:AVERAGE",
+ "DEF:max_$i=$AbsDir/email_size-$inst[$i].rrd:size:MAX";
+ }
+
+ for (my $i = 0; $i < $c; ++$i) {
+ my $s = "";
+
+ if (length $inst[$i] > 10) {
+ $s = substr ($inst[$i], 0, 7) . '...';
+ }
+ else {
+ $s = sprintf '%-10s', $inst[$i];
+ }
+
+ push @ret,
+ "LINE1:avg_$i#$colors[$i]:$s",
+ "GPRINT:min_$i:MIN:%4.1lf Min,",
+ "GPRINT:avg_$i:AVERAGE:%4.1lf Avg,",
+ "GPRINT:max_$i:MAX:%4.1lf Max,",
+ "GPRINT:avg_$i:LAST:%4.1lf Last\\l";
+ }
+ return @ret;
+}
+
+sub output_graph_spam_check
+{
+ my @inst = sort @_;
+ my @ret = ();
+
+ my $c = scalar @inst;
+
+ my @colors = get_n_colors ($c);
+
+ for (my $i = 0; $i < $c; ++$i) {
+ push @ret,
+ "DEF:min_$i=$AbsDir/spam_check-$inst[$i].rrd:hits:MIN",
+ "DEF:avg_$i=$AbsDir/spam_check-$inst[$i].rrd:hits:AVERAGE",
+ "DEF:max_$i=$AbsDir/spam_check-$inst[$i].rrd:hits:MAX";
+ }
+
+ for (my $i = 0; $i < $c; ++$i) {
+ my $s = "";
+
+ if (length $inst[$i] > 25) {
+ $s = substr ($inst[$i], 0, 22) . '...';
+ }
+ else {
+ $s = sprintf '%-25s', $inst[$i];
+ }
+
+ push @ret,
+ "LINE1:avg_$i#$colors[$i]:$s",
+ "GPRINT:min_$i:MIN:%4.1lf Min,",
+ "GPRINT:avg_$i:AVERAGE:%4.1lf Avg,",
+ "GPRINT:max_$i:MAX:%4.1lf Max,",
+ "GPRINT:avg_$i:LAST:%4.1lf Last\\l";
+ }
+ return @ret;
+}
+
sub output_graph_mysql_commands
{
my @inst = @_;
</head>
<body>
+ <script type="text/javascript">
+ var lastUpdateHour = (new Date ()).getTime () / 1000;
+ var lastUpdateDay = lastUpdateHour;
+ var lastUpdateWeek = lastUpdateHour;
+ var lastUpdateMonth = lastUpdateHour;
+ var lastUpdateYear = lastUpdateHour;
+
+ function exchangeImages (origImg, newImg)
+ {
+ var parent = origImg.parentNode;
+
+ if (!newImg.complete)
+ setTimeout (function () { exchangeImages (origImg, newImg); }, 100);
+ else
+ parent.replaceChild (newImg, origImg);
+ }
+
+ function updateImage (origImg)
+ {
+ var imgSrc = origImg.src;
+ var newImg = new Image (origImg.width, origImg.height);
+ var now = (new Date ()).getTime () / 1000;
+
+ imgSrc = imgSrc.replace (/\\?.*/, "");
+ imgSrc = imgSrc + "?update=" + now;
+
+ newImg.className = origImg.className;
+ newImg.src = imgSrc;
+
+ exchangeImages (origImg, newImg);
+ } /* updateImage */
+
+ function updateImageClass (className)
+ {
+ var elems = document.getElementsByTagName ("img");
+ for (var i = 0; i < elems.length; i++)
+ {
+ var img = elems[i];
+ if (img.className != className)
+ continue;
+ updateImage (img);
+ }
+ } /* updateImageClass */
+
+ function doUpdate ()
+ {
+ var now = (new Date ()).getTime () / 1000;
+ if ((now - lastUpdateHour) >= 10)
+ {
+ updateImageClass ("hour");
+ lastUpdateHour = 0 + now;
+ }
+ if ((now - lastUpdateDay) >= 120)
+ {
+ updateImageClass ("day");
+ lastUpdateDay = now;
+ }
+ if ((now - lastUpdateWeek) >= 600)
+ {
+ updateImageClass ("week");
+ lastUpdateWeek = now;
+ }
+ if ((now - lastUpdateMonth) >= 3600)
+ {
+ updateImageClass ("month");
+ lastUpdateMonth = now;
+ }
+ if ((now - lastUpdateYear) >= 7200)
+ {
+ updateImageClass ("year");
+ lastUpdateYear = now;
+ }
+ } /* doUpdate */
+
+ /* It's important to save this variable */
+ var updateInterval = window.setInterval ("doUpdate ()", 10000);
+ </script>
HEADER
my $MySelf = defined ($ENV{'GATEWAY_INTERFACE'}) ? $ENV{'SCRIPT_NAME'} : $0;
print qq(\t\t<div><a href="$MySelf$RelDir">Go up</a></div>\n);
print "\t\t<ul>\n";
- for (@{$files->{$Type}})
+ for (sort { $a <=> $b } @{$files->{$Type}})
{
print qq(\t\t\t<li><a href="$MySelf$RelDir/$Type/$_">$_</a></li>\n);
}
</ul>
<h3>Hourly</h3>
- <div><img src="$MySelf$RelDir/$Type/hour" /></div>
+ <div><img src="$MySelf$RelDir/$Type/hour" class="hour" /></div>
<h3>Daily</h3>
- <div><img src="$MySelf$RelDir/$Type/day" /></div>
+ <div><img src="$MySelf$RelDir/$Type/day" class="day" /></div>
<h3>Weekly</h3>
- <div><img src="$MySelf$RelDir/$Type/week" /></div>
+ <div><img src="$MySelf$RelDir/$Type/week" class="week" /></div>
<h3>Monthly</h3>
- <div><img src="$MySelf$RelDir/$Type/month" /></div>
+ <div><img src="$MySelf$RelDir/$Type/month" class="month" /></div>
<h3>Yearly</h3>
- <div><img src="$MySelf$RelDir/$Type/year" /></div>
+ <div><img src="$MySelf$RelDir/$Type/year" class="year" /></div>
HTML
}
elsif (length ($Type) != 0)
print <<HTML;
<h3>Hourly</h3>
- <div><img src="$MySelf$RelDir/$ext/hour" /></div>
+ <div><img src="$MySelf$RelDir/$ext/hour" class="hour" /></div>
<h3>Daily</h3>
- <div><img src="$MySelf$RelDir/$ext/day" /></div>
+ <div><img src="$MySelf$RelDir/$ext/day" class="day" /></div>
<h3>Weekly</h3>
- <div><img src="$MySelf$RelDir/$ext/week" /></div>
+ <div><img src="$MySelf$RelDir/$ext/week" class="week" /></div>
<h3>Monthly</h3>
- <div><img src="$MySelf$RelDir/$ext/month" /></div>
+ <div><img src="$MySelf$RelDir/$ext/month" class="month" /></div>
<h3>Yearly</h3>
- <div><img src="$MySelf$RelDir/$ext/year" /></div>
+ <div><img src="$MySelf$RelDir/$ext/year" class="year" /></div>
HTML
}
else
if (ref ($GraphMulti->{$type}) eq 'CODE')
{
print qq(\t\t<a href="$MySelf$RelDir/$type" />),
- qq(<img src="$MySelf$RelDir/$type/day" /></a>\n);
+ qq(<img src="$MySelf$RelDir/$type/day" class="day" /></a>\n);
next;
}
if (length ($inst))
{
print qq(\t\t<a href="$MySelf$RelDir/$type/$inst" />),
- qq(<img src="$MySelf$RelDir/$type/$inst/day" /></a>\n);
+ qq(<img src="$MySelf$RelDir/$type/$inst/day" class="day" /></a>\n);
}
else
{
print qq(\t\t<a href="$MySelf$RelDir/$type" />),
- qq(<img src="$MySelf$RelDir/$type/day" /></a>\n);
+ qq(<img src="$MySelf$RelDir/$type/day" class="day" /></a>\n);
}
}
}