Skip to content

Commit e887369

Browse files
committed
initial commit
1 parent d375e4a commit e887369

File tree

2 files changed

+135
-0
lines changed

2 files changed

+135
-0
lines changed

README.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
### check_scalelite
2+
This plugin for icinga checks bigbluebutton clusters run with scalelite (https://github.com/blindsidenetworks/scalelite/issues) and verifies how many bbb nodes are live.

check_scalelite

Lines changed: 133 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,133 @@
1+
#!/bin/bash
2+
#
3+
# Check scalelite cluster health
4+
# Written by
5+
#
6+
# Usage: ./check_scalelite
7+
#
8+
# Description:
9+
#
10+
# Since the rake command via docker exec needs a lot of permissions, we do that in a cronjob for root and write to a tmp-file
11+
# the plugin then works with.
12+
#
13+
# Notes:
14+
#
15+
# needs a cronjob as root, should be in the interval you run the check:
16+
# */5 * * * * docker exec -t scalelite-api env COLUMNS=2048 bundle exec rake status > /tmp/scalelite.state
17+
#
18+
19+
STATE_OK=0
20+
STATE_WARNING=1
21+
STATE_CRITICAL=2
22+
STATE_UNKNOWN=3
23+
STATE_DEPENDENT=4
24+
25+
PROGNAME=$(basename "$0")
26+
REVISION="0.1"
27+
28+
# defaults
29+
CHECKFILE="/tmp/scalelite.state"
30+
critical=1
31+
warning=2
32+
33+
print_usage() {
34+
echo "Usage: $PROGNAME --filename statefile -w <number> -c <number>"
35+
echo "Usage: $PROGNAME --help"
36+
echo "Usage: $PROGNAME --version"
37+
}
38+
39+
print_help() {
40+
print_revision "$PROGNAME" $REVISION
41+
echo ""
42+
print_usage
43+
echo ""
44+
echo "scalelite cluster check plugin for icinga2"
45+
echo ""
46+
support
47+
}
48+
49+
# Grab the command line arguments
50+
51+
#logfile=$1
52+
#oldlog=$2
53+
#query=$3
54+
exitstatus=$STATE_WARNING #default
55+
while test -n "$1"; do
56+
case "$1" in
57+
--help)
58+
print_help
59+
exit "$STATE_OK"
60+
;;
61+
-h)
62+
print_help
63+
exit "$STATE_OK"
64+
;;
65+
--version)
66+
print_revision "$PROGNAME" $REVISION
67+
exit "$STATE_OK"
68+
;;
69+
-V)
70+
print_revision "$PROGNAME" $REVISION
71+
exit "$STATE_OK"
72+
;;
73+
--filename)
74+
CHECKFILE=$2
75+
shift
76+
;;
77+
-w)
78+
warning=$2
79+
shift
80+
;;
81+
-c)
82+
critical=$2
83+
shift
84+
;;
85+
*)
86+
echo "Unknown argument: $1"
87+
print_usage
88+
exit "$STATE_UNKNOWN"
89+
;;
90+
esac
91+
shift
92+
done
93+
94+
# If the state file doesn't exist or is not readable, exit
95+
96+
if [ ! -e "$CHECKFILE" ]; then
97+
echo "scalelite check error: state file $CHECKFILE does not exist! Did you set up the cronjob?"
98+
exit "$STATE_UNKNOWN"
99+
elif [ ! -r "$CHECKFILE" ] ; then
100+
echo "scalelite check error: state file $CHECKFILE is not readable!"
101+
exit "$STATE_UNKNOWN"
102+
fi
103+
104+
# Count the number of nodes we have and handle errors when grep fails
105+
count=$(grep -c ".*" "$CHECKFILE" 2>&1)
106+
((count-=1))
107+
108+
if [[ $? -gt 1 ]]; then
109+
echo "scalelite check error: $count"
110+
exit "$STATE_UNKNOWN"
111+
fi
112+
113+
# Count the number of nodes we have that are enabled and online and handle errors when grep fails
114+
count_eo=$(grep -c "enabled.*online" "$CHECKFILE" 2>&1)
115+
if [[ $? -gt 1 ]]; then
116+
echo "scalelite check error: $count"
117+
exit "$STATE_UNKNOWN"
118+
fi
119+
120+
if [ "$count_eo" -gt "$warning" ]; then
121+
echo "check ok - $count_eo out of $count nodes are live"
122+
exitstatus=$STATE_OK
123+
else
124+
if [ "$count_eo" -gt "$critical" ]; then
125+
echo "check warning - $count_eo out of $count nodes are live"
126+
exitstatus=$STATE_WARNING
127+
else
128+
echo "check critical - $count_eo out of $count nodes are live"
129+
exitstatus=$STATE_CRITICAL
130+
fi
131+
fi
132+
133+
exit "$exitstatus"

0 commit comments

Comments
 (0)