Created
October 5, 2022 04:04
-
-
Save Abdukosim/3329745108a9a571ff64fc76ba75257b to your computer and use it in GitHub Desktop.
zabbix ssl check
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
| #SSL | |
| HOST=$1 | |
| PORT=$2 | |
| expires_in(){ | |
| EXP_DATE=$( | |
| echo "" | openssl s_client -connect $HOST:$PORT 2>/dev/null \ | |
| | sed -n '/-----BEGIN CERTIFICATE-----/,/-----END CERTIFICATE-----/p' \ | |
| | openssl x509 -noout -in - -enddate \ | |
| | sed 's/notAfter=//' | |
| ) | |
| DAYS_LEFT=$(( ($(date -d "$EXP_DATE" +%s) - $(date -d "now" +%s) ) / 86400 )) | |
| #echo $DAYS_LEFT days | |
| echo $DAYS_LEFT | |
| #exit | |
| } | |
| echo $(expires_in) | |
| #./ssl_chek.sh opennet.ru 443 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment