小宝长大了

5877126640_e001511362_b 5877126138_bf38b20308_b

»Read More

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');
}

Marc Jacobs Sunglasses MMJ 112/S AL0S2

给媳妇买了一副太阳镜.晒晒.

dsc_6470 dsc_6472 dsc_6474

»Read More

Microsoft IE9 Tee

昨天收到一个微软寄来的包裹,打开一看是一件微软IE9的Tee,估计是参加微软什么在线活动之类的纪念品吧,但具体是什么活动已经想不起来了.

来看看这件Tee吧,不知道我有没有勇气吧这种广告衫穿出去…

[正面]

dsc_6459

[反面]

dsc_6460

[领口特写]

dsc_6461

ipInfo.class.php更新

加入了64位与32位环境的判断(ip2long),更新了计算方法。

PHP
<?php
/*
* Leon
* http://nerrsoft.com
* leon@nerrsoft.com
* 2011-04-11
*/
class ipInfo{
 
    var $address;
    var $netbits;
 
    public function getIpInfo($ipStr){
        list($this->address, $this->netbits) = explode('/', $ipStr);
 
        $info['long']['mask'] = $this->netmask();   
        $info['ip']['mask'] = long2ip($info['long']['mask']);
 
        $info['long']['net'] = $this->network(); 
        $info['ip']['net'] = long2ip($info['long']['net']);
 
        $info['long']['begin'] = $info['long']['net'] + 1;
        $info['ip']['begin'] = long2ip($info['long']['begin']);
 
        $info['long']['end'] = abs($info['long']['mask']) + $info['long']['begin'] - 3;
        $info['ip']['end'] = long2ip($info['long']['end']);
 
        $info['long']['broacast'] = $this->broadcast();
        $info['ip']['broacast'] = long2ip($info['long']['broacast']);
 
        $info['count'] = $info['long']['broacast'] - $info['long']['net'] - 1;
 
        return $info;   
    }
 
    // Return the netmask
    function netmask(){
        $mask = $this->check6432('255.255.255.255');
        return $mask << (32 - $this->netbits);
    }
 
    // Return the network that the address sits in
    function network(){
        $ip = $this->check6432($this->address);
        return ($ip & $this->netmask());
    }
 
    // Return the broadcast that the address sits in
    function broadcast(){
        return ($this->network() | (~$this->netmask()));
    }
 
    // Return the inverse mask of the netmask
    function inverse(){
        $mask = $this->check6432('255.255.255.255');
        return (long2ip(~($mask << (32 - $this->netbits))));
    }
 
    //
    function check6432($ip){
        if(PHP_INT_MAX==2147483647){
          $mask = ip2long($ip);   
        }else{
          list(, $mask) = unpack('l', pack('l', ip2long($ip)));
        }
        return $mask;      
    }
}
?>