[心得] Cacti+SMS短信告警

楼主: xxoo1122 (一个连IE6都能相容的男人)   2014-08-23 13:31:08
Cacti一直都是网管人的最爱,Cacti也推出一段时间了但是一直没有好的SMS短信告警
的外挂,势必得自己改程式
解题思路:要在thold的email alert function 中另外call sms的php程式
并且把alert message传递到sms的php程式.
1.首先得安装好Cacti+thold
2.接着我们的先选好一家短信服务商,我用的是every8d(http://tw.every8d.com/),
可以在every8d的官方网站找到API2.1 的范例程式
(http://tw.every8d.com/template/every8d/document/download.html),
在php的资料夹中有两个档案index.php,SMSHttp.php,避免档名重复所以把index.php
改成sms.php,然后把这两个php档放在/usr/share/cacti/plugins/thold 中
3.再来修改thold_functions.php这只程式,找到
function thold_mail($to, $from, $subject, $message, $filename, $headers = '')
移动到function 的最尾端可以看到return ''; ,在return '';前加入
$sms = shell_exec('php /usr/share/cacti/plugins/thold/sms.php '
.escapeshellarg($message).'');
4.修改sms.php,将改为 $content = $argv[1];
5.大功告成,这样cacti就能发短信了
6.你可以在thold中定义 ex:CPU使用率,Interface流量,网络latency超过多少的值
就发告警
最后收到的短信会是这样
http://ppt.cc/ifgF
作者: shuinedu (成长只有一次)   2014-08-23 15:30:00
好文帮推
作者: occupy222   2014-08-26 03:15:00
作者: renice (山水有相逢)   2014-08-26 16:29:00
真不想三不五时收系统短信
作者: JOHN001123 (阿机)   2014-08-27 13:49:00
短信人生 (叹

Links booklink

Contact Us: admin [ a t ] ucptt.com