本来nagios已经搭建成功,邮件报警也已经实现,但领导要求实时的监控系统,在问题出现时及时的处理,这样就要求我实时的登陆邮箱,但在很多的时候我没有办法一直登陆邮箱,而且我的手机是塞班系统,流量还很少(需要自己花钱),所以我就又搭建了飞信报警方式,系统出现问题直接接收短信就可以,而且不用一直登陆邮件,还省流量,呵呵!
邮件报警之前已经实现,具体配置参照我之前的文档,现在来实现飞信报警。
1、安装解压rar格式的解压软件
[root@web1 tmp]# wget http://www.rarlab.com/rar/rarlinux-3.8.0.tar.gz
[root@web1 tmp]# tar zxvf rarlinux-3.8.0.tar.gz
[root@web1 tmp]# cd rar
[root@web1 rar]# make install
[root@web1 rar]# cd ..
[root@web1 tmp]# wget http://www.it-adv.net/fetion/linuxso_20101113.rar
[root@web1 tmp]# unrar x linuxso_20101113.rar
[root@web1 tmp]# cp lib*so* /usr/lib
[root@web1 ~]# echo "/usr/lib" >> /etc/ld.so.conf
[root@web1 tmp]# ldconfig
[root@web1 tmp]# cp fetion /usr/local/ 把飞信复制到/usr/local/里
[root@web1 local]# chmod 777 fetion
[root@web1 local]# chown nagios:nagios fetion
[root@web1 local]# ./fetion --mobile=152******** --pwd=*** --to=152********--msg-utf8=test
# 'notify-host-by-fei' command definition
define command {
command_name notify-host-by-fei
command_line /usr/local/fetion --mobile=152********--pwd=xyy528888--to=$CONTACTPAGER$ --msg-utf8="Host $HOSTSTATE$ alert for $HOSTNAME$! on '$LONGDATETIME$'" $CONTACTPAGER$
}
# 'notify-service-by-fei' command definition
define command {
command_name notify-service-by-fei
command_line /usr/local/fetion --mobile=152********--pwd=xyy528888--to=$CONTACTPAGER$ --msg-utf8="$HOSTADDRESS$ $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ on $LONGDATETIME$" $CONTACTPAGER$
}
service_notification_commands notify-service-by-email,notify-service-by-fei
host_notification_commands notify-host-by-email,notify-host-by-fei
[root@web1 etc]# tail -f /usr/local/nagios/var/nagios.log
[1320401780] SERVICE NOTIFICATION: nagiosadmin;web1;HTTP;WARNING;notify-service-by-email;HTTP WARNING: HTTP/1.1 403 Forbidden - 5240 bytes in 0.018 second response time
[1320401868] Caught SIGTERM, shutting down...
[1320401868] Successfully shutdown... (PID=5878)
[1320401869] Nagios 3.3.1 starting... (PID=6118)
[1320401869] Local time is Fri Nov 04 06:17:49 EDT 2011
[1320401869] LOG VERSION: 2.0
[1320401869] Finished daemonizing... (New PID=6119)
[1320402489] SERVICE NOTIFICATION: test;web1;HTTP;WARNING;notify-service-by-email;HTTP WARNING: HTTP/1.1 403 Forbidden - 5240 bytes in 0.003 second response time
[1320402502] SERVICE NOTIFICATION: nagiosadmin;web1;HTTP;WARNING;notify-service-by-fei;HTTP WARNING: HTTP/1.1 403 Forbidden - 5240 bytes in 0.003 second response time
[1320402503] SERVICE NOTIFICATION: nagiosadmin;web1;HTTP;WARNING;notify-service-by-email;HTTP WARNING: HTTP/1.1 403 Forbidden - 5240 bytes in 0.003 second response time