[mrtg] Re: mailq script needed
Larry Sheldon
lsheldon at creighton.edu
Thu Mar 15 13:05:45 MET 2001
> Now can any one have the script for the mailq statistics of sendmail using
> in mrtg??
Here is what I use:
/usr/local/bin/mailq-gauge
----------------------------------cut here---------------------------------
#!/usr/bin/ksh
echo " gauge running at `date`"
#
# Gadget to prepare a file in "mrtg" format showing the depth of the
# mail queue for reporting by "mrtg" on "bluejay".
#
#
line1=`ls /var/spool/mqueue | grep ^qf | wc -l` # Current queue item count
line2=`ps -ef | grep sendmail | grep -v grep | wc -l` # No. of copies running
line3="Not Available" # "up" time
line4=`uname -n` # Whose data is it?
echo ${line1} > /jaynet/mrtg/data-transfers/bj-mail-queue-size
echo ${line2} >> /jaynet/mrtg/data-transfers/bj-mail-queue-size
echo ${line3} >> /jaynet/mrtg/data-transfers/bj-mail-queue-size
echo ${line4} >> /jaynet/mrtg/data-transfers/bj-mail-queue-size
chmod 644 /jaynet/mrtg/data-transfers/bj-mail-queue-size
#
# Expansion of the gadget to prepare a second file in "mrtg" format showing
# the mail traffic to and from "mailjay" (failing for the moment to
# account for mail originating on, or being delivered to "mailjay").
# The interpretive assumtion is that all mail received will be re-transmited,
# and all mail transmitted came from somewhere else. This is not actually
# true, but at this point I have not looked to see waht the local traffic
# is, but it there turns out to be very much, I will have to account for it.
#
# Since we now have a "sendmail" that reports a "total", that is all that
# seems very interesting. Turned the rest off to save CPU cycles.
#
# This next section develops information about the number of messages
# handled, the following section extract the number of bytes handled.
#
#line1=`mailstats | grep '^ 4' |sed 's/^\ //g' | sed 's/\ \ */ /g' | cut -d\ -f 2 | sed 's/K/000/'` # messages in
#line2=`mailstats | grep '^ 4' |sed 's/^\ //g' | sed 's/\ \ */ /g' | cut -d\ -f 4 | sed 's/K/000/'` # messages out
#echo ${line1} > /jaynet/mrtg/data-transfers/bj-mail-msg-traffic
#echo ${line2} >> /jaynet/mrtg/data-transfers/bj-mail-msg-traffic
#echo ${line3} >> /jaynet/mrtg/data-transfers/bj-mail-msg-traffic
#echo ${line4} >> /jaynet/mrtg/data-transfers/bj-mail-msg-traffic
#chmod 644 /jaynet/mrtg/data-transfers/bj-mail-msg-traffic
##
## This developes the volume data--number of bytes handled.
##
#line1=`mailstats | grep '^ 4' |sed 's/^\ //g' | sed 's/\ \ */ /g' | cut -d\ -f 3 | sed 's/K/000/'` # messages in
#line2=`mailstats | grep '^ 4' |sed 's/^\ //g' | sed 's/\ \ */ /g' | cut -d\ -f 5 | sed 's/K/000/'` # messages out
#echo ${line1} > /jaynet/mrtg/data-transfers/bj-mail-msg-volume
#echo ${line2} >> /jaynet/mrtg/data-transfers/bj-mail-msg-volume
#echo ${line3} >> /jaynet/mrtg/data-transfers/bj-mail-msg-volume
#echo ${line4} >> /jaynet/mrtg/data-transfers/bj-mail-msg-volume
#chmod 644 /jaynet/mrtg/data-transfers/bj-mail-msg-volume
##
## Now do the same two steps for the local mail traffic
##
#line1=`mailstats | grep '^ 3' |sed 's/^\ //g' | sed 's/\ \ */ /g' | cut -d\ -f 2 | sed 's/K/000/'` # messages in
#line2=`mailstats | grep '^ 3' |sed 's/^\ //g' | sed 's/\ \ */ /g' | cut -d\ -f 4 | sed 's/K/000/'` # messages out
#echo ${line1} > /jaynet/mrtg/data-transfers/bj-mail-msg-traffic-local
#echo ${line2} >> /jaynet/mrtg/data-transfers/bj-mail-msg-traffic-local
#echo ${line3} >> /jaynet/mrtg/data-transfers/bj-mail-msg-traffic-local
#echo ${line4} >> /jaynet/mrtg/data-transfers/bj-mail-msg-traffic-local
#chmod 644 /jaynet/mrtg/data-transfers/bj-mail-msg-traffic-local
##
## This developes the volume data--number of bytes handled.
##
#line1=`mailstats | grep '^ 3' |sed 's/^\ //g' | sed 's/\ \ */ /g' | cut -d\ -f 3 | sed 's/K/000/'` # messages in
#line2=`mailstats | grep '^ 3' |sed 's/^\ //g' | sed 's/\ \ */ /g' | cut -d\ -f 5 | sed 's/K/000/'` # messages out
#echo ${line1} > /jaynet/mrtg/data-transfers/bj-mail-msg-volume-local
#echo ${line2} >> /jaynet/mrtg/data-transfers/bj-mail-msg-volume-local
#echo ${line3} >> /jaynet/mrtg/data-transfers/bj-mail-msg-volume-local
#echo ${line4} >> /jaynet/mrtg/data-transfers/bj-mail-msg-volume-local
#chmod 644 /jaynet/mrtg/data-transfers/bj-mail-msg-volume-local
##
## Now do the same two steps for the "program" mail traffic
##
#line1=`mailstats | grep '^ 0' |sed 's/^\ //g' | sed 's/\ \ */ /g' | cut -d\ -f 2 | sed 's/K/000/'` # messages in
#line2=`mailstats | grep '^ 0' |sed 's/^\ //g' | sed 's/\ \ */ /g' | cut -d\ -f 4 | sed 's/K/000/'` # messages out
#echo ${line1} > /jaynet/mrtg/data-transfers/bj-mail-msg-traffic-program
#echo ${line2} >> /jaynet/mrtg/data-transfers/bj-mail-msg-traffic-program
#echo ${line3} >> /jaynet/mrtg/data-transfers/bj-mail-msg-traffic-program
#echo ${line4} >> /jaynet/mrtg/data-transfers/bj-mail-msg-traffic-program
#chmod 644 /jaynet/mrtg/data-transfers/bj-mail-msg-traffic-program
##
## This developes the volume data--number of bytes handled.
##
#line1=`mailstats | grep '^ 0' |sed 's/^\ //g' | sed 's/\ \ */ /g' | cut -d\ -f 3 | sed 's/K/000/'` # messages in
#line2=`mailstats | grep '^ 0' |sed 's/^\ //g' | sed 's/\ \ */ /g' | cut -d\ -f 5 | sed 's/K/000/'` # messages out
#echo ${line1} > /jaynet/mrtg/data-transfers/bj-mail-msg-volume-program
#echo ${line2} >> /jaynet/mrtg/data-transfers/bj-mail-msg-volume-program
#echo ${line3} >> /jaynet/mrtg/data-transfers/bj-mail-msg-volume-program
#echo ${line4} >> /jaynet/mrtg/data-transfers/bj-mail-msg-volume-program
#chmod 644 /jaynet/mrtg/data-transfers/bj-mail-msg-volume-program
#
# Now do the same two steps for the "Total" mail traffic
#
line1=`mailstats | grep '^ T' |sed 's/^\ //g' | sed 's/\ \ */ /g' | cut -d\ -f 2 | sed 's/K/000/'` # messages in
line2=`mailstats | grep '^ T' |sed 's/^\ //g' | sed 's/\ \ */ /g' | cut -d\ -f 4 | sed 's/K/000/'` # messages out
echo ${line1} > /jaynet/mrtg/data-transfers/bj-mail-msg-traffic-total
echo ${line2} >> /jaynet/mrtg/data-transfers/bj-mail-msg-traffic-total
echo ${line3} >> /jaynet/mrtg/data-transfers/bj-mail-msg-traffic-total
echo ${line4} >> /jaynet/mrtg/data-transfers/bj-mail-msg-traffic-total
chmod 644 /jaynet/mrtg/data-transfers/bj-mail-msg-traffic-total
#
# This developes the volume data--number of bytes handled.
#
line1=`mailstats | grep '^ T' |sed 's/^\ //g' | sed 's/\ \ */ /g' | cut -d\ -f 3 | sed 's/K/000/'` # messages in
line2=`mailstats | grep '^ T' |sed 's/^\ //g' | sed 's/\ \ */ /g' | cut -d\ -f 5 | sed 's/K/000/'` # messages out
echo ${line1} > /jaynet/mrtg/data-transfers/bj-mail-msg-volume-total
echo ${line2} >> /jaynet/mrtg/data-transfers/bj-mail-msg-volume-total
echo ${line3} >> /jaynet/mrtg/data-transfers/bj-mail-msg-volume-total
echo ${line4} >> /jaynet/mrtg/data-transfers/bj-mail-msg-volume-total
chmod 644 /jaynet/mrtg/data-transfers/bj-mail-msg-volume-total
--------------------------cut here---------------------------------------
This is run by "cron" every five minutes--the MRTG target "cats" the
appropriate file a minute or two later (on a different machine, the
file-system "/jaynet" is NFS-mounted on all of our systems).
--
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
. .
- L. F. (Larry) Sheldon, Jr. -
. Unix Systems and Network Administration .
- Creighton University Computer Center-Old Gym -
. 2500 California Plaza .
- Omaha, Nebraska, U.S.A. 68178 Two identifying characteristics -
. lsheldon at creighton.edu of System Administrators: .
- 402 280-2254 (work) Infallibility, and the ability to -
. 402 681-4726 (cellular) learn from their mistakes. .
- 402 332-4622 (residence) -
. http://www.creighton.edu/~lsheldon Adapted from Stephen Pinker .
-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-.-
--
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