Created
August 13, 2020 12:41
-
-
Save fluidum/b33833c1b5f6329b6afbfdb2aa379b42 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
!/bin/bash | |
to="[email protected]" | |
function status_check() { | |
if [ $? -ne 0 ]; then | |
echo "$1 failed" | mutt -s "ERROR: $PWD/$0" $to | |
echo ":(" | |
fi | |
} | |
hosts=( | |
'www.something.asdf' | |
'www.something.asdf2' | |
) | |
for host in "${hosts[@]}"; do | |
x=`echo | openssl s_client -servername $host -connect $host:443 2>/dev/null | openssl x509 -noout -dates | tail -1 | awk -F'=' '{print $NF}'` | |
A=`date '+%Y-%m-%d'` | |
B=`date -d "$x" '+%Y-%m-%d'` | |
C=$(( (`date -d $B +%s` - `date -d $A +%s`) / 86400 )) | |
#echo $host $C | |
if [ $C -lt 7 ]; then | |
echo "$host SSL failed, days remaining $C" | mutt -s "ERROR: $PWD/$0" $to | |
fi | |
status_check "openssl broke" | |
done | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment