Cacti 告警如何通过微信、短信、电话等方式通知

faq
monitor
alert
cacti
notification

#1
  1. 修改文件{cacti_home}/plugins/xxx/xxx_functions.php,直接调用 OneAlert API
  2. 代码
<?php
function onealert_for_cacti($msg, $subject) {
   $fields = array(
      "app"  =>  "Change-to-Your-appkey", // 登录 www.onealert.com,进入配置--应用页面获取
      "subject"  =>  $subject,
      "msg"  =>   $msg
   );
   $fieldsdate = json_encode($fields);
   $ch = curl_init("http://api.onealert.com/alert/api/event/cacti/new");
   curl_setopt($ch, CURLOPT_HEADER, 0);
   curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json'));
   curl_setopt($ch, CURLOPT_POST, 1);
   curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
   curl_setopt($ch, CURLOPT_POSTFIELDS, $fieldsdate);
   $output = curl_exec($ch);
   if(curl_errno($ch)){
      print curl_error($ch);
   }

   curl_close($ch);
   echo $output;
 }
 onealert_for_cacti("test-message","test-subject");