#!/bin/bash
# this checks to see how many mesages are queued up for delivery
# IWT 20160920 (1.3) added mesage count to display
# parameters to adjust for ok/warn/emergency
((yellowThreshhold=1))
((redThreshhold=10))
# overhead
OS=$(uname -o)
PID=$$
TEST="postqueue"
VERSION='1.4'
VERMSG="
Version: ${VERSION}"
DATE=$(date)
POSTQ='/usr/sbin/postqueue'
# actual work
pq=$(${POSTQ} -p)
cnt=$(${POSTQ} -p | grep '^[0-9A-Z]' | grep -v 'Mail queue is empty' | wc -l)
msg="
Mesasges in queue: ${cnt}
Yellow threshhold: ${yellowThreshhold}
Red threshhold: ${redThreshhold}
";
# figure out color
if (( cnt < yellowThreshhold ))
then
color="green"
else
if (( cnt < redThreshhold ))
then
color="yellow"
else
color="red"
fi
fi
# echo ${BB} ${BBDISP} "status ${MACHINE}.${TEST} ${color} ${pq}"
${BB} ${BBDISP} "status ${MACHINE}.${TEST} ${color} ${DATE} ${msg} ${pq} ${VERMSG}
"