Nagios设置飞信报警

一.下载飞信
到此网站下载飞信机器人
http://www.it-adv.net/
下载完把飞信移动到/usr/lcaol/fetion
安装好FTP,等会飞信需要输入验证码,要看验证码
二.配置库
cd /usr/local/fetion/
1.将库加载到系统
vim /etc/ld.so.conf.d/fetion
/usr/local/fetion
ldconfig

[root@bogon fetion]# ./fetion
-bash: ./fetion: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory
出了个错
[root@bogon fetion]#  yum install /lib/ld-linux.so.2
[root@bogon fetion]# ./fetion
./fetion: error while loading shared libraries: libACE-5.7.2.so: cannot open shared object file: No such file or directory
又出了个错
[root@bogon fetion]# cp libACE-5.7.2.so /lib
[root@bogon fetion]# ./fetion
./fetion: error while loading shared libraries: libACE_SSL-5.7.2.so: cannot open shared object file: No such file or directory
[root@bogon fetion]# cp libACE_SSL-5.7.2.so /lib
又出了个错
[root@bogon fetion]# ./fetion
./fetion: error while loading shared libraries: libssl.so.4: cannot open shared object file: No such file or directory
[root@bogon fetion]# cp libssl.so.4 /lib
又出了个错
[root@bogon fetion]# ./fetion
./fetion: error while loading shared libraries: libstdc++.so.6: cannot open shared object file: No such file or directory
[root@bogon fetion]# cp libstdc++.so.6 /lib
又出了个错
[root@bogon fetion]# ./fetion
./fetion: error while loading shared libraries: libgcc_s.so.1: cannot open shared object file: No such file or directory
[root@bogon fetion]# yum -y install libgcc_s.so.1
又出了个错
[root@bogon fetion]# ./fetion
./fetion: error while loading shared libraries: libcrypto.so.4: cannot open shared object file: No such file or directory
[root@bogon fetion]# cp libcrypto.so.4 /lib
又出了个错
[root@bogon fetion]# ./fetion
./fetion: error while loading shared libraries: libgssapi_krb5.so.2: cannot open shared object file: No such file or directory
[root@bogon fetion]# yum -y install libgssapi_krb5.so.2
又出了个错
[root@bogon fetion]# ./fetion
./fetion: error while loading shared libraries: libz.so.1: cannot open shared object file: No such file or directory
[root@bogon fetion]# yum -y install libz.so.1
直到出现这样就成功了
[root@bogon 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 China Fetion!
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 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.发信测试

第一次发信会提示你输入验证码


./fetion --mobile=1590***** --pwd=*****--to=18501223113 --msg-utf8=test
3.创建脚本


vim fetion.sh
#!/bin/bash
/usr/local/fetion/fetion --mobile=159******** --pwd=******** --to="$1" --msg-utf8="$
2"




chmod 755 fetion.sh
chown nagios.nagios fetion.sh
sh fetion.sh 159****** test


SIP-C/4.0 280 Send SMS OK
T: sip:[email protected];p=5913
I: 2
Q: 1 M
L: 112
D: Sat, 14 Sep 2013 17:13:45 GMT
XI: 4DEBE57197CEBC01DAC262E2A9D23EE2


三.修改模版配置文件templates.cfg
vim /usr/local/nagios/etc/objects/templates.cfg


define contact{
        name                            generic-contact         ; The name of this contact template
        service_notification_period     24x7                    ; service notifications can be sent anytime
        host_notification_period        24x7                    ; host notifications can be sent anytime
        service_notification_options    w,u,c,r,f,s             ; send notifications for all service states, flapping events, and scheduled downtime events
        host_notification_options       d,u,r,f,s               ; send notifications for all host states, flapping events, and scheduled downtime events
        service_notification_commands   notify-service-by-email,notify-service-by-fetion        ; send service notifications via email
        host_notification_commands      notify-host-by-email,notify-host-by-fetion    ; send host notifications via email
        register                        0                       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL CONTACT, JUST A TEMPLATE!
        }


四.修改命令配置文件commadns.cfg

vim /usr/local/nagios/etc/objects/commands.cfg

# 'notify-host-by-fetion' command definition 
define command{ 
 command_name    notify-host-by-fetion 
 command_line    $USER1$/fetion.sh $CONTACTPAGER$ "$NOTIFICATIONTYPE$ Host Alert: $HOSTNAME$ is $HOSTSTATE$"
}
 
# 'notify-service-by-fetion' command definition 
define command{
 command_name    notify-service-by-fetion
 command_line    $USER1$/fetion.sh $CONTACTPAGER$ "$NOTIFICATIONTYPE$ Service Alert: $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$"
}


五.修改联系人配置文件contacts.cfg

vim /usr/local/nagios/etc/objects/contacts.cfg

define contact{
        contact_name                    nagiosadmin             ; Short name of user
        use                             generic-contact         ; Inherit default values from generic-contact template (defined above)
        alias                           Nagios Admin            ; Full name of user
        email                           [email protected]        ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******
        pager                           1590*******
        }



你可能感兴趣的:(Nagios设置飞信报警)