Skip to content

Commit 1859794

Browse files
author
MMA
committed
check the APIPORT before sslcert check
1 parent e259753 commit 1859794

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

check_kubernetes.sh

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -162,6 +162,11 @@ mode_apicert() {
162162
APICERT=$(echo "$APISERVER" | awk -F "//" '{ print $2 }' | awk -F ":" '{ print $1 }')
163163
APIPORT=$(echo "$APISERVER" | awk -F "//" '{ print $2 }' | awk -F ":" '{ print $2 }')
164164
APIPORT=${APIPORT:=443}
165+
timeout "$TIMEOUT" bash -c "</dev/tcp/$APICERT/$APIPORT" &>/dev/null
166+
if [ $? -ne 0 ]; then
167+
echo "APICERT is in UNKNOWN"
168+
exit 3
169+
fi
165170
APICERTDATE=$(echo | openssl s_client -connect "$APICERT":"$APIPORT" 2>/dev/null | openssl x509 -noout -dates | grep notAfter | sed -e 's#notAfter=##')
166171
a=$(date -d "$APICERTDATE" +%s)
167172
b=$(date +%s)
@@ -176,9 +181,6 @@ mode_apicert() {
176181
elif [ "$d" -le "$CRIT" ]; then
177182
echo "APICERT is in CRIT"
178183
EXITCODE=2
179-
else
180-
echo "APICERT is in UNKNOWN"
181-
EXITCODE=3
182184
fi
183185
}
184186

0 commit comments

Comments
 (0)