« Posts tagged thold

Cacti中为每主机定义不同的Down机报警邮件接收地址

cacti_down_alert_email
(主机=Host=Device)
背景:默认情况下Cacti的Down机邮件报警功能只能设置一个统一的接受地址,不够人性化。特是对于集团性质的企业,通常不同的主机是由不同的人员来负责的,因此,为每主机定义不同的邮件接收地址就很有必要。
环境:Cacti 0.8.7g Monitor1.2.1 Thold 0.4.1

Setp1: 给cacti.host表增加一个字段`alertMail`

ALTER TABLE host ADD laertmail varchar(200) default ” not null AFTER monitor_text;

Setp2: 修改脚本/plugins/monitor/setup.php, 设置Host管理表单项,找到monitor_config_form()方法,在$fields_host_edit3['monitor_text']数组变量下加入$fields_host_edit3['alertMail']数组,如下

PHP
	$fields_host_edit3['alertMail'] = array(
	"method" => "textbox",
	"friendly_name" => "Alert Email",
	"description" => "This is the email address that will be sent when this host is reported as down.",
	"value" => "|arg1:alertMail|",
	"max_length" => "250",
);

找到monitor_api_device_save()方法,在return $save;一行的上面,增加如下代码

PHP
if (isset($_POST['alertMail']))
	$save['alertMail'] = form_input_validate($_POST['alertMail'], 'alertMail', '', true, 3);
else
                $save['alertMail'] = form_input_validate('', 'alertMail', '', true, 3);

»Read More

指定Cacti Thold邮件报警的”From”地址

公司换了Lotus邮件服务器,更换后不能任意设置“From Email Address”,导致Cacti Thold不能正常发送报警邮件,提示“554 Sender address not allowed for this authenticated session”。

修改/plugins/thold/thold_functions.php

查找

PHP
if ($from == '') {
	if (isset($_SERVER['HOSTNAME'])) {
		$from = 'Cacti@' . $_SERVER['HOSTNAME'];
	} else {
		$from = 'Cacti@cactiusers.org';
	}
}

修改为,即指定Settings->Mail/DNS->Emailing Options->From Email Address中填写的邮件地址

PHP
if ($from == '') {
	$from = read_config_option('settings_from_email');
}

给Cacti增加短信提醒功能

snap1

0.本方法使用it-adv的”飞信机器人”来发送短信,关于飞信机器人的安装与使用,这里不多说了,请去官网找资料.因为要用php的exec()函数去运行该组件,所以要给fetion必要的权限,我这里给fetion的install目录www-data权限.我使用Ubuntu9.04+cacti0.87c+thold0.4.1.本方法主要修改thold插件,所以请注意thold的版本.

sudo chown www-data -R install
sudo chgrp www-data -R install

1.数据库中thold_data表中增加字段`notify_extra_sms` varchar(255)型,用于存储接收短信的手机号码

2.将thold插件目录下的thold.php做如下修改:
向$form_array = array()数组里面追加如下代码(页面上的输入框):

PHP
1
2
3
4
5
6
7
'notify_extra_sms' = array(
            'friendly_name' = 'Extra Alert SMS',
            'method' = 'textbox',
            'max_length' = 20,
            'description' = 'You may specify here extra MP number to receive alerts SMS for this data source (comma separated)',
            'value' = isset($thold_item_data['notify_extra_sms']) ? $thold_item_data['notify_extra_sms'] : ''
        ),

»Read More