On Thu, Oct 07, 2004 at 04:44:14PM -0500, Ed McLain wrote:
> Here is an app that will give you 5 minute averages for connection to
> qpsmtpd through tcpserver. It's pretty straight forward and was written
> more for use with net-snmp so that I can graph usage using rrdtool to know
> when my mail servers are being loaded the most and so I can tell when I
> will need to add more. Let me know if anyones finds any errors or has any
> ideas to make it better.
>
> http://www.edmclain.com/?page=qpsmtpd
This code will fail when $min < 10:
$min =~ /([0-9])([0-9])/;
my $mf = $1;
my $ml = $2;
Try this instead (it's simpler and faster, too):
$mf = $min / 10;
$ml = $min % 10;
Also, this won't work: "if ( $hour =~ '00' )" because $hour is numeric,
and when stringified will become "0" but not "00". You can just do
"if ( $hour == 0 )" or even "if ($hour)". However this section as a
whole has a simpler replacement:
if ( $hour =~ '00' ) {
$hour = 23;
} else {
$hour = $hour - 1;
}
Can be replaced by "$hour = ($hour - 1) % 24;"
Finally, you should make the first line "#!/usr/bin/perl -w" to
help catch errors in your code.
Hope that helps,
Andrew
--
mailto:[EMAIL PROTECTED] Andrew Pam
http://www.xanadu.com.au/ Chief Scientist, Xanadu
http://www.glasswings.com.au/ Partner, Glass Wings
http://www.sericyb.com.au/ Manager, Serious Cybernetics