This repository has been archived by the owner on Jan 8, 2025. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 10
/
Copy pathcheck_nfsmount
executable file
·125 lines (105 loc) · 2.66 KB
/
check_nfsmount
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/bash
# NFS mount plugin for Nagios
# Written by Tim Gibbon [email protected]
# Last Modified: 29-Sep-2008
#
# Description:
#
# This plugin will check the status of a remote servers NFS shares. Note that
# in the event of nfsd failing and portmap remaining up, showmount will still
# return a list of shares and zero error code. If you are concerned about this
# then do not use this script.
#
# Add the following to /etc/nagios2/conf.d/check_nfsmount.cfg
#define command {
# command_name check_nfsmount
# command_line $USER1$/check_nfsmount -H $HOSTADDRESS$
# }
# Add the following to your main services_nagios2.cfg
#
#define service {
# hostgroup_name nfs-servers
# service_description NFS
# check_command check_nfsmount
# use generic-service
# notification_interval 0 ; set > 0 if you want to be renotified
#}
# Add the following to your hostgroups_nagios2.cfg
#define hostgroup {
# hostgroup_name nfs-servers
# alias NFS servers
# members icybox
# }
# Location of the showmount command (if not in path)
SHOWMOUNT=`which showmount`
# Don't change anything below here
# Nagios return codes
STATE_OK=0
STATE_WARNING=1
STATE_CRITICAL=2
STATE_UNKNOWN=3
STATE_DEPENDENT=4
if [ ! -x "${SHOWMOUNT}" ]
then
echo "UNKNOWN: $SHOWMOUNT not found or is not executable by the nagios user"
exitstatus=$STATE_UNKNOWN
exit $exitstatus
fi
PROGNAME=`basename $0`
print_usage() {
echo "Usage: $PROGNAME -H <hostname>"
echo ""
echo "Notes:"
echo "-H: Hostname - Can be a hostname or IP address"
echo ""
}
print_help() {
print_usage
echo ""
echo "This plugin will check the NFS mounts on a remote (or local with -H localhost) NFS server."
echo ""
exit 0
}
#exitstatus=${STATE_UNKNOWN} #default
while test -n "$1"; do
case "$1" in
--help)
print_help
exit $STATE_OK
;;
-h)
print_help
exit $STATE_OK
;;
-H)
HOSTNAME=$2
shift
;;
*)
print_help
exit $STATE_OK
esac
shift
done
# Check arguments for validity
if [ -z ${HOSTNAME} ]
then
echo "You must specify a hostname (or localhost to test the local system)"
print_usage
exitstatus=$STATE_UNKNOWN
exit $exitstatus
fi
# Run basic showmount and find our status
SHOWMOUNT_OUTPUT=`${SHOWMOUNT} -e ${HOSTNAME} 2>&1`
if [ $? -ne 0 ]
then
exitstatus=${STATE_CRITICAL}
else
exitstatus=${STATE_OK}
fi
# Remove the wildcards as they cause a complete listing of CWD
# Uncomment the following 2 lines if you wish to have a list of shares
# in your Nagios output
#CLEANED_SHOWMOUNT_OUTPUT=`${SHOWMOUNT} -e ${HOSTNAME} 2>&1 | sed -e s/\*//g`
#echo ${CLEANED_SHOWMOUNT_OUTPUT}
exit $exitstatus