- 论坛徽章:
- 0
|
回复 #1 lingfengxp 的帖子
推荐你用nagios实现
nagios的实现方式参考如下
[root@nagios etc]# vi commands.cfg 在配置命令添加短信报警
#service notify by sms
define command {
command_name service-notify-by-sms
command_line /usr/local/bin/sms_send.sh "'$HOSTADDRESS$' $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$"
}
#host-notify-by-sms
define command {
command_name host-notify-by-sms
command_line /usr/local/bin/sms_send.sh "Host $HOSTSTATE$ alert for $HOSTNAME$! on '$DATETIME$'"
}
编写SMS_SEND脚本
[root@nagios etc]# cat /usr/local/bin/sms_send.sh
#!/bin/bash
msg="$1"
for phone_num in 15811111111 13411111*** 1351075***** 131448*****
do
wget -O /dev/null "http://203.86.*.*0:8009/test/smstest.aspx?phone=$phone_num&content=$msg"
done
[root@nagios etc]#
[root@nagios etc]# vi contacts.cfg
define contact{
contact_name nagios
# use generic-contact ; Inherit default values from generic-contact template (defined above)
service_notification_period 24x7
# alisa system administrator
host_notification_period 24x7
service_notification_options w,u,c,r
host_notification_options d,u,r
service_notification_commands service-notify-by-sms,notify-service-by-email
host_notification_commands notify-host-by-email,host-notify-by-sms
# email lvsheat@qq.com
# pager 13999999999
email lvsheat@qq.com ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
}
通过日志即可看见报警短信邮件发出 |
|