(主机=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: 修改脚本
$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;一行的上面,增加如下代码
if (isset($_POST['alertMail'])) $save['alertMail'] = form_input_validate($_POST['alertMail'], 'alertMail', '', true, 3); else $save['alertMail'] = form_input_validate('', 'alertMail', '', true, 3);
Comments