#!/bin/bash
WebName="xxx.xxx.com"
Port="443"
Cert_END_Time=$(echo | openssl s_client -servername ${WebName} -connect ${WebName}:${Port} 2> /dev/null | openssl x509 -noout -dates | grep 'After' | awk -F '=' '{print $2}' | awk '{print $1,$2,$4}')
Cert_NED_TimeStamp=$(date +%s -d "$Cert_END_Time")
Create_TimeStamp=$(date +%s)
Rest_Time=$(expr $(expr $Cert_NED_TimeStamp - $Create_TimeStamp) / 86400)
echo "$WebName 网站的 SSL 证书还有 $Rest_Time 天后到期" > ssl-monitor.txt
WebHook='https://oapi.dingtalk.com/robot/send?access_token=根据自己的环境来定义'
curl "${WebHook}" -H 'Content-Type: application/json' -d '
{"msgtype": "text","text": { "content": "上线通知'"$(cat ssl-monitor.txt)"'"}
}' &> ssl_check.log
本文来自互联网用户投稿,文章观点仅代表作者本人,不代表本站立场,不承担相关法律责任。如若转载,请注明出处。 如若内容造成侵权/违法违规/事实不符,请点击【内容举报】进行投诉反馈!