#!/bin/bash
mysql='mysql -uroot -p123456 -h192.168.1.100 -P3308 -b operation' #登陆到operation库中
datetime=`date +%Y-%m-%d -d 20day `
url="https://oapi.dingtalk.com/robot/send?access_token="
get_end=`echo "select name from domain where end_time < \"$datetime\" " | $mysql` #通过记录在domain表的数据进行判断
function send_msg() #钉钉机器人使用curl发送信息
{
message=$1
curl -H 'Content-Type: application/json' -X POST $url -d \
"{
'msgtype':'text',
'text':{
'content':\"$message\"
}
}"
}
x=0
for i in $get_end
do
x=$[ x + 1 ]
if [ $x -eq 1 ];then #获取即将到期的所有数据
continue
fi
send_msg "[ "$i" ]ssl证书即将过期请登陆[ 192.168.0.253:33086 ]数据库获取详细信息" #
done