Logoj0ke.net Open Build Service > Projects > server:monitoring > nagios-plugins-sign > check_sign
Sign Up | Log In

File check_sign of Package nagios-plugins-sign

x
 
1
#!/bin/sh
2
###############################################
3
#
4
# Nagios script to check signd status on a host
5
#
6
# Copyright 2009, Novell Inc.
7
#
8
# See usage for command line switches
9
#
10
# Created: 2009-10-04 (lrupp@suse.de)
11
#
12
# This program is free software: you can redistribute it and/or modify
13
# it under the terms of the GNU General Public License as published by
14
# the Free Software Foundation, either version 3 of the License, or
15
# (at your option) any later version.
16
#
17
# This program is distributed in the hope that it will be useful,
18
# but WITHOUT ANY WARRANTY; without even the implied warranty of
19
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
20
# GNU General Public License for more details.
21
#
22
# You should have received a copy of the GNU General Public License
23
# along with this program.  If not, see <http://www.gnu.org/licenses/>.
24
#
25
###############################################
26
27
. /usr/lib/nagios/plugins/utils.sh
28
29
VERSION="0.92"
30
31
SIGN=$(which sign 2>/dev/null)
32
SUDO=""
33
34
function usage() {
35
    echo " check_sign $VERSION - Nagios sign check script"
36
    echo ""
37
    echo " Usage: check_sign [-h]"
38
    echo "        -h           : show this help"
39
    echo "        -c <command> : use the given command (full path needed)"
40
    echo "        -s           : use sudo"
41
    echo "                       This needs a line in /etc/sudoers like:"
42
    echo "                       nagios ALL = NOPASSWD: $SIGN -t"
43
    echo ""
44
}
45
46
function doopts() {
47
    if ( `test 0 -lt $#` )
48
    then
49
        while getopts sc:h myarg "$@"
50
        do
51
            case $myarg in
52
                c)
53
                    SIGN="$OPTARG"
54
                ;;
55
                h|\?)
56
                    usage
57
                    exit
58
                ;;
59
                s|S)
60
                    SUDO=$(which sudo)
61
                ;;
62
            esac
63
        done
64
    fi
65
}
66
67
function theend() {
68
    echo $RESULT
69
    exit $EXIT_STATUS
70
}
71
72
# Handle command line options
73
doopts $@
74
75
OUTPUT=$($SUDO $SIGN -t; echo $?)
76
if [ 0$OUTPUT -gt 0 ]; then
77
    RESULT="SIGN CRITICAL - test ($SUDO $SIGN -t) failed: $OUTPUT"
78
    EXIT_STATUS=$STATE_CRITICAL
79
else
80
    RESULT="SIGN OK - test ($SUDO $SIGN -t) succeeded"
81
    EXIT_STATUS=$STATE_OK
82
fi
83
# Quit and return information and exit status
84
theend
85
86