[mrtg] Re: mailq script needed
Tom Throckmorton
throck at hbs.edu
Thu Mar 15 15:37:46 MET 2001
Imran wrote:
> Now can any one have the script for the mailq statistics of sendmail using
> in mrtg??
You can find a simple perl script to count the messages in queue (as well as
some other useful scripts) from the Empire SystemEDGE Contrib Page:
#!/usr/local/bin/perl
# count ^qf files in the mail queue
# runs twice as fast as the sh(1) version
# this was just a 6 line script, but for backward compatibility with
# the sh version I have added some logic to get the default mqueue
# from /etc/sendmail.cf
# 1996-11-04 Kimmo Suominen (sh)
# 1997-09-03 Eric Hendrickson (perl)
# $Id: mqcnt.pl,v 1.2 1997/09/11 17:53:15 edh Exp $
use File::Basename; # for dirname()
use Getopt::Std;
($prog = $0) =~ s,.*/,,;
$usage = "usage: $prog [-C sendmail.cf] [mqueue]\n";
# accept -C for backward compatibility
getopts('C:') or die $usage;
$cf = $opt_C ? $opt_C : "/etc/sendmail.cf";
if ($ARGV[0]) { # command line
$mqueue = (-d $ARGV[0]) ? $ARGV[0] : dirname("$ARGV[0]");
} elsif (open CF, $cf) { # scan cf for mqueue
while (<CF>) {
if (/^OQ(.*)/||/^O QueueDirectory[\s+=](.*)/) {
$mqueue = $1;
last;
}
}
close CF;
}
$mqueue = "/var/spool/mqueue" unless $mqueue; # default to /var/spool/mqueue
opendir MQ, $mqueue;
print scalar (@da = grep /^qf/, readdir MQ), "\n";
close MQ;
--
Tom Throckmorton
Harvard Business School
ITG, Network Operations Center
throck at hbs.edu
--
Unsubscribe mailto:mrtg-request at list.ee.ethz.ch?subject=unsubscribe
Archive http://www.ee.ethz.ch/~slist/mrtg
FAQ http://faq.mrtg.org Homepage http://www.mrtg.org
WebAdmin http://www.ee.ethz.ch/~slist/lsg2.cgi
More information about the mrtg
mailing list