|
6
|
1 |
#!/bin/sh
|
|
|
2 |
|
|
|
3 |
# Check of qmail queue.
|
|
|
4 |
# Invocation:
|
|
|
5 |
# qmail-qstat-check <stat>
|
|
|
6 |
# where stat is one of:
|
|
|
7 |
# total
|
|
|
8 |
# unprocessed
|
|
|
9 |
#
|
|
|
10 |
# Put following into /etc/sudoers:
|
|
|
11 |
# zabbix ALL=(ALL) NOPASSWD: /var/qmail/bin/qmail-qstat
|
|
|
12 |
|
|
|
13 |
DIR="/tmp/zabbix"
|
|
|
14 |
REPORT=qstat
|
|
|
15 |
QSTAT="sudo /var/qmail/bin/qmail-qstat"
|
|
|
16 |
|
|
|
17 |
[ -d $DIR ] || mkdir -p $DIR
|
|
|
18 |
|
|
|
19 |
F=$DIR/$REPORT
|
|
|
20 |
|
|
|
21 |
find $DIR -name $REPORT -mmin +10 -exec rm '{}' \;
|
|
|
22 |
if [ ! -f $F ]; then
|
|
|
23 |
$QSTAT > $F.tmp || exit 1
|
|
|
24 |
mv $F.tmp $F
|
|
|
25 |
fi
|
|
|
26 |
|
|
|
27 |
if [ "x$1" = "xtotal" ]; then
|
|
|
28 |
head -1 $F | cut -d' ' -f4
|
|
|
29 |
fi
|
|
|
30 |
|
|
|
31 |
if [ "x$1" = "xunprocessed" ]; then
|
|
|
32 |
tail -1 $F | cut -d' ' -f8
|
|
|
33 |
fi
|