Skip to content

Commit 38f8819

Browse files
authored
Handle 403 forbidden error (#15) (#16)
1 parent 7856cae commit 38f8819

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

check_rancher2.sh

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@
3737
# 20190903 1.2.0 Allow self-signed certificates (-s) #
3838
# 20190913 1.2.1 Detect additional redirect (308) #
3939
# 20200129 1.2.2 Fix typos in workload perfdata (#11) and single cluster health (#12) #
40+
# 20200523 1.2.3 Handle 403 forbidden error (#15) #
4041
##########################################################################################
4142
# (Pre-)Define some fixed variables
4243
STATE_OK=0 # define the exit code if status is OK
@@ -45,7 +46,7 @@ STATE_CRITICAL=2 # define the exit code if status is Critical
4546
STATE_UNKNOWN=3 # define the exit code if status is Unknown
4647
export PATH=/usr/local/bin:/usr/bin:/bin:$PATH # Set path
4748
proto=http # Protocol to use, default is http, can be overwritten with -S parameter
48-
version=1.2.2
49+
version=1.2.3
4950

5051
# Check for necessary commands
5152
for cmd in jshon curl [
@@ -126,6 +127,8 @@ elif [[ $apicheck = 308 ]]
126127
then echo -e "CHECK_RANCHER2 UNKNOWN - Redirect detected. Maybe http to https? Use -S parameter."; exit ${STATE_UNKNOWN}
127128
elif [[ $apicheck = 401 ]]
128129
then echo -e "CHECK_RANCHER2 WARNING - Authentication failed"; exit ${STATE_WARNING}
130+
elif [[ $apicheck = 403 ]]
131+
then echo -e "CHECK_RANCHER2 WARNING - Access to API forbidden"; exit ${STATE_CRITICAL}
129132
elif [[ $apicheck -gt 499 ]]
130133
then echo -e "CHECK_RANCHER2 CRITICAL - API Returned HTTP $apicheck error"; exit ${STATE_CRITICAL}
131134
fi

0 commit comments

Comments
 (0)