`
mars914
  • 浏览: 430016 次
  • 性别: Icon_minigender_1
  • 来自: 北京
社区版块
存档分类
最新评论

nagios监控之飞信报警

阅读更多

1、安装解压rar格式的解压软件

  1. [root@web1 tmp]# wget http://www.rarlab.com/rar/rarlinux-3.8.0.tar.gz
  2. [root@web1 tmp]# tar zxvf rarlinux-3.8.0.tar.gz
  3. [root@web1 tmp]# cd rar
  4. [root@web1 rar]# make install
  5. [root@web1 rar]# cd ..
unrar x **.rar 想要解压的时候,可以用次命令
2、下载并安装飞信的支持库
  1. [root@web1 tmp]# wget http://www.it-adv.net/fetion/linuxso_20101113.rar  
  2. [root@web1 tmp]# unrar x linuxso_20101113.rar  
  3. [root@web1 tmp]# cp lib*so* /usr/lib  
  4. [root@web1 ~]# echo "/usr/lib" >> /etc/ld.so.conf  
  5. [root@web1 tmp]# ldconfig  
3、下载飞信并传到服务器里(fetion在附件里)
  1. [root@web1 tmp]# cp fetion /usr/local/ 把飞信复制到/usr/local/里  
  2. [root@web1 local]# chmod 777 fetion   
  3. [root@web1 local]# chown nagios:nagios fetion  
  4. [root@web1 local]# ./fetion --mobile=152******** --pwd=*** --to=152********--msg-utf8=test 
就能发短信了,现在还有个问题是最新的飞信,必须输入图形的验证码,验证码在fetion的安装目录下,一般名位手机号的jpg如,152********.jpg,查看并输入就能在linux里登陆飞信。
4、配置飞信报警参数
在command.cfg里增加以下内容:
  1. # 'notify-host-by-fei' command definition   
  2.  
  3. define command {  
  4.              command_name            notify-host-by-fei  
  5.              command_line            /usr/local/fetion --mobile=15201352163 --pwd=xyy528888 --to=$CONTACTPAGER$ --msg-utf8="Host $HOSTSTATE$ alert for $HOSTNAME$! on '$LONGDATETIME$'" $CONTACTPAGER$   
  6.              }  
  7.  
  8. # 'notify-service-by-fei' command definition   
  9.  
  10. define command {  
  11.              command_name         notify-service-by-fei  
  12.              command_line         /usr/local/fetion --mobile=15201352163 --pwd=xyy528888 --to=$CONTACTPAGER$ --msg-utf8="$HOSTADDRESS$ $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ on $LONGDATETIME$" $CONTACTPAGER$   
  13.              }  
5、在联系人里增加报警手机号与飞信报警方式
在contacts.cfg里配置
  1. service_notification_commands           notify-service-by-email,notify-service-by-fei  
  2. host_notification_commands              notify-host-by-email,notify-host-by-fei  
增加command.cfg里的飞信报警命令notify-service-by-fei,与notify-host-by-fei
pager                                   152********
增加报警手机号
现在nagios的飞信报警就已经完成,查看日志
  1. [root@web1 etc]# tail -f /usr/local/nagios/var/nagios.log  
  2. [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  
  3. [1320401868] Caught SIGTERM, shutting down...  
  4. [1320401868] Successfully shutdown... (PID=5878)  
  5. [1320401869] Nagios 3.3.1 starting... (PID=6118)  
  6. [1320401869] Local time is Fri Nov 04 06:17:49 EDT 2011  
  7. [1320401869] LOG VERSION: 2.0  
  8. [1320401869] Finished daemonizing... (New PID=6119)  
  9. [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  
  10. [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  
  11. [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

分享到:
评论
1 楼 mars914 2012-04-02  
echo $? 上一条命令执行的结果
0为成功
1--255为失败

相关推荐

Global site tag (gtag.js) - Google Analytics