一、网页报警
1。修改cgi.cfg 去掉下面几行注释
host_unreachable_sound=hostdown.wav
host_down_sound=hostdown.wav
service_critical_sound=critical.wav
service_warning_sound=warning.wav
service_unknown_sound=warning.wav
normal_sound=noproblem.wav
2。在/usr/local/nagios/share/media/应该有相应的声音文件(这个默认没有的,需要自己添加)
二、邮件报警 (使用sendEmail 发送邮件)
# wget http://caspian.dotconf.net/menu/Software/SendEmail/sendEmail-v1.56.tar.gz
# tar �Czxvf sendEmail-v1.55.tar.gz
# cd sendEmail-v1.56
# cp sendEmail /usr/local/bin
# chmod 0755 /usr/local/bin/sendEmail
#. /usr/local/bin/sendEmail �Cf
[email protected]�Ct
[email protected] �Cs mail.scomd.com �Cu “from nagios” �Cxu nagios �Cxp scomd �Cm nagios test
-f 表示发送者的邮箱
-t 表示接收者的邮箱
-s 表示SMTP服务器的域名或者ip
-u 表示邮件的主题
-xu 表示SMTP验证的用户名
-xp 表示SMTP验证的密码(注意,这个密码貌似有限制,例如我用d!5neyland就不能被正确识别)
-m 表示邮件的内容
修改commands.cfg
define command{
command_name notify-host-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" | /usr/local/bin/sendEmail -f
[email protected] -t
[email protected] -s mail.scomd.com -u "from nagios" -xu nagios -xp scomd ; /bin/mail -s "** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **" $CONTACTEMAIL$
}
# 'notify-service-by-email' command definition
define command{
command_name notify-service-by-email
command_line /usr/bin/printf "%b" "***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost: $HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time: $LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$" | /usr/local/bin/sendEmail -f
[email protected] -t
[email protected] -s mail.scomd.com -u "from nagios" -xu nagios -xp scomd
}
发现一个小问题,我用163测试,密码错误的也可以发送。
三、飞信报警 (移动用户必须开通飞信业务)
#wget http://www.it-adv.net/fetion/downng/fetion20091117-linux.tar.gz
#tar �Czxvf fetion20091117-linux.tar.gz
#cd fx
LD_LIBRARY_PATH=. ./fetion --mobile=13691515**** --pwd=mypwd --to=13691515****--msg-utf8=test
发送成功后可进行整合。发送不成功请关注http://www.it-adv.net网站的说明
编辑commands.cfg,增加host-notify-by-fetion和service-notify-by-fetion命令的定义
define command {
command_name host-notify-by-fetion
command_line LD_LIBRARY_PATH=/usr/local/nagios/fx /usr/local/nagios/fx/fetion --mobile=13691515****--pwd=passwd --to=13691515**** --msg-utf8="Host $HOSTSTATE$ alert for $HOSTNAME$! on '$LONGDATETIME$'" $CONTACTPAGER$
}
define command {
command_name service-notify-by-fetion
command_line LD_LIBRARY_PATH=/usr/local/nagios/fx /usr/local/nagios/fx/fetion --mobile=13691515**** --pwd= passwd --to=13691515**** --msg-utf8="$HOSTADDRESS$ $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ on $LONGDATETIME$" $CONTACTPAGER$
}
编辑contact.cfg,添加短信通知
define contact{
contact_name nagiosadmin
use generic-contact
alias Nagios Admin
email
[email protected]
service_notification_commands notify-service-by-email,service-notify-by-fetion
host_notification_commands notify-host-by-email,host-notify-by-fetion
pager 1367115****
}