为Nagios配置桌面报警

直接发配置文档: 

Nagios录下新tools.growlNatifyNagios.zip压到里面

修改tools的所有者为nagios运行帐号

chown nagios.nagios tools -R

编辑growlNatifyNagios里的growlNatify

修改

$growl->setAddress( '192.168.7.204', 'mypassword' );

192.168.7.204为你装有growl的地址.growl的配置参考<<growl+php构建桌面消息系统>>

修改growlNatify的权限

chmod 755 growlNatify

growlNatify链接到Nagioslibexec

ln -s /path/to/Nagios/tools/growlNatifyNagios/growlNatify /path/to/Nagios/libexec

就配置完了.

你可以测试一下growlNatify是不是正常工作

./growlNatify -s '我是主' -b '我是内容'

nagios配置

1.commands.cfg配置:

# 'notify-host-by-growlNotify' command definition

define command{

        command_name    notify-host-by-growlNotify

        command_line    /usr/bin/printf "%b" "Nagios-Notification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState:              $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | $USER1$/growNotify -s "                 $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$

        }   

 

# 'notify-service-by-growlNotify' command definition

define command{

        command_name    notify-service-by-growlNotify

        command_line    /usr/bin/printf "%b" "Nagios-Notification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost:       $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$"   |  $USER1$/growNotify -s "$NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ " $CONTACTEMAIL$        

}

2.templates.cfg配置:

service_notification_commandshost_notification_commands分别添加对应项

service_notification_commands   notify-service-by-email,notify-service-by-growlNotify ; send        service notifications via email

host_notification_commands      notify-host-by-email,notify-host-by-growlNotify      ; send host       notifications via email

3.重新Nagios使配置生效.

 

你可能感兴趣的:(PHP,mac,nagios,Growl,桌面报警)