中文字幕av专区_日韩电影在线播放_精品国产精品久久一区免费式_av在线免费观看网站

溫馨提示×

溫馨提示×

您好,登錄后才能下訂單哦!

密碼登錄×
登錄注冊×
其他方式登錄
點擊 登錄注冊 即表示同意《億速云用戶服務條款》

Nagios配合飛信發短信

發布時間:2020-07-24 07:43:06 來源:網絡 閱讀:2055 作者:bbotte 欄目:移動開發

nagios的安裝在此頁面 http://bbotte.blog.51cto.com/6205307/1403997 

提示:飛信接口已經不可用

nagios要添加飛信報警功能,盡管網上有很多教程,不過許多都需要瞎折騰才能正常用飛信,所以下面記錄一下,供參考

系統centos6.4 64位

安裝飛信

下載地址 http://pan.baidu.com/s/1sXpGj 找到linux安裝包 > 飛信 >fetiontar.zip

# unzip fetiontar.zip
# cd fetiontar
# ls
fetion  lib
# mkdir /usr/local/fetion
# cp fetion /usr/local/fetion/
# chmod 755 /usr/local/fetion/fetion


# ls lib/   #lib文件夾下的so文件
ld-2.5.so            libcap.so.1          libcrypt.so.1          libpcre.so.0.0.1
ld-linux.so.2        libcap.so.1.10       libc.so.6              libproc-3.2.7.so
ld-lsb.so.3          libcidn-2.5.so       libeay32.dll           libpthread-2.5.so
ld.so.conf           libcidn.so.1         libnss_ldap-2.5.so     libpthread.so.0
libACE-5.6.5.so      libcom_err.so.2      libnss_ldap.so.2       libssl.so.0.9.7a
libACE-5.6.8.so      libcom_err.so.2.1    libpamc.so.0           libssl.so.0.9.8
libACE-5.7.2.so      libcrypt-2.5.so      libpamc.so.0.81.0      libssl.so.4
libACE_SSL-5.6.5.so  libcrypto.so.0.9.7a  libpam_misc.so.0       libstdc++.so.6
libACE_SSL-5.6.8.so  libcrypto.so.0.9.8   libpam_misc.so.0.81.2  libstdc++.so.6.0.8
libACE_SSL-5.7.2.so  libcrypto.so.0.9.8b  libpam.so.0            readme
libc-2.5.so          libcrypto.so.4       libpam.so.0.81.5
libcap.so            libcrypto.so.6       libpcre.so.0



設置fetion的庫文件

# cp -r lib/ /lib64/fetion
# vim /etc/ld.so.conf.d/fetion.conf
/lib64/fetion


# ldconfig -v|grep fetion
ldconfig: /etc/ld.so.conf.d/kernel-2.6.32-431.11.2.el6.x86_64.conf:6: duplicate hwcap 1 nosegneg
ldconfig: /lib64/fetion/libstdc++.so.6 is not a symbolic link
ldconfig: /lib64/fetion/libpamc.so.0 is not a symbolic link
ldconfig: /lib64/fetion/libpam_misc.so.0 is not a symbolic link
ldconfig: /lib64/fetion/libpcre.so.0 is not a symbolic link
ldconfig: /lib64/fetion/ld-linux.so.2 is not a symbolic link
ldconfig: /lib64/fetion/libcom_err.so.2 is not a symbolic link
ldconfig: /lib64/fetion/libcap.so.1 is not a symbolic link
ldconfig: /lib64/fetion/libpam.so.0 is not a symbolic link
/lib64/fetion:


查看缺少哪些庫,然后依次安裝

