-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchk_as_stat-read-reqs.sh
executable file
·96 lines (83 loc) · 2.07 KB
/
chk_as_stat-read-reqs.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
94
95
96
#!/bin/bash
# Nagios Plugin
# Check Cluster Size
if [ ! -e citrusleaf_stats.py ] ; then
echo "citrusleaf_stats.py file does not exist."
exit 2
fi
usage()
{
cat << EOF
usage: $0 options
By Kali Nguyen, 2013 - github.com/solaris7
This nagios plugins checks for aerospike stat_read_reqs. The same number over a 1 minute period may indicate a problem.
This script creates a temporary file at /tmp/.aerospike-stat_read_reqs
OPTIONS:
-h Show this message
-H Hostname
-p Server port
EOF
}
HOSTNAME=
PORT=
WARN=
CRIT=
while getopts “hH:p:” OPTION
do
case $OPTION in
h)
usage
exit 1
;;
H)
HOSTNAME=$OPTARG
;;
p)
PORT=$OPTARG
;;
?)
usage
exit
;;
esac
done
if [[ -z $HOSTNAME ]] || [[ -z $PORT ]]
then
usage
exit 1
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 citrusleaf_stats.py -h $HOSTNAME -p $PORT -s stat_read_reqs | cut -d= -f 2)"
#if [ -z $METRIC ] ; then
# echo -e "CRITICAL - cannot obtain replication latencies | Error on $HOSTNAME:$PORT aerospike lag check"
# exit 2
#fi
# Comparing the result and setting the correct level:
if [ -e /tmp/.aerospike-stat_read_reqs ]; then
# Count size of the file, makes sure it is only 1
if [ `cat /tmp/.aerospike-stat_read_reqs | wc -l` -eq 1 ]; then
VAR1=`cat /tmp/.aerospike-stat_read_reqs`
else
rm -vfr /tmp/.aerospike-stat_read_reqs
echo -e "CRITICAL | /tmp/.aerospike-stat_read_reqs read file error"
exit 2
fi
fi
if [[ $METRIC -eq $VAR1 ]]; then
msg="CRITICAL"
status=2
else if [[ $METRIC -ne $VAR1 ]]; then
msg="OK"
status=0
fi
fi
# Printing the results:
echo $METRIC > /tmp/.aerospike-stat_read_reqs
echo "$msg - $HOSTNAME aerospike stat_read_reqs=$METRIC | '$HOSTNAME stat_read_reqs'=$METRIC;$WARN;$CRIT;"
# Bye!
exit $status