Skip to content

Commit a8a4018

Browse files
author
MMA
committed
update usage
1 parent c56d51a commit a8a4018

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

check_kubernetes.sh

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,11 +28,13 @@ usage() {
2828
- Pod restart count in pods mode; default is 30
2929
- Job failed count in jobs mode; default is 1
3030
- Pvc storage utilization; default is 80%
31+
- APICERT expiration days for apicert mode; default is 30
3132
-c CRIT Critical threshold for
3233
- Pod restart count (in pods mode); default is 150
3334
- Unbound Persistent Volumes in unboundpvs mode; default is 5
3435
- Job failed count in jobs mode; default is 2
3536
- Pvc storage utilization; default is 90%
37+
- APICERT expiration days for apicert mode; default is 15
3638
-M EXIT_CODE Exit code when resource is missing; default is 2 (CRITICAL)
3739
-h Show this help and exit
3840
@@ -155,16 +157,18 @@ mode_apicert() {
155157
if [ -z "$APISERVER" ]; then
156158
die "Apiserver URL should be defined in this mode"
157159
fi
160+
WARN=${WARN:-30}
161+
CRIT=${CRIT:-15}
158162
APICERT=$(echo "$APISERVER" | awk -F "//" '{ print $2 }' | awk -F ":" '{ print $1 }')
159163
APIPORT=$(echo "$APISERVER" | awk -F "//" '{ print $2 }' | awk -F ":" '{ print $2 }')
160-
set ${APIPORT:=443}
164+
APIPORT=${APIPORT:=443}
161165
APICERTDATE=$(echo | openssl s_client -connect "$APICERT":"$APIPORT" 2>/dev/null | openssl x509 -noout -dates | grep notAfter | sed -e 's#notAfter=##')
162166
a=$(date -d "$APICERTDATE" +%s)
163167
b=$(date +%s)
164168
c=$((a-b))
165169
d=$((c/3600/24))
166170
echo "APICERT expires in $d days"
167-
if [ "$d" -gt "$WARN" ]; then
171+
if [ "$d" -gt "$WARN" ] && [ "$d" -gt "$CRIT" ]; then
168172
echo "APICERT is OK"
169173
elif [ "$d" -le "$WARN" ] && [ $d -gt "$CRIT" ]; then
170174
echo "APICERT is in WARN"

0 commit comments

Comments
 (0)