From e07de733e8b371505a7ee7cadbf5d4fc32a55926 Mon Sep 17 00:00:00 2001 From: "Hahn Axel (hahn)" <axel.hahn@iml.unibe.ch> Date: Wed, 6 Oct 2021 12:51:44 +0200 Subject: [PATCH] add check_ssl_certs --- check_ssl_certs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/check_ssl_certs b/check_ssl_certs index 5d4b71c..9a1a5e6 100755 --- a/check_ssl_certs +++ b/check_ssl_certs @@ -112,7 +112,7 @@ for mycert in $( ls -1 $filelist 2>/dev/null ) do iCounter=$iCounter+1 data=$(openssl x509 -noout -text -in $mycert 2>/dev/null ) - mySubject=$( echo "$data" | grep "Subject:\ CN\ =\ " | cut -f 2- -d "=" | grep -v ",") + mySubject=$( echo "$data" | grep "Subject:\ CN\ =\ " | grep -v "," | cut -f 2- -d "=" | cut -c 2- ) if [ -z "$mySubject" ]; then bHasWarning=true fullstatus="${fullstatus} @@ -124,8 +124,8 @@ do typeset -i iExpire=$( date +%s -d "$dateExpire" ) typeset -i iLeft=($iExpire-$iNow)/60/60/24 - if [ $iLeft -lt $iWarn ]; then - if [ $iLeft -lt $iCrit ]; then + if [ $iLeft -le $iWarn ]; then + if [ $iLeft -le $iCrit ]; then bHasCritical=true if [ $iLeft -lt 0 ]; then result="EXPIRED ALREADY" @@ -141,7 +141,7 @@ do fi shortstatus="${shortstatus}${result} ${mySubject} [${iLeft}d] | " fullstatus="${fullstatus} ------ $iCounter/ $iTotal: ${mySubject} - $iLeft days +----- [$iCounter of $iTotal] ${mySubject} - expires in $iLeft days $( echo "$data" | grep -E "(DNS:|Issuer:|Not\ |Subject:)" | sed 's#^\ *##g') File: $mycert " @@ -164,7 +164,7 @@ fi ph.status "SSL certs | $shortstatus" echo "$fullstatus" -echo "INFO: warning below $iWarn d before expiration; raise to critical $iCrit days before" +echo "INFO: warning starts $iWarn d before expiration, raising to critical $iCrit days before" echo ph.exit -- GitLab