File check_sign of Package monitoring-plugins-sign
#!/bin/sh
###############################################
#
# Nagios script to check signd status on a host
#
# Copyright 2009, Novell Inc.
#
# See usage for command line switches
#
# Created: 2009-10-04 (lrupp@suse.de)
#
# 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="0.92"
SIGN=$(which sign 2>/dev/null)
SUDO=""
function usage() {
echo " check_sign $VERSION - Nagios sign check script"
echo ""
echo " Usage: check_sign [-h]"
echo " -h : show this help"
echo " -c <command> : use the given command (full path needed)"
echo " -s : use sudo"
echo " This needs a line in /etc/sudoers like:"
echo " nagios ALL = NOPASSWD: $SIGN -t"
echo ""
}
function doopts() {
if ( `test 0 -lt $#` )
then
while getopts sc:h myarg "$@"
do
case $myarg in
c)
SIGN="$OPTARG"
;;
h|\?)
usage
exit
;;
s|S)
SUDO=$(which sudo)
;;
esac
done
fi
}
function theend() {
echo $RESULT
exit $EXIT_STATUS
}
# Handle command line options
doopts $@
OUTPUT=$($SUDO $SIGN -t; echo $?)
if [ 0$OUTPUT -gt 0 ]; then
RESULT="SIGN CRITICAL - test ($SUDO $SIGN -t) failed: $OUTPUT"
EXIT_STATUS=$STATE_CRITICAL
else
RESULT="SIGN OK - test ($SUDO $SIGN -t) succeeded"
EXIT_STATUS=$STATE_OK
fi
# Quit and return information and exit status
theend