Nagios飞信配置

运维 系统运维
Nagios飞信配置:Nagios是一个监控系统运行状态和网络信息的监控系统。Nagios能监控所指定的本地或远程主机以及服务,同时提供异常通知功能等。就比如是以飞信的方式发送。这篇文章主要讲的是Nagios飞信配置。

  nagios组合飞信

  1、软件环境(centos 5为例)

  官网地址:[url]http://www.it-adv.net/[/url]

  支持库安装:需要Glibc2.4以上的版本

  2、安装过程

  支持库和安装包内容如下:

  # tar zxvf libraryrh4×32.tar.gz  
 
  libACE-5.6.5.so  
 
  libACE_SSL-5.6.5.so  
 
  libcrypto.so.0.9.7a  
 
  libssl.so.0.9.7a  
 
  # tar zxvf fetion20080522004-linrh4.tar.gz  
 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.

  我将fetion放在/../nagios/libexec/sms

  把支持库复制到/usr/lib/目录下,并作软链接如下:

  cp lib*so* /usr/lib/  
 
  ln -s /usr/lib/libcrypto.so.0.9.7a /usr/lib/libcrypto.so.4  
 
  ln -s /usr/lib/libssl.so.0.9.7a /usr/lib/libssl.so.4  
 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.

  设定lib库配置文件

  #vi /etc/ld.so.conf  
 
  #增加一条  
 
  /usr/lib/  
 
  #保存退出后,执行  
 
  #ldconfig  
 
  fetion的目录结构:  
 
  .\Readme.txt: 本说明文件  
 
  .\fetion:主程序  
 
  .\sound\*.wav:各种音效文件,您可以用自己喜欢的文件替换  
 
  .\plugins\plugin_*: 插件程序,您可以修改插件以达到自己的各性化需求  
 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.

  完成之后测试,安装是否成功;执行

  #cd install  
 
  # ./fetion -h  
 
  Usage:  
 
  fetion -h  
 
  -h: help  
 
  fetion -u mobile -p pwd [-b batchfile] [-EN] [-d]  
 
  fetion -u mobile -p pwd [-b batchfile] [-EN] [-d]  
 
  -u: Fetion user account(only supports mobile phone No.)  
 
  -p: Account password  
 
  -b: Batch file name  
 
  -d: Debug and write logs to [mobile]-debug.log  
 
  -EN: English  
 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.

  3、实际测试

  测试帐号:13888888888

  密码:123456 (如果密码中含有特殊字符,请使用单引号)

  如果发送成功。那么飞信安装过程就OK了

  4、飞信组合nagios

  Fetion以后台方式启动:nohup /usr/local/nagios/libexec/sms/fetion -u 13888888888 -p 123456 >/dev/null 2>1 &

  写一个perl脚本(本脚本由gzmaster小弟提供)

  Sms.pl (/../nagios/libexec/sms/sms.pl)  
 
  #!/usr/bin/perl -w  
 
  use strict;  
 
  use Data::Dumper;  
 
  use LWP::UserAgent;  
 
  my $mesg = shift;  
 
  $mesg =~ s/\//|/g;  
 
  my @number = (接收手机号,接收手机号);  
 
  foreach my $number ( @number ) {  
 
  #print “send sms to $number \n”;  
 
  my $send_sms_url = “http://localhost:40000/API/buddy/sms/” . $number . “/” . $mesg . ‘?rand=0.7394060082921254′;  
 
  my $request = HTTP::Request->new(GET => $send_sms_url);  
 
  my $ua = LWP::UserAgent->new;  
 
  $ua->timeout( 5 );  
 
  $ua->agent(“Mozilla/4.0 (compatible; MSIE 7.0; Windows NT 5.2; .NET CLR 1.1.4322; Maxthon 2.0)”);  
 
  my $response = $ua->request($request);  
 
  my $content = $response->content();  
 
  }  
 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.

  修改相应的配置文件

  修改用户及组:contacts.cfg

  添加:

  define contact{  
 
  contact_name sms-members  
 
  use sms-mail-contact  
 
  alias Nagios Admin SMS  
 
  pager 138888888888  
 
  }  
 
  define contactgroup{  
 
  contactgroup_name admins-and-lijs  
 
  alias Nagios Administrators  
 
  members sms-members  
 
  }  
 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.

  修改报警选项:templates.cfg

  define contact{  
 
  name generic-contact  
 
  service_notification_period 24×7  
 
  host_notification_period 24×7  
 
  service_notification_options w,u,c,r,f,s  
 
  host_notification_options d,u,r,f,s  
 
  service_notification_commands notify-service-by-email; service-notify-by-sms  
 
  host_notification_commands notify-host-by-email  
 
  register 0  
 
  }  
 
  define contact{  
 
  name sms-mail-contact  
 
  service_notification_period 24×7  
 
  host_notification_period 24×7  
 
  service_notification_options w,u,c,r,f,s  
 
  host_notification_options d,u,r,f,s  
 
  service_notification_commands service-notify-by-sms  
 
  host_notification_commands notify-host-by-email  
 
  register 0  
 
  }  
 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.
  • 27.
  • 28.
  • 29.
  • 30.
  • 31.
  • 32.
  • 33.
  • 34.
  • 35.
  • 36.
  • 37.
  • 38.
  • 39.
  • 40.

  修改调用脚本:commands.cfg

  #host-notify-by-sms  
 
  define command {  
 
  command_name host-notify-by-sms  
 
  command_line /usr/bin/printf “%b” “***** Nagios *****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nHost: $HOSTNAME$\nState:  
 
  $HOSTSTATE$\nWAN_IP: $HOSTALIAS$\nLAN_IP: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n” | /usr/local/nagios/lib  
 
  exec/sms.pl 710880931 “** $NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$ **” $CONTACTEMAIL$  
 
  }  
 
  #service notify by sms  
 
  define command {  
 
  command_name service-notify-by-sms  
 
  command_line /usr/local/nagios/libexec/sms/sms.pl ‘** $NOTIFICATIONTYPE$ alert – $HOSTNAME$ $SERVICEDESC$ is $SERVICESTA  
 
  TE$ info: $SERVICEOUTPUT$’  
 
  }  
 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.
  • 21.
  • 22.
  • 23.
  • 24.
  • 25.
  • 26.

  测试下nagios情况。然后再测试报警。Nagios飞信配置就OK了。

【编辑推荐】

Nagios报错notify-by-email解决

Nagios配置文件的结构

配置Nagios监控Oracle服务器

责任编辑:zhaolei 来源: nagiostutorial
相关推荐

2011-03-23 13:32:14

Nagios飞信

2011-03-23 09:07:49

Nagios飞信

2011-03-25 13:10:08

2010-05-31 09:06:12

Nagios飞信

2011-03-24 10:08:42

Nagios飞信Linux

2011-03-24 13:00:31

Nagios飞信

2011-03-23 12:55:51

NagiosMSN飞信

2011-08-22 12:25:02

nagios

2011-03-31 16:05:18

Redhat配置nagios

2010-05-31 11:10:37

Nagios pnp

2011-03-21 09:17:06

Nagios

2011-03-25 10:37:17

2011-03-25 16:49:33

nagios服务

2011-11-08 21:58:01

Nagios 配置 流

2011-03-23 09:07:50

Nagios短信

2010-05-31 10:22:31

Nagios pnp

2011-03-28 15:22:00

nagios

2011-03-31 16:05:18

Redhat配置nagios

2011-03-23 14:43:10

Nagiosnagios.cfg

2010-05-31 12:22:13

Nagios pnp
点赞
收藏

51CTO技术栈公众号