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 想要解压的时候,可以用次命令
2、下载并安装飞信的支持库
- [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里登陆飞信。
4、配置飞信报警参数
在command.cfg里增加以下内容:
- # 'notify-host-by-fei' command definition
- define command {
- command_name notify-host-by-fei
- command_line /usr/local/fetion --mobile=15201352163 --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=15201352163 --pwd=xyy528888 --to=$CONTACTPAGER$ --msg-utf8="$HOSTADDRESS$ $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ on $LONGDATETIME$" $CONTACTPAGER$
- }
5、在联系人里增加报警手机号与飞信报警方式
在contacts.cfg里配置
- 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
pager
152********
增加报警手机号
现在nagios的飞信报警就已经完成,查看日志
- [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://dl528888.blog.51cto.com/2382721/770684