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、 飞信命令测试:

  1.   # wget http://www.it-adv.net/fetion/fetion_linux_20080402.tar.gz  
  2.  
  3.   # tar xvfz fetion_linux_20080402.tar.gz  
  4.  
  5.   # cp sms /usr/bin  
  6.  
  7.   # sms -h  
  8.  
  9.   sms -f mobile -p pwd -t mobile1,.. -m message -a message -d  
  10.  
  11.   sms -f mobile -p pwd -t mobile1,.. -i file_name[utf8] -a invite_message -d 1  
  12.  
  13.   -f:Fetion mobile account(only supports mobile phone No.)  
  14.  
  15.   -p:Account password  
  16.  
  17.   -t:Destination mobile list  
  18.  
  19.   -m:Message  
  20.  
  21.   -i:File name(only supports utf8)  
  22.  
  23.   -a:Auto send invite using invite_message.  
  24.  
  25.   -d:Debug on.  
  26.  

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

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

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

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

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

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

  3、安装lib库

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

  4、测试sms:

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

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

  ** **

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

  ** OTHERWISE PLEASE BEAR YOUR OWN CONSEQUENCES. **

  ** **

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

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

  1.   This program is for sending short messages via CMCC Fetion!  
  2.  
  3.   [url=http://www.fetion.com.cn/]http://www.fetion.com.cn/  
  4.  
  5.   AUTHOR:KelvinHan MSN/EMAIL:shichangguo@msn.com 2008/3/8  
  6.  
  7.   Usage:  
  8.  
  9.   sms -f mobile -p pwd -t mobile1,.. -m message -a message -d  
  10.  
  11.   sms -f mobile -p pwd -t mobile1,.. -i file_name[utf8] -a invite_message -d 1  
  12.  
  13.   -f:Fetion mobile account(only supports mobile phone No.)  
  14.  
  15.   -p:Account password  
  16.  
  17.   -t:Destination mobile list  
  18.  
  19.   -m:Message  
  20.  
  21.   -i:File name(only supports utf8)  
  22.  
  23.   -a:Auto send invite using invite_message.  
  24.  
  25.   -d:Debug on.  
  26.  

  五、 Nagios飞信测试:

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

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

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

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

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

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

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

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

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

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

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

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

  六、 Nagios配置:

  1、 nagios命令配置commands.cfg:

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

  2、 nagios发送配置contacts.cfg:

  1.   [root@nagios ~]# more /usr/local/nagios/etc/contacts.cfg  
  2.  
  3.   define contact{  
  4.  
  5.   contact_name sa  
  6.  
  7.   alias system admin  
  8.  
  9.   host_notification_period 24×7  
  10.  
  11.   service_notification_period 24×7  
  12.  
  13.   host_notification_options d,r,  
  14.  
  15.   service_notification_options c,w,r  
  16.  
  17.   service_notification_commands notify-service-by-email,notify-service-by-sms  
  18.  
  19.   # service_notification_commands notify-service-by-email  
  20.  
  21.   host_notification_commands notify-host-by-email  
  22.  
  23.   # email [email]1234@sina.com[/email]  
  24.  
  25.   pager 158010775111  
  26.  
  27.   }  
  28.  
  29.   [root@nagios ~]#  

【编辑推荐】

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短信报警

2010-03-10 12:59:08

Linux安装飞信

2009-12-23 19:13:40

Fedora Linu

2011-03-21 15:44:52

escalationsNagios

2011-03-24 08:56:21

Nagios邮件

2011-03-25 14:56:43

Nagiosescalations

2011-04-01 17:01:11

Zabbix短信

2011-03-23 14:43:10

Nagiosnagios.cfg

2011-03-21 11:14:22

LinuxNagios
点赞
收藏

51CTO技术栈公众号