cacti分组发飞信模块开发

功能:
1、在阈值配置页面添加手机号码输入框
2、实现不同阈值发送不同的手机号码
实现过程:
1、修改数据库:修改thold_data,和thold_template表分别添加字段“mobile”,varchar类型,长度15
2、修改thold.php
1)在$form_array = array()的最后添加代码:
'mobile' => array(
                        'friendly_name' => '报警短信手机号码',
                        'method' => 'textarea',
                        'textarea_rows' => 3,
                        'textarea_cols' => 50,
                        'description' => '您可以在这里指定接收报警短信的手机号码(多个手机号码用英文逗号分隔)',
                        'value' => isset($thold_item_data['mobile']) ? $thold_item_data['mobile'] : ''
                ),
2)在_f.notify_extra.disabled = status;的下面添加代码:
_f.mobile.disabled = status;
3、用php封装飞信发送接口得到PHPFetion.php,放到plugins/thold/下
4、修改thold_functions.php
1)在开头添加代码
require 'PHPFetion.php';
function sendsms($mobile,$sms){
        $fetion = new PHPFetion('手机号码', '飞信密码'); // 手机号、飞信密码
        $fetion->send($mobile, $sms); // 接收人手机号、飞信内容
}
2)在thold_check_threshold函数中添加代码:$mobile = $item['mobile'];
3)在所有下面代码的后面
if (trim($alert_emails) != '')
    thold_mail($alert_emails, '', $subject, $msg, $file_array);
添加发送飞信代码
if (trim($mobile) != '')
    sendsms($mobile,$subject);
4)在
$save['notify_extra'] = (trim($_POST['notify_extra'])) == '' ? '' : $_POST['notify_extra'];
的下面添加代码:
$save['mobile'] = (trim($_POST['mobile'])) == '' ? '' : $_POST['mobile'];
5)在
$insert['notify_extra'] = $template[$y]['notify_extra'];
的下面添加代码:
$insert['mobile'] = $template[$y]['mobile'];
6)在
thold_data.notify_extra = thold_template.notify_extra,
的下面添加代码:
thold_data.mobile = thold_template.mobile,
7)在
thold_data.notify_extra = thold_template.notify_extra,
的下面添加代码:
thold_data.mobile = thold_template.mobile,
8)在
if (trim($alert_emails) != '' && $item['restored_alert'] != 'on')
    thold_mail($alert_emails, '', $subject, $msg, $file_array);
的下面添加代码:
if (trim($mobile) != '' && $item['restored_alert'] != 'on')
    sendsms($mobile,$subject);
5、修改thold_templates.php
1)在$form_array = array()的最后添加代码:
'mobile' => array(
                        'friendly_name' => '报警短信手机号码',
                        'method' => 'textarea',
                        'textarea_rows' => 3,
                        'textarea_cols' => 50,
                        'description' => '您可以在这里指定接收报警短信的手机号码(多个手机号码用英文逗号分隔)',
                        'value' => isset($thold_item_data['mobile']) ? $thold_item_data['mobile'] : ''
                ),
2)在$save['notify_extra'] = $_POST['notify_extra'];的下面添加代码:
$save['mobile'] = $_POST['mobile'];
6、修改thold.sql
1)在notify_extra varchar(255) NOT NULL default '',的下面添加代码:
mobile varchar(15) NOT NULL default '',
2)在`notify_extra` varchar(255) default NULL,的下面添加代码:
`mobile` varchar(15) default NULL,
7、修改thold_add.php
在$insert['notify_extra'] = $template['notify_extra'];的下面添加代码:
$insert['mobile'] = $template['mobile'];
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值