# ldd /usr/local/fetion/fetion 
linux-gate.so.1 =>  (0x00e41000)
libACE-5.7.2.so => /lib64/fetion/libACE-5.7.2.so (0x007ec000)
libACE_SSL-5.7.2.so => /lib64/fetion/libACE_SSL-5.7.2.so (0x002ad000)
libssl.so.4 => /lib64/fetion/libssl.so.4 (0x0069d000)
libstdc++.so.6 => /lib64/fetion/libstdc++.so.6 (0x004f8000)
libm.so.6 => /lib/libm.so.6 (0x00c7d000)
libgcc_s.so.1 => /lib/libgcc_s.so.1 (0x00dfe000)
libc.so.6 => /lib/libc.so.6 (0x002c2000)
libcrypto.so.4 => /lib64/fetion/libcrypto.so.4 (0x03e4a000)
librt.so.1 => /lib/librt.so.1 (0x001d0000)
libdl.so.2 => /lib/libdl.so.2 (0x001d9000)
libgssapi_krb5.so.2 => not found
libkrb5.so.3 => not found
libcom_err.so.2 => /lib64/fetion/libcom_err.so.2 (0x001de000)
libk5crypto.so.3 => not found
libresolv.so.2 => /lib/libresolv.so.2 (0x001e1000)
/lib/ld-linux.so.2 (0x0070f000)
libz.so.1 => not found
libgssapi_krb5.so.2 => not found
libkrb5.so.3 => not found
libk5crypto.so.3 => not found
libz.so.1 => not found
libpthread.so.0 => /lib/libpthread.so.0 (0x0079e000)

如果缺少libgcc_s.so.1,出現下面情況,那么 yum install libgcc_s.so.1

# /usr/local/fetion/fetion 
/usr/local/fetion/fetion: error while loading shared libraries: libgcc_s.so.1: cannot open shared object file: No such file or directory


# yum install krb5-libs libgssapi_krb5.so.2 libz.so.1 -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 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/]


ok,飛信已經安裝好了,下面測試

# /usr/local/fetion/fetion --mobile=你的手機號 --pwd=飛信密碼 --to=對方的手機號 --msg-utf8="hello  hero"

HTTP/1.1 200 OK

Connection: close

Date: Sat, 23 Aug 2014 09:50:19 GMT

Server: Microsoft-IIS/6.0

X-Powered-By: ASP.NET

Content-Location: nav.fetion.com.cn

X-AspNet-Version: 4.0.30319

Cache-Control: private

Content-Type: text/html; charset=utf-8

Content-Length: 2473


<?xml version="1.0" encoding="UTF-8"?><results><pic-certificate id="f9c6154e-1e8f-4fe5-bb54-61b6ac4a3a85" pic="*****(省略)"

#這里是提示輸入驗證碼,驗證碼到目錄,即下面的手機號.jpg 文件

# cd /usr/local/fetion/

# ls

1591425****.cache  1591425****.jpg  fetion

Nagios配合飛信發短信

下面就可以給飛信的好友發送信息了

# /usr/local/fetion/fetion --mobile=1591425**** --pwd=****** --to=****** --msg-utf8="hello  hero,you are a man"

SIP-C/4.0 280 Send SMS OK

T: sip:1056282019@fetion.com.cn;p=7019

I: 3

Q: 1 M

RQ: 56602213092

L: 112

XI: 7df854ffd4ff4abeb840b878110fec25


----以上確定飛信可以正常使用,下面詳細說明配置內容----


下面幾個配置文件相互關聯,commands.cfg中定義飛信發送短信的命令,contacts.cfg中說明發送短信的用戶和組,templates.cfg定義觸發后要執行的動作,比如發飛信或郵件,什么時候發,用那個用戶發送,timeperiods.cfg定義時間,工作日或者7x24,這里我使用默認的7x24,linuxhost.cfg為自己創建的文件,定義監控的服務和主機,監控的動作


cd /usr/local/nagios/etc/objects
commands.cfg    #定義飛信的發送命令
define command {
  command_name notify-host-by-fetion
  command_line /usr/local/fetion/fetion --mobile=1591425**** --pwd=123456 --to=1591425**** --msg-utf8="$NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n"  --msg-type=1
}
define command {
  command_name notify-service-by-fetion
  command_line /usr/local/fetion/fetion --mobile=1591425**** --pwd=123456 --to=1591425**** --msg-utf8="$NOTIFICATIONTYPE$\nHost: $HOSTNAME$\nState: $HOSTSTATE$\nAddress: $HOSTADDRESS$\nInfo: $HOSTOUTPUT$\n\nDate/Time: $LONGDATETIME$\n"   --msg-type=1
}


