Added mailQWatch.sh for mailq reporting
Updated README.md with instructions
This commit is contained in:
parent
b323ab96db
commit
bb95025e81
20
README.md
Normal file → Executable file
20
README.md
Normal file → Executable file
@ -98,3 +98,23 @@ Script sends an email with the rkhunter scan and report.
|
|||||||
apt-get install rkhunter
|
apt-get install rkhunter
|
||||||
ln -s ${PWD}/rkhunter.sh /etc/cron.daily
|
ln -s ${PWD}/rkhunter.sh /etc/cron.daily
|
||||||
</code></pre>
|
</code></pre>
|
||||||
|
|
||||||
|
#### mailQWatch.sh
|
||||||
|
|
||||||
|
Script checks mailq size on a postfix system and sends an email when queue size is greater than threshold.
|
||||||
|
|
||||||
|
Update variables in scripts to suit your needs.
|
||||||
|
|
||||||
|
<pre><code>
|
||||||
|
QUEUELIMIT=75
|
||||||
|
SUBJECT="Mail Queue on $HOST is currently $QUEUECOUNT"
|
||||||
|
MAILTO="user@example.com"
|
||||||
|
</code></pre>
|
||||||
|
|
||||||
|
<b>Installation</b>
|
||||||
|
|
||||||
|
As root, sudo will not work.
|
||||||
|
|
||||||
|
<pre><code>
|
||||||
|
echo "*/5 * * * * ${PWD}/mailQWatch.sh" >> /etc/crontab
|
||||||
|
</code></pre>
|
||||||
|
@ -1,16 +1,16 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
# Checks mailQ size
|
|
||||||
|
|
||||||
QUEUELIMIT=0
|
QUEUELIMIT=75
|
||||||
HOST=$(/bin/hostname)
|
|
||||||
QUEUELENGTH=$(/usr/sbin/postqueue -p | tail -n1 | awk '{print $5}')
|
|
||||||
QUEUECOUNT=$(echo $queuelength | grep "[0-9]")
|
|
||||||
SUBJECT="Mail Queue on $HOST is currently $QUEUECOUNT"
|
SUBJECT="Mail Queue on $HOST is currently $QUEUECOUNT"
|
||||||
MAILTO="mmckinnon@comprofix.com"
|
MAILTO="mmckinnon@comprofix.com"
|
||||||
|
|
||||||
|
HOST=$(/bin/hostname)
|
||||||
|
POSTQUEUE=$(which postqueue)
|
||||||
|
QUEUELENGTH=$($POSTQUEUE -p | tail -n1 | awk '{print $5}')
|
||||||
|
QUEUECOUNT=$(echo $QUEUELENGTH | grep "[0-9]")
|
||||||
|
|
||||||
if [ "$QUEUECOUNT" == "" ]; then
|
if [ "$QUEUECOUNT" == "" ]; then
|
||||||
exit;
|
exit;
|
||||||
elif [ "$QUEUECOUNT" -gt "$QUEUELIMIT" ]; then
|
elif [ "$QUEUECOUNT" -gt "$QUEUELIMIT" ]; then
|
||||||
#echo $msg | /bin/mail -s "Mail Queue Alert $queuecount ($hostname)" "helpdesk@ambient-it.com.au"
|
$POSTQUEUE -p | /bin/mail -s "$SUBJECT" "$MAILTO"
|
||||||
/usr/sbin/postqueue -p | /bin/mail -s "$SUBJECT" "$MAILTO"
|
|
||||||
fi
|
fi
|
||||||
|
Loading…
Reference in New Issue
Block a user