-
Notifications
You must be signed in to change notification settings - Fork 0
/
chk_as_evicted-objects.sh
executable file
·80 lines (74 loc) · 1.63 KB
/
chk_as_evicted-objects.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
#!/bin/bash
# Nagios Plugin
# Check Cluster Size
usage()
{
cat << EOF
usage: $0 options
By AppLovin Ops Team. www.applovin.com.
This nagios plugins checks for aerospike stat_evicted_objects. The same number over a 1 minute period may indicate a problem.
This script creates a temporary file at /tmp/.aerospike-stat_evicted_objects
OPTIONS:
-h Show this message
-H Hostname
-p Server port
-n Nagios plugins dir ($USER1)
EOF
}
HOSTNAME=
PORT=
PLUGINDIR=
OUT=
while getopts “hH:p:n:” OPTION
do
case $OPTION in
h)
usage
exit 2
;;
H)
HOSTNAME=$OPTARG
;;
p)
PORT=$OPTARG
;;
n)
PLUGINDIR=$OPTARG
;;
?)
usage
exit 2
;;
esac
done
if [[ -z $HOSTNAME ]] || [[ -z $PORT ]] || [[ -z $PLUGINDIR ]]
then
usage
exit 2
fi
if [ ! -e /usr/bin/clmonitor ] ; then
echo "clmonitor file does not exist. Exiting."
exit 2
fi
if [ ! -e $PLUGINDIR/citrusleaf_stats.py ] ; then
echo "citrusleaf_stats.py file does not exist."
exit 2
fi
METRIC="$(python $PLUGINDIR/citrusleaf_stats.py -h $HOSTNAME -p $PORT -s stat_evicted_objects | cut -d= -f 2)"
# Comparing the result and setting the correct level:
if ! [[ "$METRIC" =~ ^[0-9]+$ ]] ; then
echo "CRITICAL - $HOSTNAME aerospike connection error | '$HOSTNAME aerospike connection error'=0"
exit 2
fi
if [[ $METRIC -eq 0 ]]; then
msg="OK"
status=0
else if [[ $METRIC -ne 0 ]]; then
msg="CRITICAL"
status=2
fi
fi
# Printing the results:
echo "$msg - $HOSTNAME aerospike stat_evicted_objects=$METRIC | '$HOSTNAME stat_evicted_objects'=$METRIC;1;3;"
# Bye!
exit $status