diff --git a/check_ssl_certs b/check_ssl_certs index 5d4b71c6a151a1ba9cb10e1f498054b54c0c70c2..9a1a5e6817de2630403134e47e852aee0e6c7961 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