shell script for checking quorum drives on multiple windows nodes
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
#!/bin/bash
# check_quorum.sh
#
# K Sotiroff 23 Oct 2014
#
# checks quorum drives no matter what node they sit on.
#
usage () {
echo "Usage: $0 -H hosts (comma separated list) -w warning -c critical -d drive";
return
}
# check for incoming options
if [ $# -lt 4 ] # we expect 4 options
then
usage;
exit 1
fi
# get arguments
hosts= critical= warning= drive=
while getopts H:w:d:c: opt
do
case $opt in
H) hosts=($OPTARG)
;;
c) critical=$OPTARG
;;
w) warning=$OPTARG
;;
d) drive=$OPTARG
;;
'?') echo "$0: invalid option -$OPTARG" >&2
usage;
exit 1
;;
esac
done
shift $((OPTIND -1))
oIFS="$IFS"; # save the field seperator
IFS=,; # set the new field separator to ,
set -- $hosts; # split the hosts variable into an array based on IFS
IFS="$oIFS"; # set it back to default
# now loop it
for thishost in "$@"; do
result=$(/usr/local/nagios/libexec/check_nt -H $thishost -v USEDDISKSPACE -p 1248 -l $drive -w $warning -c $critical );
found=$(echo $result | grep -c "Invalid drive");
# found it, no need to go any further.
if [["$found"_==_"0"|"$found" == "0"]]; then
echo $result;
exit 0;
fi
done
# oops, something went wrong
echo "Critical: Cannot find Quorum drive on any node. Checked $hosts";
exit 2;
The command config is;
1
2
3
4
define command{
command_name check_quorum
command_line $USER1$/check_quorum.sh -H $ARG1$ -w $ARG2$ -c $ARG3$ -d $ARG4$
}
and the service config inside the host is;
1
2
3
4
5
6
define service{
host_name servercluster
service_description Q Quorum Drive
use live_service
check_command check_quorum!servernode01,servernode02!10%!5%!q
}