contacts.cfg   #創建用戶和用戶組,定義使用飛信發送通知信息
define contact{
        contact_name                        linux
        use                                 linux-contact
        alias                               linux server1
        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
        host_notification_commands          notify-host-by-fetion
        }
define contactgroup{
        contactgroup_name           linux
        alias                       linux group1
        members                     linux
        }
templates.cfg    #在模板中定義檢測后所要執行的選擇
define contact{
        name                            linux-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
        host_notification_commands      notify-host-by-fetion
        register                        0
        }
define host{
        name                            mylinux-server   
        use                             generic-host    
        check_period                    24x7            
        check_interval                  5               
        retry_interval                  1               
        max_check_attempts              10              
        check_command                   check-host-alive
        notification_period             24x7                                                                                                                  
        notification_interval           120             
        notification_options            d,u,r           
        contact_groups                  linux    
        register                        0               
        }
define service{
        name                            linux-service
        active_checks_enabled           1
        passive_checks_enabled          1
        parallelize_check               1
        obsess_over_service             1
        check_freshness                 0
        notifications_enabled           1
        event_handler_enabled           1
        flap_detection_enabled          1
        failure_prediction_enabled      1
        process_perf_data               1
        retain_status_information       1
        retain_nonstatus_information    1
        is_volatile                     0
        check_period                    24x7
        max_check_attempts              3
        normal_check_interval           1
        retry_check_interval            2
        contact_groups                  linux
        notification_options            w,u,c,r
        notification_interval           60
        notification_period             24x7
         register                        0
        }
linuxhost.cfg     #定義主機和監控的服務
define host{
        use                     mylinux-server           
        host_name               webserver1
        alias                   webserver1
        address                 192.168.22.241
        }
define hostgroup{
        hostgroup_name  group1 
        alias           Linux group1 
        members         webserver1    
        }
define service{
        use                             linux-service
        host_name                       webserver1
        service_description             check users
        check_command                   check_nrpe!check_users
        }
define service{
        use                             linux-service
        host_name                       webserver1
        service_description             check load
        check_command                   check_nrpe!check_load
        }
define service{
        use                             linux-service
        host_name                       webserver1
        service_description             check zombie proce
        check_command                   check_nrpe!check_zombie_procs
        }
define service{
        use                             linux-service
        host_name                       webserver1
        service_description             check total proce
        check_command                   check_nrpe!check_total_procs
        }
define service{
        use                             linux-service
        host_name                       webserver1
        service_description             check rootdisk
        check_command                   check_nrpe!check_rootdisk
        }
define service{
        use                             linux-service
        host_name                       webserver1
        service_description             check swap
        check_command                   check_nrpe!check_swap
        }
define service{
        use                             linux-service
        host_name                       webserver1
        service_description             check sda1
        check_command                   check_nrpe!check_sda1
        }
define service{
        use                             linux-service
        host_name                       webserver1
        service_description             check sda3
        check_command                   check_nrpe!check_sda3
        }
define service{
        use                             linux-service
        host_name                       webserver1
        service_description             check mysql
        check_command                   check_nrpe!check_mysql
        }



測試service發送短信

被監控端user設置 check_users -w 3 -c 3 現在5人登錄,稍后再登出

nagios日志,SERVICE NOTIFICATION: linux;webserver1;check users;CRITICAL;notify-service-by-fetion;USERS CRITICAL - 5 users currently logged in

[1409704648] SERVICE ALERT: webserver1;check users;CRITICAL;SOFT;1;USERS CRITICAL - 4 users currently logged in
[1409704768] SERVICE ALERT: webserver1;check users;CRITICAL;SOFT;2;USERS CRITICAL - 5 users currently logged in
[1409704888] SERVICE ALERT: webserver1;check users;CRITICAL;HARD;3;USERS CRITICAL - 5 users currently logged in
[1409704888] SERVICE NOTIFICATION: linux;webserver1;check users;CRITICAL;notify-service-by-fetion;USERS CRITICAL - 5 users currently logged in
[1409704948] SERVICE ALERT: webserver1;check users;OK;HARD;3;USERS OK - 1 users currently logged in
[1409704948] SERVICE NOTIFICATION: linux;webserver1;check users;OK;notify-service-by-fetion;USERS OK - 1 users currently logged in


測試host發送短信:

把被監控端關機的nagios日志,HOST NOTIFICATION: linux;webserver1;DOWN;notify-host-by-fetion;CRITICAL - Host Unreachable (192.168.22.241)

[1409705298] HOST ALERT: webserver1;DOWN;HARD;10;CRITICAL - Host Unreachable (192.168.22.241)
[1409705298] HOST NOTIFICATION: linux;webserver1;DOWN;notify-host-by-fetion;CRITICAL - Host Unreachable (192.168.22.241)
[1409705307] Warning: Return code of 255 for check of service 'check sda3' on host 'webserver1' was out of bounds.
[1409705307] SERVICE ALERT: webserver1;check sda3;UNKNOWN;HARD;3;(Return code of 255 is out of bounds)
[1409705310] Warning: Return code of 255 for check of service 'check users' on host 'webserver1' was out of bounds.
[1409705310] SERVICE ALERT: webserver1;check users;UNKNOWN;HARD;3;(Return code of 255 is out of bounds)
[1409705313] Warning: Return code of 255 for check of service 'check load' on host 'webserver1' was out of bounds.
[1409705313] SERVICE ALERT: webserver1;check load;UNKNOWN;HARD;3;(Return code of 255 is out of bounds)
[1409705319] SERVICE ALERT: webserver1;check sda1;OK;HARD;3;DISK OK - free space: /boot 158 MB (86% inode=99%):
[1409705331] SERVICE ALERT: webserver1;check swap;OK;HARD;3;DISK OK - free space: / 17097 MB (91% inode=94%): /dev/shm 245 MB (100% inode=99%): /boot 158 MB (86% inode=99%):
[1409705335] SERVICE ALERT: webserver1;check zombie proce;OK;HARD;3;PROCS OK: 0 processes with STATE = Z
[1409705335] HOST ALERT: webserver1;UP;HARD;1;PING OK - Packet loss = 0%, RTA = 0.79 ms
[1409705335] HOST NOTIFICATION: linux;webserver1;UP;notify-host-by-fetion;PING OK - Packet loss = 0%, RTA = 0.79 ms
[1409705338] SERVICE ALERT: webserver1;check rootdisk;OK;HARD;3;DISK OK - free space: / 17097 MB (91% inode=94%):


無圖無真相

Nagios配合飛信發短信

Nagios配合飛信發短信

Nagios配合飛信發短信

Nagios配合飛信發短信

向AI問一下細節

免責聲明:本站發布的內容(圖片、視頻和文字)以原創、轉載和分享為主,文章觀點不代表本網站立場,如果涉及侵權請聯系站長郵箱:is@yisu.com進行舉報,并提供相關證據,一經查實,將立刻刪除涉嫌侵權內容。

AI

开阳县| 赤峰市| 洛阳市| 来凤县| 枞阳县| 墨江| 兴业县| 柘城县| 新民市| 裕民县| 赫章县| 宜黄县| 思南县| 石家庄市| 永善县| 常熟市| 纳雍县| 军事| 桐城市| 进贤县| 小金县| 福海县| 正定县| 开封县| 平邑县| 邓州市| 渑池县| 拜泉县| 蚌埠市| 寿宁县| 乌兰察布市| 农安县| 阿尔山市| 阿巴嘎旗| 大名县| 马尔康县| 寻乌县| 邮箱| 龙江县| 水富县| 文成县|