Skip to content

Commit 7eb979b

Browse files
authored
Fix/handle 503 errors with curl exit code 0 (#21)
1 parent a174847 commit 7eb979b

1 file changed

Lines changed: 10 additions & 3 deletions

File tree

check_es_system.sh

Lines changed: 10 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@
2020
# You should have received a copy of the GNU General Public License #
2121
# along with this program; if not, see <https://www.gnu.org/licenses/>. #
2222
# #
23-
# Copyright 2016,2018,2019 Claudio Kuenzler #
23+
# Copyright 2016,2018-2020 Claudio Kuenzler #
2424
# Copyright 2018 Tomas Barton #
2525
# #
2626
# History: #
@@ -45,14 +45,15 @@
4545
# 20190909: Handle correct curl return codes #
4646
# 20190924: Missing 'than' in tps output #
4747
# 20191104: Added master check type #
48+
# 20200401: Fix/handle 503 errors with curl exit code 0 (issue #20) #
4849
################################################################################
4950
#Variables and defaults
5051
STATE_OK=0 # define the exit code if status is OK
5152
STATE_WARNING=1 # define the exit code if status is Warning
5253
STATE_CRITICAL=2 # define the exit code if status is Critical
5354
STATE_UNKNOWN=3 # define the exit code if status is Unknown
5455
export PATH=$PATH:/usr/local/bin:/usr/bin:/bin # Set path
55-
version=1.7.0
56+
version=1.7.1
5657
port=9200
5758
httpscheme=http
5859
unit=G
@@ -61,7 +62,7 @@ max_time=30
6162
################################################################################
6263
#Functions
6364
help () {
64-
echo -e "$0 $version (c) 2016-$(date +%Y) Claudio Kuenzler and contributors
65+
echo -e "$0 $version (c) 2016-$(date +%Y) Claudio Kuenzler and contributors (open source rulez!)
6566
6667
Usage: ./check_es_system.sh -H ESNode [-P port] [-S] [-u user] [-p pass] -t checktype [-d int] [-o unit] [-w int] [-c int] [-m int]
6768
@@ -183,6 +184,9 @@ if [[ -z $user ]]; then
183184
elif [[ $esstatusrc -eq 28 ]]; then
184185
echo "ES SYSTEM CRITICAL - server did not respond within ${max_time} seconds"
185186
exit $STATE_CRITICAL
187+
elif [[ $esstatus =~ "503" ]]; then
188+
echo "ES SYSTEM CRITICAL - Elasticsearch not available: ${host}:${port} return error 503"
189+
exit $STATE_CRITICAL
186190
fi
187191
# Additionally get cluster health infos
188192
if [ $checktype = status ]; then
@@ -205,6 +209,9 @@ if [[ -n $user ]] || [[ -n $(echo $esstatus | grep -i authentication) ]] ; then
205209
elif [[ $esstatusrc -eq 28 ]]; then
206210
echo "ES SYSTEM CRITICAL - server did not respond within ${max_time} seconds"
207211
exit $STATE_CRITICAL
212+
elif [[ $esstatus =~ "503" ]]; then
213+
echo "ES SYSTEM CRITICAL - Elasticsearch not available: ${host}:${port} return error 503"
214+
exit $STATE_CRITICAL
208215
elif [[ -n $(echo $esstatus | grep -i "unable to authenticate") ]]; then
209216
echo "ES SYSTEM CRITICAL - Unable to authenticate user $user for REST request"
210217
exit $STATE_CRITICAL

0 commit comments

Comments
 (0)