add certcheck

This commit is contained in:
mrbesen 2019-05-19 03:57:33 +02:00
parent b42c0244f1
commit 6b09d55ac7
3 changed files with 20 additions and 0 deletions

7
bot.sh
View File

@ -35,3 +35,10 @@ if [ "$mem" -gt "$memlimit" ]; then
send "warnung%20Memory%20Usage%20is%20high%20$mem%25"
fi
#CheckCerts
. cert.sh
checkCert "/etc/letsencrypt/live/mrbesen.de/cert.pem"
if [ "$?" -gt "0" ]; then
echo "cert expired!"
send "warnung%20cert%20expires%20soon"
fi

11
cert.sh Executable file
View File

@ -0,0 +1,11 @@
#!/bin/bash
function checkCert {
valid=$(openssl x509 -enddate -noout -in "$1" | cut -b 10-)
valids=$(date -d "${valid}" +%s)
limit=$(date -d "-${certlimit}" +%s)
if [ "${valids}" -lt "${limit}" ]; then
return 1
fi
return 0
}

View File

@ -17,3 +17,5 @@ hddlimit="50"
hdd="/dev/sda1"
memlimit="90"
certlimit="1 week"