Chinaunix首页 | 论坛 | 博客
  • 博客访问: 140428
  • 博文数量: 68
  • 博客积分: 10
  • 博客等级: 民兵
  • 技术积分: 720
  • 用 户 组: 普通用户
  • 注册时间: 2011-02-28 20:01
文章分类

全部博文(68)

文章存档

2015年(68)

我的朋友

分类: 系统运维

2015-08-31 17:18:51

(飞信机器人网站 )

(1)下载安装、系统配置

# wget fetion/downng/fetion20091117-linux.tar.gz 

# tar zxvf fetion20091117-linux.tar.gz 

# mv fx /usr/local/sms

把支持库复制到/usr/lib/目录下

#  cd /usr/local/sms

# cp lib*so* /usr/lib/

设定lib库配置文件

#vi /etc/ld.so.conf

#增加一条

/usr/lib/

#保存退出后,执行

#ldconfig

 

(2)详细用法:

# ./fetion -h

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]

    --add=[uri]

    --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/3 sms longsms smartmsg mms]

    --file-gb=[gb2312/gbk file]

    --file-utf8=[utf8 file]

    --query-cmcc-no

    --testaccount

    --auto-retry

    --get-web-session

    --action=getpiccode --mobile=13910000000 --pwd=[pwd] (--piccode-url=[url])

    --action=appsubscribe --mobile=[mobile] --pwd=[pwd] --pic-certificate-id=[certid] --pic-cert-code=[certcode] --apply-sub-service-url=[url]

    --action=subscribe --mobile=[mobile] --pwd=[pwd] --sms-code=[smscode] --subscribe-url=[url]

    --action=updatepwd --mobile=[mobile] --pwd=[pwd] --sms-code=[smscode] --update-pwd-url=[url]

 

(3)测试:

#./fetion --mobile=1580029xxxx --pwd=xxxxx --to 1580029xxxx --msg-utf8="server down"

 

Send Msg to:

TP=3 ID=472119592   LO=0 SU=0 RE=0 SI=772279007 SE=6903  MO=15800295127 GR=      ST=101  RE=1 OL=499  NN=15800295127LN=

SIP-C/2.0 280 Send SMS OK

T: sip:772279007@fetion.com.cn;p=6903

I: 2

Q: 1 M

测试成功

 

(4)nagios配置

(4.1)定义命令:

# vi /usr/local/nagios/etc/objects/commands.cfg

添加:

define command {

        command_name notify-service-by-sms

        command_line /usr/local/sms/fetion --config=/usr/local/sms/num.conf --index=1 --to=$CONTACTPAGER$  --msg-utf8="$NOTIFICATIONTYPE$: $HOSTNAME$: $SERVICEDESC$ is $SERVICESTATE$"

}

 

define command {

        command_name notify-host-by-sms

        command_line /usr/local/sms/fetion --config=/usr/local/sms/num.conf --index=1 --to=$CONTACTPAGER$  --msg-utf8="$NOTIFICATIONTYPE$: $HOSTNAME$ is $HOSTSTATE$"

}

(注:文件num.conf的格式为:(index)1 (mobile)158xxxxx (password)xxxxx )

 

(4.2)在联系人中添加定义好的命令:

# vi /usr/local/nagios/etc/objects/contacts.cfg

define contact{

        contact_name                                sa

        use                                                 generic-contact

        alias                                                System Administrator liuweiqing

        service_notification_commands      notify-service-by-sms

        host_notification_commands           notify-host-by-sms

        email                                                sa@mydomain.com

        pager                                               13700xxxxxx  #(接收告警短信的手机号,需先在飞信中加为好友)

        }

 

(4.3)在监控的服务中添加定义好的联系人:

#  vi /usr/local/nagios/etc/objects/service.cfg  

define service {

        use                                generic-service

        host_name                    myserver

        service_description       squid sever

        contacts                        sa

        check_interval               5

        retry_interval                 1

        max_check_attempts     5

        check_command check_squid!!3128!2

}


到这里配置就完成了,可在重启nagios后停掉服务来测测能否接收到告警短信

阅读(281) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~