监控域名,证书过期时间

#!bin/bash
date_Now=$(date +%Y%m%d)
set -e
set -x
# 这里定义发送的消息艾特多个人,
atMobiles=xxxxxxxx
keyword="告警"
 
dintalkurl="https://oapi.dingtalk.com/robot/send?access_token=993fae78d36f623907ae2a0be5123a3be6a85dab7a19556ff32d6fcebfe54y7c"

cat /etc/ansible/domain_ssl/domain_ssl.txt | while read line
do
	Type=`echo $line | awk '{print $1}'`
	Name=`echo $line | awk '{print $2}'`
	expiration=`echo $line | awk '{print $3}'`
	time1=`date +%s -d "$expiration"`
	time2=`date +%s -d "$date_Now"`
	expiration_date=$(((time1-$time2)/86400))
	if [ $expiration_date -le 45 ];then
	msg="Type:$Type,Name:$Name,剩余有效天数:$expiration_date 天,过期时间:$expiration,请及时续费."
	curl ${dintalkurl} \
         -H 'Content-Type: application/json' \
           -d '{"msgtype": "text",
                "text": {
                     "content": "'"$msg"'"
                },"at": {
                        "atMobiles": ['${atMobiles}']
                }
              }'

	else
	continue
	fi
done
cat domain_ssl.txt
Domain	xxxxx.co.id	20240504
Domain	xxxx.id		20240524
Domain	xxxx.id		20221007
Domain	xxx.id		20220923
Domain	xxx.id		20220923
Domain	xxxx.net	20221207
Domain	xxxx.com	20220819
Hosting	xxxxx.com	20220819
SSL     xxxxx.com   20220825

  

  

posted @ 2022-04-08 15:33  MlxgzZ  阅读(69)  评论(1编辑  收藏  举报