On 8 Jan 1999, Russell Nelson wrote:
> Is anybody using MRTG to track the performance of qmail? Any code
> they wish to share?
I use it just to track the number of message sent in the last 5
minutes (the MRTG cycle time).
I use qmailanalog-0.70 to grok the log. I also use daemontools to
monitor qmail and I use svc to get the pid of the process to add to
the mrtg output.
Attached is a PostScript dump of the web page.
Here's the mrtg config file:
###########################################################################
#---------------------------------------------------------------
# The directory where the log files, graph images and html files
# will be generated.
WorkDir: /proj/bisg/wwwind/Misc/Stats/Network
# The directory where the MRTG icons can be found. This directory is
# relative to the root of the web server. It must end with a slash.
IconDir: /Misc/Stats/Network/
#---------------------------------------------------------------
Target[mailq]: `/pkgs/mrtg-2.5.4c/scripts/mailq.pl`
Title[mailq]: Humpback Mail Traffic
PageTop[mailq]: <h1>Humpback Mail Traffic</h1>
MaxBytes[mailq]: 10000
YLegend[mailq]: Messages
ShortLegend[mailq]: Messages
Legend1[mailq]: delivered
Legend2[mailq]: queued
Legend3[mailq]: Max messages delivered
Legend4[mailq]: Max messages queued
LegendI[mailq]: delivered
LegendO[mailq]: queued
Options[mailq]: absolute nopercent gauge
WithPeak[mailq]: wmy
#---------------------------------------------------------------
###########################################################################
And here's the script that does the stat gathering:
###########################################################################
#!/pkgs/bin/perl
$now = time;
$then = $now - 300;
$tmp = "/tmp/mailq.$$";
open(LOG, "/var/log/mail");
open(ZOVERALL, "| /pkgs/bin/matchup 5>/dev/null | /pkgs/bin/zoverall > $tmp");
while(<LOG>)
{
@f = split(' ');
print ZOVERALL if $f[0] > $then;
}
close(LOG);
close(ZOVERALL);
open(TMP, "$tmp");
while(<TMP>)
{
chomp;
if (/^Completed messages:/)
{
@f = split(' ');
if (scalar @f == 1)
{
print "0\n";
}
else
{
print "$f[2]\n";
}
}
}
close(TMP);
unlink($tmp);
open(QSTAT, "/var/qmail/bin/qmail-qstat |");
while(<QSTAT>)
{
chomp;
if (/queue:/)
{
@f = split(' ');
print "$f[3]\n";
}
}
close(QSTAT);
open(UPTIME, "uptime | cut -c13- |");
while(<UPTIME>)
{
chomp;
$uptime = $_;
}
close(UPTIME);
print "$uptime</b> <br><br> The qmail-send process details are: <br> <tt><b>";
###########################################################################
open(PROCESS, "/var/qmail/bin/qmailq check |");
while(<PROCESS>)
{
chomp;
if (/not runn/)
{
print "$_</b></tt>";
last;
}
if (/UID/)
{
s/\s/ /g;
print "<br>$_<br>";
}
if (/qmails/)
{
s/\s/ /g;
print "$_</b></tt>";
last;
}
}
print "<br><br>The queued value should be close to zero during normal operation\n";
close(PROCESS);
open(UNAME, "uname -n |");
while(<UNAME>)
{
print;
}
close(UNAME);
###########################################################################
Regards
Peter
----------
Peter Samuel [EMAIL PROTECTED]
Technical Consultant or at present:
Uniq Professional Services, [EMAIL PROTECTED]
a division of X-Direct Pty Ltd
Phone: +61 2 9206 3410 Fax: +61 2 9281 1301
"If you kill all your unhappy customers, you'll only have happy ones left"
mailq.ps.gz