Nagios飞信Linux系统免费短信报警配置

运维 系统运维
Nagios飞信Linux系统免费短信报警配置:Nagios是一个监控系统运行状态和网络信息的监控系统。Nagios能监控所指定的本地或远程主机以及服务,同时提供异常通知功能等。本文教你Nagios飞信Linux系统免费短信报警配置。

  Nagios飞信linux系统免费短信报警配置

  一、 前言:

  1、 nagios是一个非常好的系统监控工具,现在我的nagios系统已经正常运行,使用短信猫和邮件可以报警。使用飞信可以节约我们的短信猫和短信费用。

  2、 飞信首先手机要开通中国移动的飞信业务。目前使用飞信发送短信是免费的。需要把接受短信的手机和飞信发送手机加为好友。

  3、 下载飞信的linux客户端程序.解开包后只有一个文件sms。不错。这个就是飞信发送短信的程序啦。现在的飞信还是不能用的。因为它需要libace的glibc库的支持。

  二、 飞信linux程序下载:

  1、 飞信官方网站下载

  2、 飞信官方命令下载:sms

  3、 飞信官方lib库下载:32位官方lib库、64位官方lib库。

  三、 飞信程序测试:

  1、 飞信命令测试:

  # wget http://www.it-adv.net/fetion/fetion_linux_20080402.tar.gz  
 
  # tar xvfz fetion_linux_20080402.tar.gz  
 
  # cp sms /usr/bin  
 
  # sms -h  
 
  sms -f mobile -p pwd -t mobile1,.. -m message -a message -d  
 
  sms -f mobile -p pwd -t mobile1,.. -i file_name[utf8] -a invite_message -d 1  
 
  -f:Fetion mobile account(only supports mobile phone No.)  
 
  -p:Account password  
 
  -t:Destination mobile list  
 
  -m:Message  
 
  -i:File name(only supports utf8)  
 
  -a:Auto send invite using invite_message.  
 
  -d:Debug on.  
 
  • 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.

  如果没有安装lib库,将会提示 缺少libACE.so.5.4.7包

  四、 解决缺少lib库的方法:

  说明: 在centOS5下装提示需要libACE.so.5.4.7这个库,千万不要自己去安装ACE包,很麻烦,官方已经给了liunx的下载版本:

  1.先检查一下缺少的lib文件

  [root@nagios libexec]# ldd sms  
 
  linux-gate.so.1 => (0×00b00000)  
 
  libACE.so.5.4.7 => not found  
 
  libACE_SSL.so.5.4.7 => not found  
 
  libssl.so.0.9.8 => not found  
 
  libstdc++.so.6 => /usr/lib/libstdc++.so.6 (0×02a05000)  
 
  libm.so.6 => /lib/libm.so.6 (0×00cd4000)  
 
  libgcc_s.so.1 => /lib/libgcc_s.so.1 (0×029f7000)  
 
  libc.so.6 => /lib/libc.so.6 (0×00b92000)  
 
  /lib/ld-linux.so.2 (0×001c3000)  
 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.
  • 13.
  • 14.
  • 15.
  • 16.
  • 17.
  • 18.
  • 19.
  • 20.

  2.下载lib库:32位官方lib库、64位官方lib库

  3、安装lib库

  [root@nagios library32]# ls  
 
  libACE.so.5.4.7 libACE_SSL.so.5.4.7 libcrypto.so.0.9.8 libssl.so.0.9.8  
 
  [root@nagios library32]# cp *.* /lib/  
 
  [root@nagios library32]# cp *.* /usr/lib/  
 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.

  4、测试sms:

  [root@nagios libexec]# ./sms  
 
  • 1.
  • 2.

  ************************ IMPORTANT STATEMENT ************************

  ** **

  ** PLEASE DON’T USE THIS SOFTWARE TO SEND JUNK SHORT MESSAGES. **

  ** OTHERWISE PLEASE BEAR YOUR OWN CONSEQUENCES. **

  ** **

  ** [version:2008-4-2] **

  *********************************************************************

  This program is for sending short messages via CMCC Fetion!  
 
  [url=http://www.fetion.com.cn/]http://www.fetion.com.cn/  
 
  AUTHOR:KelvinHan MSN/EMAIL:shichangguo@msn.com 2008/3/8  
 
  Usage:  
 
  sms -f mobile -p pwd -t mobile1,.. -m message -a message -d  
 
  sms -f mobile -p pwd -t mobile1,.. -i file_name[utf8] -a invite_message -d 1  
 
  -f:Fetion mobile account(only supports mobile phone No.)  
 
  -p:Account password  
 
  -t:Destination mobile list  
 
  -m:Message  
 
  -i:File name(only supports utf8)  
 
  -a:Auto send invite using invite_message.  
 
  -d:Debug on.  
 
  • 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飞信测试:

  1、 需要注册一个可以使用飞信的手机号码,测试期间可以自己发送给自己做测试。

  2、 给别的手机发飞信,需要给把手机绑定为好友。

  3、 飞信环境解决了,发短信测试一下

  136933XXXXX为发飞信的注册手机号码

  136833XXXXX、36733XXXXX 为接收飞信短信的手机号码

  [root@nagios libexec]# ./sms -f 136933XXXXX -p password -t 136833XXXXX -m hello,this is test  
 
  • 1.
  • 2.

  也可以要发的消息在一个文本文件里,如 message.txt

  ./sms -f 136933XXXXX -p password -t 136833XXXXX,136733XXXXX -i message.txt  
 
  • 1.
  • 2.

  如果接收短信的手机号码在你的好友列表里,就会发送成功。

  如果不在好友列表里,发送是不成功的。如果你想让程序邀请他们加入,那么就用 -a 参数

  sms -f 136933XXXXX -p password -t 136833XXXXX,136733XXXXX -m 你好,飞信 -a UBUNTU

  这样,对方就会收到移动发的确认短信。

  六、 Nagios配置:

  1、 nagios命令配置commands.cfg:

  more /usr/local/nagios/etc/commands.cfg  
 
  define command{  
 
  command_name notify-service-by-sms  
 
  command_line /usr/bin/sms -f 13901111111 -p 562128 -t $CONTACTPAGER$ -m ”$HOSTNAME$ $SERVICEDESC$ is $SERVICESTATE$  
 
  on $TIME$ result is $SERVICEOUTPUT$” $CONTACTPAGER$  
 
  }  
 
  • 1.
  • 2.
  • 3.
  • 4.
  • 5.
  • 6.
  • 7.
  • 8.
  • 9.
  • 10.
  • 11.
  • 12.

  2、 nagios发送配置contacts.cfg:

  [root@nagios ~]# more /usr/local/nagios/etc/contacts.cfg  
 
  define contact{  
 
  contact_name sa  
 
  alias system admin  
 
  host_notification_period 24×7  
 
  service_notification_period 24×7  
 
  host_notification_options d,r,  
 
  service_notification_options c,w,r  
 
  service_notification_commands notify-service-by-email,notify-service-by-sms  
 
  # service_notification_commands notify-service-by-email  
 
  host_notification_commands notify-host-by-email  
 
  # email [email]1234@sina.com[/email]  
 
  pager 158010775111  
 
  }  
 
  [root@nagios ~]#  
  • 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.

【编辑推荐】

Nagios飞信配置

Nagios监控系统搭建问题

Nagios报警邮件到yahoo邮箱

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

2011-03-23 09:07:49

Nagios飞信

2010-05-31 09:06:12

Nagios飞信

2011-03-23 13:32:14

Nagios飞信

2011-03-24 13:00:31

Nagios飞信

2011-03-25 13:10:08

2011-03-24 09:15:54

Nagios飞信

2011-03-23 09:07:50

Nagios短信

2011-03-23 12:55:51

NagiosMSN飞信

2011-04-06 14:24:18

2011-03-22 16:31:27

Nagios

2011-03-24 08:56:23

escalationsNagios报警

2014-03-12 16:09:21

Zabbix短信报警

2009-12-23 19:13:40

Fedora Linu

2011-03-25 14:56:43

Nagiosescalations

2011-03-24 08:56:21

Nagios邮件

2011-03-21 15:44:52

escalationsNagios

2011-03-21 11:14:22

LinuxNagios

2011-03-23 14:43:10

Nagiosnagios.cfg

2010-03-10 12:59:08

Linux安装飞信

2021-05-28 11:03:14

网络监控Nagios漏洞
点赞
收藏

51CTO技术栈公众号