Commit a047d849 authored by nuts's avatar nuts
Browse files

add mailq script for exim



git-svn-id: https://subversion.fem.tu-ilmenau.de/repository/nagios@40 0c029375-f9a5-47ba-aa0c-8883c34e326a
parent 35dc9108
#!/bin/sh
###############################################
#
# Nagios script to check Exim mail queue status
#
# Copyright 2007, 2008 Ian Yates, 2016 Dustin Funk
#
# NOTE: Depending on your config, the nagios user will probably be
# needed to be added to the exim group for this script to function correctly
#
# See usage for command line switches
#
# You need to add the following to /etc/sudoers:
# nagios ALL=NOPASSWD:/usr/local/exim/bin/exim
#
# Created: 2006-07-31 (i.yates@uea.ac.uk)
# Updated: 2007-04-30 (i.yates@uea.ac.uk) - Linux/sudo tweaks
# Updated: 2008-03-26 (i.yates@uea.ac.uk) - Fixed bug in critical/warning level checking which could result in erroneous results.
# Updated: 2008-11-27 (i.yates@uea.ac.uk) - Added GPLv3 licence
# Updated: 2016-03-25 (nuts@fem.tu-ilmenau.de) - Added perfomance output and remove sensless verbose flag
#
# This program is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License as published by
# the Free Software Foundation, either version 3 of the License, or
# (at your option) any later version.
#
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
# GNU General Public License for more details.
#
# You should have received a copy of the GNU General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
###############################################
. /usr/lib/nagios/plugins/utils.sh
VERSION="1.4"
EXIM=exim
SUDO=sudo
LEVEL_WARN=""
LEVEL_CRIT=""
PERFDATA=false
RESULT=""
EXIT_STATUS=$STATE_OK
###############################################
#
## FUNCTIONS
#
## Print usage
usage() {
echo " check_eximailqueue $VERSION - Nagios Exim mail queue check script"
echo ""
echo " Usage: check_eximailqueue -w <warning queue size> -c <critical queue size> [ -p ] [ -h ]"
echo ""
echo " -w Queue size at which a warning is triggered"
echo " -c Queue size at which a critical is triggered"
echo " -p Add performance data"
echo " -h Show this page"
echo ""
}
## Process command line options
doopts() {
if ( `test 0 -lt $#` )
then
while getopts w:c:ph myarg "$@"
do
case $myarg in
h|\?)
usage
exit;;
w)
LEVEL_WARN=$OPTARG;;
c)
LEVEL_CRIT=$OPTARG;;
p)
PERFDATA=true;;
*) # Default
usage
exit;;
esac
done
else
usage
exit
fi
}
# Write output and return result
#echo $PERFDATA
theend() {
if $PERFDATA; then
echo "$RESULT | mailq=$OUTPUT;$LEVEL_WARN;$LEVEL_CRIT"
else
echo $RESULT
fi
exit $EXIT_STATUS
}
#
## END FUNCTIONS
#
#############################################
#
## MAIN
#
# Handle command line options
doopts $@
# Do the do
OUTPUT=`$SUDO -u root $EXIM -bpc`
if test -z "$OUTPUT" ; then
RESULT="Mailqueue WARNING - query returned no output!"
EXIT_STATUS=$STATE_WARNING
else
if test "$OUTPUT" -lt "$LEVEL_WARN" ; then
RESULT="Mailqueue OK - $OUTPUT messages on queue"
EXIT_STATUS=$STATE_OK
else
if test "$OUTPUT" -ge "$LEVEL_CRIT" ; then
RESULT="Mailqueue CRITICAL - $OUTPUT messages on queue"
EXIT_STATUS=$STATE_CRITICAL
else
if test "$OUTPUT" -ge "$LEVEL_WARN" ; then
RESULT="Mailqueue WARNING - $OUTPUT messages on queue"
EXIT_STATUS=$STATE_WARNING
fi
fi
fi
fi
# Quit and return information and exit status
theend
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment