#!/bin/Bashshell_user="Root"Shell_domain="Apache"shell_list="/root/ip_list"Shell_row=`Cat$shell _list |WC-l 'functionTrans_text () {text=$1Curl'https://oapi.dingtalk.com/robot/send?access_token=b4fcf5862088a1bc7f2bf66a'-H'Content-type:application/json'-D'{#指定钉钉机器人hook地址 "Msgtype":"text", "text": { "content":"'"$text"'" }, }'}functionapache_check_80 () {IP=$1URL="/ http $ip/index.html"Http_code= ' Curl-o/dev/NULL-S-W "%{http_code}" "${url}"` if[$HTTP _code! = $ ] ThenTrans_text"=================================================================\ n $ip Apache Server Status exception, Web page return code:'"$HTTP _code"'Please deal with it in time!\ n================================================================= \ n" fi} while true Doshell_list="/root/ip_list"Shell_row=`Cat$shell _list |WC-l ' forTempinch`seq 1$shell _row ' Doip_addr=`Cat$shell _list |Head-N $temp |Tail-N1' apache_check_80 $Ip _addr Done Sleep Ten Done
Polling detects Apache status and enables Spike alarms