| Server IP : 104.21.58.74 / Your IP : 216.73.216.213 Web Server : LiteSpeed System : Linux s12482.usc1.stableserver.net 5.14.0-570.32.1.el9_6.x86_64 #1 SMP PREEMPT_DYNAMIC Wed Aug 6 11:30:41 EDT 2025 x86_64 User : snownico ( 1231) PHP Version : 8.2.31 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : OFF | Pkexec : OFF Directory : /lib64/nagios/plugins/ |
Upload File : |
#!/bin/bash
usage() {
echo "check_smartermail_queue - Icinga SmarterMail queue check"
echo ""
echo "Usage: check_smartermail_queue -w <warning queue size> -c <critical queue size> [ -h ]"
echo ""
echo " -w Queue size at which a warning is triggered"
echo " -c Queue size at which a critical is triggered"
echo " -h Show this page"
echo ""
}
cmdopts() {
if [ $# -gt 0 ]; then
while getopts w:c:h myarg; do
case $myarg in
h|\?)
usage
exit 0;;
w)
WARNING=$OPTARG;;
c)
CRITICAL=$OPTARG;;
*) # Default
usage
exit 1;;
esac
done
else
usage
exit 1
fi
}
cmdopts "$@"
if [ -z "$WARNING" ] || [ -z "$CRITICAL" ]; then
echo "Error: Both -w (warning) and -c (critical) thresholds must be provided."
usage
exit 1
fi
SPOOL_DIR="/var/lib/smartermail/Spool"
EMAIL_COUNT=$(find "$SPOOL_DIR" -type f -name "*.eml" 2>/dev/null | wc -l)
if [ "$EMAIL_COUNT" -ge "$CRITICAL" ]; then
echo "CRITICAL: $EMAIL_COUNT mail(s) in queue (Threshold: $CRITICAL)"
exit 2 # Critical status
elif [ "$EMAIL_COUNT" -ge "$WARNING" ]; then
echo "WARNING: $EMAIL_COUNT mail(s) in queue (Threshold: $WARNING)"
exit 1 # Warning status
else
echo "OK: $EMAIL_COUNT mail(s) in queue (Threshold is below $WARNING)"
exit 0 # OK status
fi