本文共 3003 字,大约阅读时间需要 10 分钟。
本来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 ..
unrar x **.rar 想要解压的时候,可以用次命令
- [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
3、下载飞信并传到服务器里(fetion在附件里)
- [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
就能发短信了,现在还有个问题是最新的飞信,必须输入图形的验证码,验证码在fetion的安装目录下,一般名位手机号的jpg如,152********.jpg,查看并输入就能在linux里登陆飞信。
- # '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
增加command.cfg里的飞信报警命令notify-service-by-fei,与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
能发现有飞信报警,手机也接收到了报警,(如果想要给其他人发送,一定要对方是你的好友,否则发送不了报警短信)如果您还有疑问,请找我,我会帮助您解决!
转载地址:http://oumpo.baihongyu.com/