Skip to content

Instantly share code, notes, and snippets.

@fluidum
Created August 13, 2020 12:41
Show Gist options
  • Save fluidum/b33833c1b5f6329b6afbfdb2aa379b42 to your computer and use it in GitHub Desktop.
Save fluidum/b33833c1b5f6329b6afbfdb2aa379b42 to your computer and use it in GitHub Desktop.
!/bin/bash
to="something@somegmail.com"
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