钉钉的群聊机器人很6,用途其实还有更多,大家自行发挥,这里仅做迁移备忘:
注意access_token换成自己的。
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
#!/bin/bash tmp=`uptime | awk -F "average: " '{print $2}'` u1=`echo $tmp | awk -F ", " '{print $1}'` u5=`echo $tmp | awk -F ", " '{print $2}'` u15=`echo $tmp | awk -F ", " '{print $3}'` fazhi=1.0 # Uptime异常阈值设置 if [ `expr $u1 \< $fazhi` -eq 0 ];then curl 'https://oapi.dingtalk.com/robot/send?access_token=XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX' \ -H 'Content-Type: application/json' \ -d '{"msgtype": "text", "text": {"content": "XXX网站 异常: '"$tmp"'"}}' fi |
自动执行,我这里是3分钟检查一次:
1 |
*/3 * * * * sh /root/uptime_check.sh >/dev/null 2>&1 & |