飞信机器人下载地址:http://www.it-adv.net/需要账号:wenjiazhou 密码:zhouwenjia
两个版本的,一个是32位的版本linuxso_20101113 ,下面是这个版本的安装指南
然后上传到nagios服务端
# cd fetion/
# ls
fetion libACE_SSL-5.7.2.so libssl.so.4
libACE-5.7.2.so libcrypto.so.4
然后给予执行权限
# chmod +x *
# ls
fetion libACE_SSL-5.7.2.so libssl.so.4
libACE-5.7.2.so libcrypto.so.4
# mv fetion//usr/local/fetion
# cd/usr/local/fetion/
# ls
fetion libACE_SSL-5.7.2.so libssl.so.4
libACE-5.7.2.so libcrypto.so.4
加载库文件:
# vim/etc/ld.so.conf.d/fetion.conf
/usr/local/fetion
# ldconfig
然后测试下,fetion命令是否可用
# /usr/local/fetion/fetion #缺少库文件,直接yum安装上就可以
/usr/local/fetion/fetion:error while loading shared libraries: libstdc++.so.6: cannot open shared objectfile: No such file or directory
# yum installlibstdc++.so.6 -y
[# /usr/local/fetion/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 ChinaFetion!
It's free for personal user.
This project website: http://www.it-adv.net/
AUTHOR:KelvinH MSN/EMAIL:[email protected]
Usage:
--mobile=[mobile]
--sid=[sid]
--pwd=[pwd]
--config=[config file] *format:index mobilepassword
--index=[index no in config file,refer tosample.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/]
下载的64位的名字是cenos54X64_20101113,然后下面是安装步骤
上传安装包到服务器
# ls
anaconda-ks.cfg fetion_64bit install.log install.log.syslog
给予执行权限
# chmod +xfetion_64bit/*
# mv fetion_64bit//usr/local/fetion
# ls/usr/local/fetion/
fetion libcidn.so.1 libpam_misc.so.0
ld-2.5.so libcom_err.so.2 libpam_misc.so.0.81.2
ld-linux.so.2 libcom_err.so.2.1 libpam.so.0
ld-lsb.so.3 libcrypt-2.5.so libpam.so.0.81.5
ld.so.conf libcrypto.so.0.9.7a libpcre.so.0
libACE-5.6.5.so libcrypto.so.0.9.8 libpcre.so.0.0.1
libACE-5.6.8.so libcrypto.so.0.9.8b libproc-3.2.7.so
libACE-5.7.2.so libcrypto.so.4 libpthread-2.5.so
libACE_SSL-5.6.5.so libcrypto.so.6 libpthread.so.0
libACE_SSL-5.6.8.so libcrypt.so.1 libssl.so.0.9.7a
libACE_SSL-5.7.2.so libc.so.6 libssl.so.0.9.8
libc-2.5.so libeay32.dll libssl.so.4
libcap.so libnss_ldap-2.5.so libstdc++.so.6
libcap.so.1 libnss_ldap.so.2 libstdc++.so.6.0.8
libcap.so.1.10 libpamc.so.0 readme
libcidn-2.5.so libpamc.so.0.81.0
# vim/etc/ld.so.conf.d/fetion.conf
/usr/local/fetion/
# ldconfig #缺少很多库文件,安装下面的
ldconfig:/usr/local/fetion/libpcre.so.0 is not a symbolic link
ldconfig:/usr/local/fetion/libcap.so.1 is not a symbolic link
ldconfig:/usr/local/fetion/libpamc.so.0 is not a symbolic link
ldconfig:/usr/local/fetion/libcom_err.so.2 is not a symbolic link
ldconfig:/usr/local/fetion/libpam_misc.so.0 is not a symbolic link
ldconfig:/usr/local/fetion/libpam.so.0 is not a symbolic link
ldconfig:/usr/local/fetion/libstdc++.so.6 is not a symbolic link
ldconfig:/usr/local/fetion/ld-linux.so.2 is not a symbolic link
#/usr/local/fetion/fetion
/usr/local/fetion/fetion:error while loading shared libraries: libgssapi_krb5.so.2: cannot open sharedobject file: No such file or directory
# yum install libgssapi_krb5.so.2libz.so.1
然后执行fetion命令测试下
#/usr/local/fetion/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 ChinaFetion!
It's free for personal user.
This project website: http://www.it-adv.net/
AUTHOR:KelvinH MSN/EMAIL:[email protected]
Usage:
--mobile=[mobile]
--sid=[sid]
--pwd=[pwd]
--config=[config file] *format:index mobilepassword
--index=[index no in config file,refer tosample.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/]
参数解释:
以下参数提供登录用的账号密码(三种方式,手机号-密码飞信号-密码文件--索引)
--mobile=[手机号] 登录手机号
--sid=[飞信号] 登录飞信号
--pwd=[密码] 登录密码
--config=[文件名] 存储手机号、密码的文件。
--index=[索引号] 索引
以下参数提供接收者
--to=[手机号/飞信号/URI] 接收消息的手机号/飞信号/URI.如果知道对方URI,则只需自己在对方好友列表,无需对方在自己好友列表就能发送。
支持多个号码,中间用,逗号分隔
--msg-utf8=[信息]
发送的消息,UTF8编码
--msg-gb=[信息]
发送的消息,GB编码
--file-utf8=[文件utf8格式]
发送文件内容
--file-gb=[文件gb格式]
发送文件内容
--msg-type=[0/1/2]
发送消息类型:普通消息长消息智能短信
小工具
--query-cmcc-no 查询移动公司手机段
以下为可选项
--debug
显示调试信息
--hide
隐身登录
--exit-on-verifycode
服务器需要进行图形验证时,程序退出(1)或者等待用户手工输入识别信息(程序默认)
--proxy-ip=http代理ip
--proxy-port=http代理端口
(机器人需要HTTP CONNECT代理,大家常用的 ccproxy 是支持的)
>> 举例 <<
以下为 windows 下举例:
fetion --mobile=13711123456 --pwd=mypwd --to=137xxxxxxxx --msg-gb=测试
fetion --sid=6630321 --pwd=mypwd --to=137xxxxxxxx --msg-gb=测试
fetion --config=sample.conf --index=1 --to=137xxxxxxxx --msg-gb=测试
linux下,请使用如下命令:
/usr/local/fetion/fetion --mobile=13711123456 --pwd=mypwd --to=137xxxxxxxx--msg-utf8=测试信息
/usr/local/fetion/fetion--sid=6630321 --pwd=mypwd--to=137xxxxxxxx --msg-utf8=测试信息
/usr/local/fetion/fetion--config=sample.conf --index=1--to=137xxxxxxxx --msg-utf8=测试信息
测试发送的话,飞信机器人第一次需要输入验证码,验证码是在图片(发送手机号).jpg文件上
输入完一次以后,下面就不用输入了,直接查看这个图片,然后在后面输入内容按回车就可以了
整合到nagios里面,使其出现故障的时候可以给指定的手机发送报警信息
首先定义commands.cfg命令
[root@node4 ~]# cd/usr/local/nagios/etc/objects/ [root@node4 objects]#vim commands.cfg define command { command_name notify-host-by-fetion command_line /usr/local/fetion/fetion --mobile=13711123456 --pwd=mypwd --msg-utf8=gios *****\n\nNotification Type:$NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress:$HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n" --to=$CONTACTPAGER$ } define command{ command_name notify-service-by-fetion command_line /usr/local/fetion/fetion--mobile=13711123456 --pwd=mypwd --msg-utf8= "%b" "***** Nagios*****\n\nNotification Type: $NOTIFICATIONTYPE$\n\nService: $SERVICEDESC$\nHost:$HOSTALIAS$\nAddress: $HOSTADDRESS$\nState: $SERVICESTATE$\n\nDate/Time:$LONGDATETIME$\n\nAdditional Info:\n\n$SERVICEOUTPUT$\n" --to=$CONTACTPAGER$ } [root@node4 ~]# cd/usr/local/nagios/etc/objects/ [root@node4 objects]#vim contacts.cfg define contact{ contact_name nagiosadmin use generic-contact alias Nagios Admin email nagios@localhost pager 137xxxxxxxx #定义接收联系人号码 } [root@node4 objects]#vim templates.cfg define contact{ name generic-contact service_notification_period 24x7 host_notification_period 24x7 service_notification_options w,u,c,r,f,s host_notification_options d,u,r,f,s service_notification_commands notify-service-by-fetion,notify-service-by-email #服务报警的话发飞信和邮件来提醒 host_notification_commands notify-host-by-fetion,notify-host-by-email #主机报警的话发飞信和邮件来提醒 register 0 } [root@node4 objects]# /usr/local/nagios/bin/nagios -v/usr/local/nagios/etc/nagios.cfg #检查语法 ……………………………………. Total Warnings: 0 Total Errors: 0 然后重启nagios服务 [root@node4 objects]#service nagios restart Running configurationcheck...done. Stopping nagios:done. Starting nagios:done.
这样就配置完成了