Skip to content

Commit ecd0a93

Browse files
author
Luca De Rugeriis
committed
Add critical threshold for TLS expiration days in TLS mode
1 parent 14a8dce commit ecd0a93

File tree

1 file changed

+6
-1
lines changed

1 file changed

+6
-1
lines changed

check_kubernetes.sh

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/bin/bash
22
# shellcheck disable=SC2181,SC2207,SC2199,SC2076
3-
#
43

54
##########################
65
# Perform checks against Kubernetes API or with tab help of kubectl utility
@@ -31,6 +30,7 @@ usage() {
3130
- Pvc storage utilization; default is 80%
3231
- API cert expiration days for apicert mode; default is 30
3332
-c CRIT Critical threshold for
33+
- TLS expiration days for TLS mode; default is 5
3434
- Pod restart count (in pods mode); default is 150
3535
- Unbound Persistent Volumes in unboundpvs mode; default is 5
3636
- Job failed count in jobs mode; default is 2
@@ -298,6 +298,7 @@ mode_pvc() {
298298

299299
mode_tls() {
300300
WARN=${WARN:-30}
301+
CRIT=${CRIT:-5}
301302

302303
count_ok=0
303304
count_warn=0
@@ -338,6 +339,10 @@ mode_tls() {
338339
((count_crit++))
339340
EXITCODE=2
340341
OUTPUT="$OUTPUT $ns/$cert is expired."
342+
elif [ "$diff" -le "$((CRIT*24*3600))" ]; then
343+
((count_crit++))
344+
EXITCODE=2
345+
OUTPUT="$OUTPUT $ns/$cert is about to expire in $((diff/3600/24)) days."
341346
elif [ "$diff" -le "$((WARN*24*3600))" ]; then
342347
((count_warn++))
343348
if [ "$EXITCODE" == 0 ]; then

0 commit comments

Comments
 (0)