-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchk_as_free-pct-disk.sh
executable file
·93 lines (87 loc) · 1.81 KB
/
chk_as_free-pct-disk.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
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#!/bin/bash
# Nagios Plugin
# Check Cluster Size
usage()
{
cat << EOF
usage: $0 options
By Kali Nguyen, 2013 - github.com/solaris7
This nagios plugins checks for aerospike free space.
OPTIONS:
-h Show this message
-H Hostname
-p Server port
-w Warning threshold
-c Critical threshold
-n Nagios Plugin Dir ($USER1$)
EOF
}
HOSTNAME=
PORT=
WARN=
CRIT=
PLUGINDIR=
while getopts “hH:p:w:c:n:” OPTION
do
case $OPTION in
h)
usage
exit 2
;;
H)
HOSTNAME=$OPTARG
;;
p)
PORT=$OPTARG
;;
w)
WARN=$OPTARG
;;
c)
CRIT=$OPTARG
;;
n)
PLUGINDIR=$OPTARG
;;
?)
usage
exit 2
;;
esac
done
if [[ -z $HOSTNAME ]] || [[ -z $PORT ]] || [[ -z $WARN ]] || [[ -z $CRIT ]] || [[ -z $PLUGINDIR ]]
then
usage
exit 2
fi
if [ ! -e $PLUGINDIR/citrusleaf_stats.py ] ; then
echo "citrusleaf_stats.py file does not exist."
exit 2
fi
if [ ! -e /usr/bin/clmonitor ] ; then
echo "clmonitor file does not exist. Exiting."
exit 2
fi
#clmonitor -e "info XDR" -h sjc-aero1.alcfd.com | tail -n 4 | head -n 3 | awk '{ print $6 }' | tr , "\n" > /tmp/.aerospike_lag_check
#echo Running clmonitor, $HOSTNAME:$PORT
METRIC="$(python $PLUGINDIR/citrusleaf_stats.py -h $HOSTNAME -p $PORT -s free-pct-disk | cut -d= -f 2)"
if ! [[ "$METRIC" =~ ^[0-9]+$ ]] ; then
echo "CRITICAL - Aerospike connection error"
exit 2
fi
# Comparing the result and setting the correct level:
if [[ $METRIC -lt $CRIT ]]; then
msg="CRITICAL"
status=2
else if [[ $METRIC -lt $WARN ]]; then
msg="WARNING"
status=1
else
msg="OK"
status=0
fi
fi
# Printing the results:
echo "$msg - $HOSTNAME aerospike available disk=$METRIC% | '$HOSTNAME available disk'=$METRIC;$WARN;$CRIT;"
# Bye!
exit $status