Best way to measure sendmail queue depth?

Julian Field MailScanner at ecs.soton.ac.uk
Fri Jun 30 17:16:38 IST 2006


On 30 Jun 2006, at 16:49, Greg Matthews wrote:

> Furnish, Trever G wrote:
>> I've been checking sendmail inbound queue depth using a simple  
>> readdir
>> and dividing the number of entries by two.  This is checked every  
>> five
>> minutes by Nagios with a 10-second timeout -- because of the  
>> timeout and
>> the frequency with which I want to do the check, I can't just use,  
>> for
>> example:
>>      mailq |head -1
>>  ...because under heavy flow conditions the mailq command takes  
>> WAY too
>> long to parse the entire set of queue files and generates too much  
>> load.
>>  I always realized dividing the number of files in the queue by  
>> two was
>> only a rough guess, but I didn't realize there could be so much
>> disparity between that number and the number of messages listed by
>> mailq.  With mailq reporting 6 messages in the inbound queue, the
>> directory actually contains 477 files!
>>  Mailq's result seems to match the count of files starting with a
>> lowercase "q".  I also have about the same number of files  
>> starting with
>> an uppercase "Q".  The rest of the files are df files, most of them
>> without any corresponding q file.
>
> I've reported a steadily growing in-queue here before and it is  
> these "orphaned" df files that are the culprit. I have made sure my  
> systems use the posix file locking as suggested but still I see a  
> steady increase in the number of orphaned data files. I use the  
> attached script to get rid of them. This script does more than just  
> check for the age of the file, it also checks whether it really is  
> orphaned. It also doesnt remove files outright, just moves them. If  
> the directory you move them to is on the same partition, this  
> operation is lightening fast (if that is important - personally, I  
> have seperate /var and /var/spool partitions).
>
> The stopping and starting of MailScanner is probably unnecessarily  
> paranoid.

You don't need to restart MailScanner after playing with the queues,  
it should be happy to run "live". But you could kill -STOP and then  
kill -CONT it if you are wary.

>
>>  Any idea what's going on?  Previously I expected to find files that
>> started with qf, df, xf, and tf (not Q), and to always have pairs of
>> files.  Obviously my expectation was pretty far off. :-)
>>  --
>> Trever
>
>
> -- 
> Greg Matthews           01491 692445
> Head of UNIX/Linux, iTSS Wallingford
>
> -- 
> This message (and any attachments) is for the recipient only. NERC
> is subject to the Freedom of Information Act 2000 and the contents
> of this email and any reply you make may be disclosed by NERC unless
> it is exempt from release under the Act. Any material supplied to
> NERC may be stored in an electronic records management system.
>
> #!/bin/bash
> # clean up orphaned df* files in mqueue.in
> # no known cause for these files yet.
>
> /etc/init.d/MailScanner stop
>
> sleep 2
> dir="/var/spool/mqueue.in"
>
> file=`find $dir -mtime +1`
> for i in ${file}
>     do m=`basename ${i}`
>     j=${m:2}
>     if [ ! -e "${dir}/qf${j}" ]; then
> 	mv ${i} /var/tmp/
> 	fi
>     done
> echo
> df -hl
>
> /etc/init.d/MailScanner start
>
> exit 0
> -- 
> MailScanner mailing list
> mailscanner at lists.mailscanner.info
> http://lists.mailscanner.info/mailman/listinfo/mailscanner
>
> Before posting, read http://wiki.mailscanner.info/posting
>
> Support MailScanner development - buy the book off the website!

-- 
Julian Field
MailScanner at ecs.soton.ac.uk



-- 
This message has been scanned for viruses and
dangerous content by MailScanner, and is
believed to be clean.
MailScanner thanks transtec Computers for their support.



More information about the MailScanner mailing list