-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathchk_asns-objs.sh
executable file
·87 lines (81 loc) · 1.49 KB
/
chk_asns-objs.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
#!/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 namespace objects.
OPTIONS:
-h Show this message
-H Hostname
-p Server port
-w Warning threshold
-c Critical threshold
-n Namespace or namespace map
EOF
}
HOSTNAME=
PORT=
WARN=
CRIT=
NS=
while getopts “hH:p:w:c:n:” OPTION
do
case $OPTION in
h)
usage
exit 1
;;
H)
HOSTNAME=$OPTARG
;;
p)
PORT=$OPTARG
;;
w)
WARN=$OPTARG
;;
c)
CRIT=$OPTARG
;;
n)
NS=$OPTARG
;;
?)
usage
exit
;;
esac
done
if [[ -z $HOSTNAME ]] || [[ -z $PORT ]] || [[ -z $WARN ]] || [[ -z $CRIT ]] || [[ -z $NS ]]
then
usage
exit 1
fi
if [ ! -e /usr/bin/clinfo ] ; then
echo "clmonitor file does not exist. Exiting."
exit 2
fi
METRIC="$(clinfo -h $HOSTNAME -p $PORT -v $NS| tail -n 1 | cut -d';' -f 2)"
# 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 namespace $NS objects=$METRIC | '$HOSTNAME aerospike $NS objs'=$METRIC;$WARN;$CRIT;"
# Bye!
exit $status