-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchk_as_stopwrites.sh
executable file
·72 lines (68 loc) · 1.46 KB
/
chk_as_stopwrites.sh
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
#!/bin/bash
# Nagios Plugin
# Checks for stopwrites
usage()
{
cat << EOF
usage: $0 options
By Kali Nguyen, 2013 - github.com/solaris7
This nagios plugins checks for aerospike stop writes.
This script creates a temporary file at /tmp/.aerospike-stat_evicted_objects
OPTIONS:
-h Show this message
-H Hostname
-p Server port
EOF
}
HOSTNAME=
PORT=
PLUGINDIR=
OUT=
while getopts “hH:p:” OPTION
do
case $OPTION in
h)
usage
exit 2
;;
H)
HOSTNAME=$OPTARG
;;
p)
PORT=$OPTARG
;;
?)
usage
exit 2
;;
esac
done
if [[ -z $HOSTNAME ]] || [[ -z $PORT ]]
then
usage
exit 2
fi
if [ ! -e /usr/bin/clinfo ] ; then
echo "clinfo file does not exist. Exiting."
exit 2
fi
NS=`/usr/bin/clinfo -v namespaces -h $HOSTNAME | tail -n 1 | cut -d" " -f 4 | tr ";" " "`
msg="OK"
for i in $NS; do
output=`/usr/bin/clinfo -v namespace/$i -h $HOSTNAME | grep -o "stop-writes=[a-z]*" | cut -d"=" -f2`
if [[ ! $output == "true" ]] && [[ ! $output == "false" ]]; then
echo "CRITICAL - Aerospike connection error"
exit 2
fi
if [ $output == "true" ]; then
msg="CRITICAL"
fi
done
# Printing the results:
if [[ $msg == "OK" ]] ; then
echo "$msg - $HOSTNAME aerospike stopwrites=false | '$HOSTNAME stopwrites'=false;true;true;"
exit 0
elif [[ $msg == "CRITICAL" ]] ; then
echo "$msg - $HOSTNAME aerospike stopwrites=true | '$HOSTNAME stopwrites'=true;true;true;"
exit 2
fi