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