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

提示:飞信接口已经不可用

nagios要添加飞信报警功能,尽管网上有很多教程,不过许多都需要瞎折腾才能正常用飞信,所以下面记录一下,供参考

系统centos6.4 64位

安装飞信

下载地址 http://pan.baidu.com/s/1sXpGj 找到linux安装包 > 飞信 >fetiontar.zip

1
2
3
4
5
6
7
# unzip fetiontar.zip
# cd fetiontar
# ls
fetion  lib
# mkdir /usr/local/fetion
# cp fetion /usr/local/fetion/
# chmod 755 /usr/local/fetion/fetion

1
2
3
4
5
6
7
8
9
10
11
12
13
# 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的库文件

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

1
2
3
4
5
6
7
8
9
10
11
# 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:

查看缺少哪些库,然后依次安装

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# 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

1
2
# /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

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# 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

下面就可以给飞信的好友发送信息了

# /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为自己创建的文件,定义监控的服务和主机,监控的动作


1
2
3
4
5
6
7
8
9
10
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
}


1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
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
        }

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
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
        }

1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
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

1
2
3
4
5
6
[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)

1
2
3
4
5
6
7
8
9
10
11
12
13
14
[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%):

无图无真相

本文转自 bbotte 51CTO博客,原文链接:http://blog.51cto.com/bbotte/1543832,如需转载请自行联系原作者

Nagios配合飞信发短信相关推荐

  1. java 调用飞信发短信(转)

    网上看到有网页版的飞信,http://fetionlib.appspot.com/ 可以添加好友,群发和定时发送短信给飞信好友,还开放了API接口供程序调用,可以用它来监控机器是否正常服务定期给管理员 ...

  2. linux用飞信发短信

    一.下载飞信 到此网站下载飞信机器人 http://www.it-adv.net/ 下载完把飞信移动到/usr/local/fetion mv cenos54X64_20101113/lib ./ v ...

  3. Python 采用 飞信 发短信

    最近几天琢磨了一下Python,仿照网上高手写了发送短信的小程序,,将代码发之 首先声明:飞信协议模块的代码不是我写得,而是copy别人得东东 #!/usr/bin/env python # -*- ...

  4. 使用 139邮箱免费给任何移动手机发短信

    使用飞信免费发送短信已经成为短信达人的常识.可是,使用飞信发短信 要求两人为飞信好友.这带来了两个问题: 1.想给一位还未添加好友的朋友发送一条短信,你必须先添加他为好友.这需要双方进行若干次确认.那 ...

  5. 教你在Linux用飞信(fetion)免费发短信

    http://linux.chinaunix.net/bbs/thread-1021142-1-1.html 一. 软件环境(centos 5为例) -- 原文从 www.hiadmin.com转载 ...

  6. 利用飞信给自己发短信的shell脚本

    利用飞信给自己发短信的shell脚本翻译自一个python脚本因为openwrt要装python太大了.所以用了两天非工作时间 翻译成了 shell脚本 .测试可用. http://dl.dbank. ...

  7. PHP实现飞信接口来通过网页免费发短信

    首先感谢郝同学告诉我这么一个神奇的接口 可以输入你的手机号.密码.对方手机号.发送内容直接给对方发短信. 源作者博客地址为:http://blog.quanhz.com/ 郝同学的博客地址:http: ...

  8. java+调用飞信_java调用飞信接口发短信

    java调用飞信接口发短信,看到挺好的,有利于大家做毕业设计加亮点,就发给大家了(新人发帖,不会发多个文件名,测试类就放这了) 需要这3个jar包: commons-codec-1.4.jar com ...

  9. php免费短信接,PHP实现飞信接口来通过网页免费发短信

    首先感谢郝同学告诉我这么一个神奇的接口 可以输入你的手机号.密码.对方手机号.发送内容直接给对方发短信. 源作者博客地址为:http://blog.quanhz.com/ 郝同学的博客地址:http: ...

最新文章

  1. python 获取集合里面的某一个元素
  2. C# 转换人民币大小金额(WinForm、Asp.Net)
  3. sdwan技术发展正蚕食mpls市场—vecloud
  4. 需求用例分析之九:序列图
  5. eclipse @ 注释为何一写就报错
  6. 2006---2009年杭电计算机历年研究生复试---笔试编程
  7. 软件安装(JDK+MySQL+TOMCAT)
  8. linux 根目录分配多少好,Linux下硬盘怎么分区才合适:根分区(/)交换分区(/swap)和/boot分区需要多大...
  9. Java I/O之字节流与字符流的区别
  10. php怎么清空cookies,php cookie如何清除
  11. C#正则怎么判断字符串中是否有汉字
  12. java 牙位图插件_牙医的骄傲-智能牙位图中文医疗应用app全球排名No.1
  13. Swagger API文档Responses中Object类型无法显示,求指引
  14. 这些初创公司为何要拒绝上亿美元的投资
  15. 原生js-简易点名册实现
  16. DotCMS中文教程
  17. 索引:手把手教你索引从零基础到精通使用
  18. 2022版自动发卡平台自动发卡源码
  19. Android 线性布局 、相对布局
  20. C# ------ MEF

热门文章

  1. 打印机 正在删除正在打印怎么也删除不了
  2. 【cudaMemcpy】
  3. 电源系统优化设计,低压差稳压器(LDO)如何选型?
  4. 信息安全技术——(三)标识与认证技术
  5. oracle查询表数据写入时间,求大神解决关于查询Oracle表数据时间
  6. Python自动化开发【1】:Python简介和入门
  7. go 格式化占位符详解
  8. gcc/g++ 命令的常用选项
  9. jQuery实现焦点图自动切换
  10. [渝粤教育] 江西财经大学 数据新闻可视化 参考 资料