运维监控之Nagios实战(四)&Nagios报警
Nagios配置好了,被监控机也有了http://blog.运维网.com/neweditor/editor/images/smiley/28.gif 真不容易!!!可是还不够呀,Nagios最强大的特点就是报警,总不能整天盯着nagios页面不停刷新有没有出故障吧!
所以,手机短信报警,邮件报警就很必要了!
邮件报警设置
按之前的配置文件中,已经将联系人定义为maoxian,邮箱也定义为wangyx088@gmail.com,所以只需要打开sendmail就能报警发邮件了.顺便进邮箱去收下邮件.
[*]yum -y install sendmail
[*]service sendmail restart
[*]#然后发送测试邮件,验证sendmail的可用性:
[*]echo "Hello World" | mail wangyx088@gmail.com
http://blog.运维网.com/attachment/201201/144911559.jpg
然后将nagios客户端的eth0禁用掉,或者关掉,嘎嘎(邪恶)!http://blog.运维网.com/attachment/201201/150201360.jpg
http://blog.运维网.com/attachment/201201/150130607.jpg
收到邮件了吧.
飞信报警设置
邮件在使用电脑的时候是很方便收到报警信息,可是很多时候却收不到邮件,那该怎么办呢,想大家手机总是不离身的吧,设置好飞信,有故障就发送到手机上,多好啊!
[*]#下载安装飞信
[*]cd /usr/local/src
[*]wget http://ebook.elain.org/tools/fetion20101205.tar.gz
[*]tar zxvf fetion20101205.tar.gz
[*]mv fetion20101205/fetion /usr/local/fetion
[*]cd /usr/local/fetion/lib/
[*]cp libACE*libcrypt* libssl.so.* /usr/lib
[*]#测试:
[*]/usr/local/fetion/fetion --mobile=135xxxxxxx --pwd=******** --to=135xxxxxxxx --msg-type=1 --msg-utf8="Hello World"
执行第一次时候可能会停留在那,等着你输入验证码.飞信会生成一张图片.然后放在/usr/local/fetion/目录下,你在另一终端把图片下载下来,打开会看到验证码,输入验证码.注意区分大小写.----额,我的确是收到短信了.就不发图了!
整合Nagios+fetion,在网上找的相关文档,已经将错误内容修正!
[*]#以下文档在网上找的
[*]#vim commands.cfg
[*]define command {
command_name notify-host-by-fetion
command_line /usr/local/fetion/fetion --mobile=1352**** --pwd=**** --to=$CONTACTPAGER$ --msg-utf8="Host $HOSTSTATE$ alert for $HOSTNAME$! on '$LONGDATETIME$'" $CONTACTPAGER$
}
define command {
command_name notify-service-by-fetion
command_line /usr/local/fetion/fetion --mobile=135**** --pwd=**** --to=$CONTACTPAGER$ --msg-utf8="$HOSTADDRESS$ $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ on $LONGDATETIME$" $CONTACTPAGER$
}
[*]#vim templates.cfg
[*]define contact{
[*]…………
[*]service_notification_commands notify-service-by-fetion
[*]host_notification_commands notify-host-by-fetion
[*]…………
[*]}
[*]
[*]#vim contacts.cfg
[*]define contact {
[*]contact_name maoxian
[*]alias maoxian
[*]service_notification_period 24x7
[*]host_notification_period 24x7
[*]service_notification_options w,u,c,r
[*]host_notification_options d,u,r
[*]service_notification_commandsnotify-service-by-email,notify-service-by-fetion
[*]host_notification_commands notify-host-by-email,notify-host-by-fetion
[*]email wangyx088@gmail.com
[*]pager 135xxxxxxxx
[*]}
OK
页:
[1]