免费注册 查看新帖 |

Chinaunix

  平台 论坛 博客 文库
12下一页
最近访问板块 发新帖
查看: 7734 | 回复: 10

Cacti 短信报警 [复制链接]

论坛徽章:
0
发表于 2008-11-18 18:23 |显示全部楼层
20可用积分
我按照下面这个文档做了一下短信报警:
http://blog.chinaunix.net/u/249/showart_1162952.html

可是我根本找不到:
thold–functions.php里的thold_mail($global_alert_address, ”, $subject, $msg, $file_array);

我现在用thold是0.3.9的版本

大哥大姐们帮帮忙!谢谢!

最佳答案

查看完整内容

thold_mail($alert_emails, '', $subject, $msg, $file_array); 这句根本就找不到的不用找了 肯定不对的 ,我现在把exec("echo $subject >> /usr/share/cacti/plugins/thold/alert.log");exec("sh /usr/share/cacti/plugins/thold/sendsms.sh");这2句 加在 include_once($config["base_path"] . "/plugins/settings/include/mailer.php")下面能实现短信报警

论坛徽章:
0
发表于 2008-11-18 18:23 |显示全部楼层
thold_mail($alert_emails, '', $subject, $msg, $file_array); 这句根本就找不到的不用找了 肯定不对的 ,我现在把
exec("echo $subject >> /usr/share/cacti/plugins/thold/alert.log");
exec("sh /usr/share/cacti/plugins/thold/sendsms.sh");
这2句 加在 include_once($config["base_path"] . "/plugins/settings/include/mailer.php")下面能实现短信报警

论坛徽章:
8
戌狗
日期:2014-09-26 16:39:44水瓶座
日期:2014-10-10 02:06:57金牛座
日期:2014-10-11 23:04:042015亚冠之首尔
日期:2015-06-23 15:37:0015-16赛季CBA联赛之天津
日期:2016-01-22 18:58:2915-16赛季CBA联赛之佛山
日期:2016-05-31 19:18:0815-16赛季CBA联赛之同曦
日期:2016-08-10 16:26:3315-16赛季CBA联赛之辽宁
日期:2018-01-10 11:47:40
发表于 2008-11-18 18:41 |显示全部楼层
不知道你的插件装了没有

论坛徽章:
0
发表于 2008-11-18 21:28 |显示全部楼层

回复 #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 ******
        }

通过日志即可看见报警短信邮件发出

论坛徽章:
0
发表于 2008-11-19 09:36 |显示全部楼层
谢谢上面的两位,CACTI已经用了一段时间了,上头指定的。

我的thold已经安装了,是0.3.9

我在网上也看到很多人在问相关的问题。

论坛徽章:
0
发表于 2008-11-19 10:06 |显示全部楼层

回复 #1 lingfengxp 的帖子

我也是这情况。。。

论坛徽章:
0
发表于 2008-11-19 10:11 |显示全部楼层
原帖由 lingfengxp 于 2008-11-18 18:23 发表
我按照下面这个文档做了一下短信报警:
http://blog.chinaunix.net/u/249/showart_1162952.html

可是我根本找不到:
thold–functions.php里的thold_mail($global_alert_address, ”, $subject, $msg, $fi ...


http://new.qzone.qq.com/56802890/blog/1226897360
这篇文章也许能帮到你,呵呵,我们公司的用的就是这个!!!

论坛徽章:
0
发表于 2008-11-19 10:29 |显示全部楼层
thold–functions.php 是一个php文件,
下面两句的意思是把$subject读出来并写到/usr/share/cacti/plugins/thold/alert.log里。
thold_mail($alert_emails, '', $subject, $msg, $file_array);
exec("echo $subject >> /usr/share/cacti/plugins/thold/alert.log");
exec("/usr/share/cacti/plugins/thold/sendsms.sh");

现在是不能把$subject读出来并写到/usr/share/cacti/plugins/thold/alert.log里。
如果能写了,再执行下一步就应该可以了。

是不是语法有错误?

论坛徽章:
0
发表于 2008-11-19 10:33 |显示全部楼层
加我 QQ 363671802 我和你情况一样 和你讨论下

论坛徽章:
0
发表于 2008-11-27 09:18 |显示全部楼层
thold 这个不好用,经常会乱报,还是nagios实时监控功能好
您需要登录后才可以回帖 登录 | 注册

本版积分规则 发表回复

  

北京盛拓优讯信息技术有限公司. 版权所有 京ICP备16024965号-6 北京市公安局海淀分局网监中心备案编号:11010802020122 niuxiaotong@pcpop.com 17352615567
未成年举报专区
中国互联网协会会员  联系我们:huangweiwei@itpub.net
感谢所有关心和支持过ChinaUnix的朋友们 转载本站内容请注明原作者名及出处

清除 Cookies - ChinaUnix - Archiver - WAP - TOP