|
Server : Apache System : Linux 10-169-227-96.cprapid.com 3.10.0-1160.45.1.el7.x86_64 #1 SMP Wed Oct 13 17:20:51 UTC 2021 x86_64 User : kwssawblade ( 1099) PHP Version : 7.2.34 Disable Function : exec,passthru,shell_exec,system Directory : /opt/monitoring/ |
Upload File : |
#!/bin/bash
#*/15 * * * * sh /opt/monitoring/server-reboot.sh
WebHook='https://oapi.dingtalk.com/robot/send?access_token=b76d4264035eb54e14294a23c2f5707d8bb732758d12e86849e4cdef598c4011'
Server_name='独立主机18'
App_name='服务器重启监控'
function SendMsgToDingding() {
curl $WebHook -H 'Content-Type: application/json' -d "
{
'msgtype': 'text',
'text': {
'content': '$App_name\n告警信息:请注意\n$Server_name\nhome目录挂载丢失,服务器即将重启\n'
},
'at': {
'isAtAll': false
}
}" >/dev/null 2>&1
}
if [ `df -lh |grep home | grep -v grep | wc -l` == 0 ];then
SendMsgToDingding
/bin/sync
sleep 5
/bin/sync
sleep 5
/bin/sync
sleep 5
/sbin/reboot
fi