scripts/qmail-qstat-check
author Tomas Zeman <tzeman@volny.cz>
Fri, 07 Sep 2012 11:14:29 +0200
changeset 19 08238959d9fc
parent 6 283c9818387c
permissions -rwxr-xr-x
scripts/domain-check by Matty (http://www.cyberciti.biz/files/scripts/domain-check-2.txt)

#!/bin/sh

# Check of qmail queue.
# Invocation:
# qmail-qstat-check <stat>
#	where stat is one of:
#		total
#		unprocessed
#
# Put following into /etc/sudoers:
# zabbix  ALL=(ALL) NOPASSWD: /var/qmail/bin/qmail-qstat

DIR="/tmp/zabbix"
REPORT=qstat
QSTAT="sudo /var/qmail/bin/qmail-qstat"

[ -d $DIR ] || mkdir -p $DIR

F=$DIR/$REPORT

find $DIR -name $REPORT -mmin +10 -exec rm '{}' \;
if [ ! -f $F ]; then
	$QSTAT > $F.tmp || exit 1
	mv $F.tmp $F
fi

if [ "x$1" = "xtotal" ]; then
	head -1 $F | cut -d' ' -f4
fi

if [ "x$1" = "xunprocessed" ]; then
	tail -1 $F | cut -d' ' -f8
fi