46
46
# 20210504 1.6.0 Add usage performance data on single cluster check, fix project check #
47
47
# 20210824 1.6.1 Fix cluster and project not found error (#24) #
48
48
# 20211021 1.7.0 Check for additional node (pressure) conditions (#27) #
49
+ # 20211201 1.7.1 Fix cluster state detection (#26) #
49
50
# #########################################################################################
50
51
# (Pre-)Define some fixed variables
51
52
STATE_OK=0 # define the exit code if status is OK
@@ -54,7 +55,7 @@ STATE_CRITICAL=2 # define the exit code if status is Critical
54
55
STATE_UNKNOWN=3 # define the exit code if status is Unknown
55
56
export PATH=/usr/local/bin:/usr/bin:/bin:$PATH # Set path
56
57
proto=http # Protocol to use, default is http, can be overwritten with -S parameter
57
- version=1.7.0
58
+ version=1.7.1
58
59
59
60
# Check for necessary commands
60
61
for cmd in jq curl [
@@ -193,8 +194,15 @@ if [[ -z $clustername ]]; then
193
194
do
194
195
# echo $cluster # For Debug
195
196
clusteralias=$( echo " $api_out_clusters " | jq -r ' .data[] | select(.id == "' ${cluster} ' ")|.name' )
197
+ declare -a clusterstate=( $( echo " $api_out_clusters " | jq -r ' .data[] | select(.id == "' ${cluster} ' ") | .state' ) )
196
198
declare -a component=( $( echo " $api_out_clusters " | jq -r ' .data[] | select(.id == "' ${cluster} ' ") | .componentStatuses[].name' ) )
197
199
declare -a healthstatus=( $( echo " $api_out_clusters " | jq -r ' .data[] | select(.id == "' ${cluster} ' ") | .componentStatuses[].conditions[].status' ) )
200
+
201
+ if [[ " ${clusterstate} " != " active" ]]; then
202
+ componenterrors[$e ]=" cluster ${clusteralias} is in ${clusterstate} state -"
203
+ clustererrors[$e ]=" ${cluster} "
204
+ fi
205
+
198
206
c=0
199
207
for status in ${healthstatus[*]}
200
208
do
230
238
fi
231
239
232
240
clusteralias=$( echo " $api_out_single_cluster " | jq -r ' .name' )
241
+ clusterstate=$( echo " $api_out_single_cluster " | jq -r ' .state' )
233
242
declare -a component=( $( echo " $api_out_single_cluster " | jq -r ' .componentStatuses[].name' ) )
234
243
declare -a healthstatus=( $( echo " $api_out_single_cluster " | jq -r ' .componentStatuses[].conditions[].status' ) )
235
244
@@ -269,14 +278,15 @@ else
269
278
# remove unit from requested_cpu
270
279
requested_cpu=( $( echo " ${requested_cpu} " | sed ' s/[a-zA-Z]*$//g' ) )
271
280
281
+ if [[ " ${clusterstate} " != " active" ]]; then
282
+ componenterrors+=" cluster ${clusteralias} is in ${clusterstate} state -"
283
+ fi
272
284
273
- i=0
274
285
for status in ${healthstatus[*]}
275
286
do
276
287
if [[ ${status} != True ]]; then
277
- componenterrors[ $i ] =" ${component[$i]} is not healthy -"
288
+ componenterrors+ =" ${component[$i]} is not healthy -"
278
289
fi
279
- let i++
280
290
done
281
291
282
292
if [[ ${# componenterrors[*]} -gt 0 ]]
0 commit comments