Centos6.2_x86_64系统下配置飞信机器人,实现手机接收报警短信! 2013-06-19 11:11:45
分类: 系统运维最近,新上一批服务器,安装的操作系统为:Centos6.2_x86_64。应监控需要,想在其中的一台管理机上安装配置飞信机器人报警。但是,安装配置中,遇到N多难缠的问题。网上有人说,centos6.0以后,飞信机器人的支持效果不太好。但是,经过本人实践发现,centos6.0-centos6.4都是可以成功安装配置的。下面是以Centos6.2_x86_64系统为例,说明如何配置飞信报警机器人,实现手机接收报警短信!一、配置使用本地yum源:参考linux中yum源安装方法然后就可以使用yum命令安装你所需要的软件包了 二、安装配置fetion机器人: 1.上传fetion包及安装lib库文件(lib库文件已包含在fetion压缩包中): # cd /usr/local/src/# tar xvfz fetion.good.tar.gz# cd fetion# cp -r /usr/lib /usr/lib.bak# cp -r lib/ /usr/lib/# yum install /lib/ld-linux.so.2# yum install -y libstdc++.so.6 libgssapi_krb5.so.2 libz.so.1 以上红色字体最好先别执行。2.验证机器人是否正常: # ./fetion ************************ IMPORTANT STATEMENT ************************ ** ** ** PLEASE DON'T USE THIS SOFTWARE TO SEND JUNK SHORT MESSAGES. ** ** OTHERWISE PLEASE BEAR YOUR OWN CONSEQUENCES. ** ** ** ** Version:[20101205002-linux] ** ********************************************************************* This program is the console version of China Fetion! It's free for personal user. This project website: http://www.it-adv.net/ AUTHOR:KelvinH MSN/EMAIL:shichangguo@msn.com Usage: --mobile=[mobile] --sid=[sid] --pwd=[pwd] --config=[config file] *format:index mobile password --index=[index no in config file,refer to sample.conf] --debug *debug mode on --hide *login fetion in hidden state --to=[mobile/sid] --command-path=[command file path] --robotmode --daemon(linux only) --proxy-ip(http proxy ip) --proxy-port(http proxy port) --msg-gb=[gb2312/gbk message] --msg-utf8=[utf8 message] --msg-type=[0/1/2 sms longsms smartmsg] --file-gb=[gb2312/gbk file] --file-utf8=[utf8 file] --query-cmcc-no --auto-retry --exit-on-verifycode --t3key=[http://www.tui3.com/page/smssend/] 至此,飞信机器人就可以正常发送短信了。如果,经过上面的安装配置,仍然存在一些问题,请稳步到步骤三: 三、现网遇到的问题: 1.在安装libgssapi_krb5.so.2时,出现如下错误: # yum install libgssapi_krb5.so.2 Loaded plugins: fastestmirror, refresh-packagekit, securityLoading mirror speeds from cached hostfiledvd | 4.0 kB 00:00 ... Setting up Install ProcessResolving Dependencies--> Running transaction check---> Package krb5-libs.i686 0:1.9-22.el6 will be installed--> Finished Dependency ResolutionError: Protected multilib versions: krb5-libs-1.9-22.el6.i686 != krb5-libs-1.10.3-10.el6_4.3.x86_64 You could try using --skip-broken to work around the problem You could try running: rpm -Va --nofiles --nodigest于是,根据提示尝试添加--skip-broken参数,使用rpm -Va --nofiles --nodigest命令均无效。想到强制卸载64位的版本:# rpm -e krb5-libs-1.10.3-10.el6_4.3.x86_64 --nodeps# rpm -qa|grep krb5-libs-1.10.3-10.el6_4.3.x86_64 卸载后,再执行yum安装命令,却又报出如下错误:(yum报废了,郁闷啊!) # yum install libgssapi_krb5.so.2 There was a problem importing one of the Python modulesrequired to run yum. The error leading to this problem was: libgssapi_krb5.so.2: cannot open shared object file: No such file or directory Please install a package which provides this module, orverify that the module is installed correctly. It's possible that the above module doesn't match thecurrent version of Python, which is:2.6.6 (r266:84292, Dec 7 2011, 20:48:22) [GCC 4.4.6 20110731 (Red Hat 4.4.6-3)] If you cannot solve this problem yourself, please go to the yum faq at: http://yum.baseurl.org/wiki/Faq 别着急,办法还是有的,活人不能被XX死啊!哈哈! 换一种思路,yum不行了,咱们不是还有rpm嘛。现在,就尝试如下操作:解决办法: # rpm -ivh /mnt/Packages/krb5-libs-1.9-22.el6.i686.rpm Preparing... ########################################### [100%] 1:krb5-libs ########################################### [100%]# rpm -ivh /mnt/Packages/krb5-libs-1.9-22.el6.x86_64.rpm Preparing... ########################################### [100%] 1:krb5-libs ########################################### [100%]# ./fetion ************************ IMPORTANT STATEMENT ************************ ** ** ** PLEASE DON'T USE THIS SOFTWARE TO SEND JUNK SHORT MESSAGES. ** ** OTHERWISE PLEASE BEAR YOUR OWN CONSEQUENCES. ** ** ** ** Version:[20101205002-linux] ** ********************************************************************* This program is the console version of China Fetion! It's free for personal user. This project website: http://www.it-adv.net/ AUTHOR:KelvinH MSN/EMAIL:shichangguo@msn.com Usage: --mobile=[mobile] --sid=[sid] --pwd=[pwd] --config=[config file] *format:index mobile password --index=[index no in config file,refer to sample.conf] --debug *debug mode on --hide *login fetion in hidden state --to=[mobile/sid] --command-path=[command file path] --robotmode --daemon(linux only) --proxy-ip(http proxy ip) --proxy-port(http proxy port) --msg-gb=[gb2312/gbk message] --msg-utf8=[utf8 message] --msg-type=[0/1/2 sms longsms smartmsg] --file-gb=[gb2312/gbk file] --file-utf8=[utf8 file] --query-cmcc-no --auto-retry --exit-on-verifycode --t3key=[http://www.tui3.com/page/smssend/] 2、安装/lib/ld-linux.so.2遇到如下问题:Error Downloading Packages: nscd-2.5-107.el5_9.5.x86_64: failure: RPMS/nscd-2.5-107.el5_9.5.x86_64.rpm from update: [Errno 256] No more mirrors to try.然后没有找到原因,我直接重新安装了一下结果成功了。接下来,可以进行测试一下飞信机器人发送短信,操作如下:修改sendsms.sh文件最后一行,把执行fetion脚本的路径写好,后面写上具体发送者的信息测试吧:# sh sendsms.sh 15811283479 "This Fetion Alarm Test,Please reply Me." SIP-C/4.0 280 Send SMS OKT: sip:755792951@fetion.com.cn;p=30015I: 2Q: 1 ML: 113XI: 7e30d99149cc47518b8da914f1e3af59看到如上提示,说明短信发送成功。注意:第一次测试发送短信时,会出现一个对话提示,这时候会在当前目录下生成一个以手机号命名的验证码图片(例如名为:15811283479.jpg 的验证码图片),只需切换到其他session下将其下载至本地查看,将验证码输入到前面的对话提示后,回车即可。以后,再发送短信时,就不需要验证码了。5、新增zabbix的Media Type登录到zabbix,进入“Administration" >> ”Media types",点击右上角“Create Media Type"。Description填"Fetion"或其它名称,Type选择"Script",Script填”sendsms.sh"。点击"Save"保存配置。# vim /etc/zabbix/zabbix_server.conf找到AlertScriptsPath参数并修改成 AlertScriptsPath=/usr/bin/重启zabbix-server服务6、新增zabbix的Actions配置登录到zabbix,进入"Configation" >> "Actions",点击右上角"Create Actions"。输入”Name",其它都默认点击右侧“Action Operations"下的"New"按钮,"Operation Type"选择"Send message","Send Message to"选择一个或多个要发送消息的用户组,”Send only to"选择我们之前新增的Fetion。点击"Save"保存配置。7、zabbix用户配置登录到zabbix, 进入"Adimistration" >> "Users",在之前选定要发送消息的组里的Members栏位里选择一个用户,例如选择Admin用户。在用户信息修改界面最下方的”Media"处点击"Add"按钮。Type选择"Fetion",Send to填入收信手机号码,其它参数按需修改,点击Add添加。点击"Save"保存配置。至此配置完成,触发一个警报试下手机是否收到讯息。