-
Notifications
You must be signed in to change notification settings - Fork 5
/
Copy pathcitrusleaf_checks.sh
executable file
·125 lines (111 loc) · 4.24 KB
/
citrusleaf_checks.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
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
#!/bin/bash
#####
# this script is used in nagios to check citrusleaf's "available_percent", "bytes-disk-used", and "evicted-objects"
# it also outputs the performance data of those numbers for usage in pnp4nagios or whatever else.
# usage:
# citrusleaf_checks.sh <evict|bytes|pct> <WARNING> <CRITICAL>
#####
NAMESPACE="namespace/devices"
# rm -f /tmp/cl*
TEMP=/tmp/cltmp.$$
INFO=/tmp/clinfotmp.$$
touch $TEMP $INFO
SERVER="127.0.0.1"
PORT="3000"
CLINFO=`which clinfo`
#### you should not have to change anything below this line ####
if [[ -z ${CLINFO} ]]; then
printf "\nclinfo not installed\n"
exit 1
done
for x in $SERVER; do
clinfo -h $x -p $PORT -v "$NAMESPACE" > $INFO
done
grep "type" $INFO > $TEMP
case $1 in
'evictions'|'evicted'|'evict')
EVICTIONS=`cat $TEMP | awk -F "[;=]" '{print $8}'`
if [[ -z "${2}" || -z "${3}" ]]; then
printf "must set warning and critical values"
else
if [[ ${EVICTIONS} -ge ${2} ]]; then
if [[ ${EVICTIONS} -ge ${3} ]]; then
echo "CRITICAL: evicted-objects=${EVICTIONS} | evicted-objects=${EVICTIONS};${2};${3};0;0"
rm -f /tmp/cltmp.$$ ; rm -f /tmp/clinfotmp.$$
exit 2
fi
echo "WARNING: evicted-objects=${EVICTIONS} | evicted-objects=${EVICTIONS};${2};${3};0;0"
rm -f /tmp/cltmp.$$ ; rm -f /tmp/clinfotmp.$$
exit 1
else
echo "OK: evicted-objects=${EVICTIONS} | evicted-objects=${EVICTIONS};${2};${3};0;0"
rm -f /tmp/cltmp.$$ ; rm -f /tmp/clinfotmp.$$
exit 0
fi
fi
;;
'bytes'|'disk')
BYTES_USED_DISK=`cat $TEMP | awk -F "[;=]" '{print $40}'`
BYTES_USED_DISK_GB=`echo ${BYTES_USED_DISK} | awk '{ split( "KB MB GB" , v ); s=1; while( $1>1024 ){ $1/=1024; s++ } print int($1) v[s] }'`
if [[ ${BYTES_USED_DISK} -lt "1024000" ]]; then
BUD_SIZE="KB"
else
if [[ ${BYTES_USED_DISK} -ge 1024000000 ]]; then
BUD_SIZE="GB"
else
BUD_SIZE="MB"
fi
fi
TOTAL_BYTES_DISK=`cat $TEMP | awk -F "[;=]" '{print $42}'`
TOTAL_BYTES_DISK_GB=`echo ${TOTAL_BYTES_DISK} | awk '{ split( "KB MB GB" , v ); s=1; while( $1>1024 ){ $1/=1024; s++ } print int($1) v[s] }'`
if [[ ${TOTAL_BYTES_DISK} -lt "1024000" ]]; then
TBD_SIZE="KB"
else
if [[ ${TOTAL_BYTES_DISK} -ge 1024000000 ]]; then
TBD_SIZE="GB"
else
TBD_SIZE="MB"
fi
fi
if [[ -z "${2}" || -z "${3}" ]]; then
printf "must set warning and critical values"
else
if [[ ${BYTES_USED_DISK} -ge ${2} ]]; then
if [[ ${BYTES_USED_DISK} -ge ${3} ]]; then
echo "CRITICAL: used-bytes-disk=${BYTES_USED_DISK_GB}${BUD_SIZE} | used_bytes_disk=${BYTES_USED_DISK};${2};${3};0;0"
rm -f /tmp/cltmp.$$ ; rm -f /tmp/clinfotmp.$$
exit 2
fi
echo "WARNING: used-bytes-disk=${BYTES_USED_DISK_GB}${BUD_SIZE} | used_bytes_disk=${BYTES_USED_DISK};${2};${3};0;0"
rm -f /tmp/cltmp.$$ ; rm -f /tmp/clinfotmp.$$
exit 1
else
echo "OK: used-bytes-disk=${BYTES_USED_DISK_GB}${BUD_SIZE} | used_bytes_disk=${BYTES_USED_DISK};${2};${3};0;0"
rm -f /tmp/cltmp.$$ ; rm -f /tmp/clinfotmp.$$
exit 0
fi
fi
;;
'percent'|'pct')
AVAILABLE_PCT=`cat $TEMP | awk -F "[;=]" '{print $68}'`
if [[ -z "${2}" || -z "${3}" ]]; then
printf "must set warning and critical values"
else
if [[ ${AVAILABLE_PCT} -ge ${2} ]]; then
if [[ ${AVAILABLE_PCT} -ge ${3} ]]; then
echo "CRITICAL: available_pct=${AVAILABLE_PCT} | available_pct=${AVAILABLE_PCT};${2};${3};0;0"
rm -f /tmp/cltmp.$$ ; rm -f /tmp/clinfotmp.$$
exit 2
fi
echo "WARNING: available_pct=${AVAILABLE_PCT} | available_pct=${AVAILABLE_PCT};${2};${3};0;0"
rm -f /tmp/cltmp.$$ ; rm -f /tmp/clinfotmp.$$
exit 1
else
echo "OK: available_pct=${AVAILABLE_PCT} | available_pct=${AVAILABLE_PCT};${2};${3};0;0"
rm -f /tmp/cltmp.$$ ; rm -f /tmp/clinfotmp.$$
exit 0
fi
fi
;;
'help'|*) echo "usage: $0 <evictions|bytes|percent>"
esac