Skip to content

Commit fc3cc6e

Browse files
committed
remove brief option
that adds complexity, isn't really needed (apparently except for zabbix use) and seems to have several bugs
1 parent 4823ea7 commit fc3cc6e

File tree

1 file changed

+2
-35
lines changed

1 file changed

+2
-35
lines changed

check_kubernetes.sh

Lines changed: 2 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,6 @@ usage() {
3333
- Unbound Persistent Volumes in unboundpvs mode; default is 5
3434
- Job failed count in jobs mode; default is 2
3535
- Pvc storage utilization; default is 90%
36-
-b Brief mode (more suitable for Zabbix)
3736
-M EXIT_CODE Exit code when resource is missing; default is 2 (CRITICAL)
3837
-h Show this help and exit
3938
@@ -54,20 +53,15 @@ usage() {
5453
exit 2
5554
}
5655

57-
BRIEF=0
5856
TIMEOUT=15
5957
unset NAME
6058

6159
die() {
62-
if [ "$BRIEF" = 1 ]; then
63-
echo "-1"
64-
else
6560
echo "$1"
66-
fi
6761
exit "${2:-2}"
6862
}
6963

70-
while getopts ":m:M:H:T:t:K:N:n:o:c:w:bh" arg; do
64+
while getopts ":m:M:H:T:t:K:N:n:o:c:w:h" arg; do
7165
case $arg in
7266
h) usage ;;
7367
m) MODE="$OPTARG" ;;
@@ -81,7 +75,6 @@ while getopts ":m:M:H:T:t:K:N:n:o:c:w:bh" arg; do
8175
n) NAME="$OPTARG" ;;
8276
w) WARN="$OPTARG" ;;
8377
c) CRIT="$OPTARG" ;;
84-
b) BRIEF=1 ;;
8578
*) usage ;;
8679
esac
8780
done
@@ -190,10 +183,7 @@ mode_nodes() {
190183
EXITCODE="$MISSING_EXITCODE"
191184
else
192185
OUTPUT="OK. ${#nodes[@]} nodes are Ready"
193-
BRIEF_OUTPUT="${#nodes[@]}"
194186
fi
195-
else
196-
BRIEF_OUTPUT="-1"
197187
fi
198188
}
199189

@@ -214,9 +204,7 @@ mode_unboundpvs() {
214204
select(.status.phase!=\"Bound\") | \
215205
\"\(.metadata.name):\(.status.phase):\(.spec.claimRef.uid)\"")
216206

217-
BRIEF_OUTPUT="${#pvsArr[*]}"
218207
if [ ${#unboundPvsArr[*]} -gt 0 ]; then
219-
BRIEF_OUTPUT="-${#unboundPvsArr[*]}"
220208
if [ ${#unboundPvsArr[*]} -ge "$CRIT" ]; then
221209
OUTPUT="CRITICAL. Unbound persistentvolumes:\n$OUTPUT"
222210
EXITCODE=2
@@ -355,7 +343,6 @@ mode_tls() {
355343
done
356344
done
357345

358-
BRIEF_OUTPUT="$count_ok"
359346
if [ $EXITCODE = 0 ]; then
360347
if [ -z "$ns" ]; then
361348
OUTPUT="No TLS certs found"
@@ -436,12 +423,6 @@ mode_pods() {
436423
done
437424
done
438425

439-
if [ "$max_restart_count" -ge "$WARN" ]; then
440-
BRIEF_OUTPUT="-$max_restart_count"
441-
else
442-
BRIEF_OUTPUT="$count_ready"
443-
fi
444-
445426
if [ -z "$ns" ]; then
446427
OUTPUT="No pods found"
447428
EXITCODE="$MISSING_EXITCODE"
@@ -493,7 +474,6 @@ mode_deployments() {
493474
done
494475
done
495476

496-
BRIEF_OUTPUT="$count_avail"
497477
if [ $EXITCODE = 0 ]; then
498478
if [ -z "$ns" ]; then
499479
OUTPUT="No deployments found"
@@ -554,7 +534,6 @@ mode_daemonsets() {
554534
done
555535
done
556536

557-
BRIEF_OUTPUT="$count_avail"
558537
if [ $EXITCODE = 0 ]; then
559538
if [ -z "$ns" ]; then
560539
OUTPUT="No daemonsets found"
@@ -616,7 +595,6 @@ mode_replicasets() {
616595
done
617596
done
618597

619-
BRIEF_OUTPUT="$count_avail"
620598
if [ $EXITCODE = 0 ]; then
621599
if [ -z "$ns" ]; then
622600
OUTPUT="No replicasets found"
@@ -679,7 +657,6 @@ mode_statefulsets() {
679657
done
680658
done
681659

682-
BRIEF_OUTPUT="$count_avail"
683660
if [ $EXITCODE = 0 ]; then
684661
if [ -z "$ns" ]; then
685662
OUTPUT="No statefulsets found"
@@ -780,16 +757,6 @@ case "$MODE" in
780757
(*) usage ;;
781758
esac
782759

783-
if [ "$BRIEF" = 1 ]; then
784-
if [ "$EXITCODE" = 0 ]; then
785-
echo "${BRIEF_OUTPUT:-1}"
786-
elif [ -z "$BRIEF_FAIL_OUTPUT" ]; then
787-
echo "${BRIEF_OUTPUT:-0}"
788-
else
789-
echo "${BRIEF_FAIL_OUTPUT}"
790-
fi
791-
else
792-
echo "$OUTPUT"
793-
fi
760+
printf "$OUTPUT"
794761

795762
exit $EXITCODE

0 commit comments

Comments
 (0)