新版飞信+Nagios部署监控系统

版权声明:原创作品,允许转载,转载时请务必以超链接形式标明文章 原始出处 、作者信息和本声明。否则将追究法律责任。http://52199999.blog.51cto.com/740826/202514
Linux下安装飞信

1飞信官方命令下载:fetion

tar –xvf   fetion20090406003-linux.tar.gz
cd install
cp fetion / usr/bin (拷贝命令到/usr/bin/下)
useradd nagios
chmod -R 7755 /usr/bin/fetion
chown -R  nagios:nagios /usr/bin/fetion
4飞信命令行工具/飞信机器人(2009

文件列表说明(fetion20090406003-linux.tar.gz中包含文件说明
 fetion    linux下主运行程序
 fetion.exe  win32下主运行程序
 sample.conf  演示配置文件
 readme.txt  本说明文件
 plugins 机器人框架程序
 fxdemo.sql 机器人框架数据库(请导入到数据库)
  cron.sh      
机器人监控程序(
LINUX)
  robots.dat   
机器人账号密码(配合
cron.sh)
注:本程序需要 libACE的支持,库请到 http://www.it-adv.net/  中下载

5Linux 下需用用到的4个文件
 http://www.it-adv.net/fetion/downng/library_linux.tar.gz
(下载地址)
     libACE.so.5.6.8
     libACE_SSL.so.5.6.8
     libcrypto.so.0.9.8
     libssl.so.0.9.8
 6
tar –xvf library_linux.tar.gz
在安装飞信之前需要在/usr/lib目录下加上libACE库文件,以便使飞信能够正常使用

复制这几个文件到这两个目录下 /lib/ /usr/lib/
ldd /usr/bin/fetion

>> 使用说明 <<
以下参数提供登录用的账号密码(三种方式,手机号-密码 飞信号-密码文件--索引)

    --mobile=[
手机号]       登录手机号
    --sid=[
飞信号]        登录飞信号
    --pwd=[
密码]         登录密码
    --config=[
文件名]       存储手机号、密码的文件。
    --index=[
索引号]       索引
   
以下参数提供接收者
    --to=[
手机号/飞信号/URI]   接收消息的手机号/飞信号/URI.如果知道对方URI,则只需自己在对方好友列表,无需对方在自己好友列表就能发送。
           
20090203003版本后,支持多个号码,中间用,逗号分隔
    --msg-utf8=[
信息]  
     
发送的消息,UTF8编码

    --msg-gb=[
信息]  
      
发送的消息,GB编码

    --file-utf8=[
文件utf8格式]
      
发送文件内容

    --file-gb=[
文件gb格式]
      
发送文件内容

    --msg-type=[0/1/2]
      
发送消息类型:普通消息 长消息 智能短信
     
小工具   
     --query-cmcc-no  
查询移动公司手机段

     
以下为可选项
    --debug  
   
显示调试信息
    --hide     
   
隐身登录
    --proxy-ip=http
代理ip
    --proxy-port=http
代理端口
>>
举例 <<
 
linux下,请使用如下命令:

cd install 进去解压后目录

./fetion --mobile=13466xxxx --pwd=chengxc123 --to 13466xxx --msg-utf8=123 测试飞信能否成功发送短信,发送对象需是自己飞信好友或自己

 

一、    yum安装ngios

yum groupinstall "Nagios Monitoring System"
yum -y install nagios-plugins-all
cd /etc/nagios/
nagios -v nagios.cfg 检测nagios  配置文件是否合法
htpasswd -cb /etc/nagios/passwd admin 123  (用户名 admin密码123) 生成nagios登录密码
不要忘了修改cgi.cfg文件以下行
authorized_for_system_information=admin
authorized_for_configuration_information=admin
authorized_for_system_commands=admin
authorized_for_all_services=admin
authorized_for_all_hosts=admin
authorized_for_all_service_commands=admin
authorized_for_all_host_commands=admin
为了支持Nagios安装完后status map,trend等完全显示,需要gd库的支持,首先看一下gdgd-devel有没有安装
rpm -qa |grep gd
yum -y install gd*安装也可

 

二、修改主要配置文件
1vim /etc/httpd/conf.d/nagios.conf
ScriptAlias /nagios/cgi-bin/ /usr/lib/nagios/cgi-bin/

<Directory /usr/lib/nagios/cgi-bin/>
   deny from none
   allow from all  (可以是独立的ip或网段)
Alias /nagios/ /usr/share/nagios/html/
<Directory /usr/share/nagios/html/>
   Options None
   order deny,allow
   deny from none
   allow from all
2、编译安装配置httpd.conf文件路径:vim /usr/local/apache2/conf/httpd.conf

在最下面:   

Include /etc/httpd/conf.d/nagios.conf

/usr/local/apache2/bin/httpd -k start

 
vim /etc/nagios/nagios.cfg
添加下列行
cfg_file=/etc/nagios/cheng.cfg(自定义的,添加即可)
cfg_file=/etc/nagios/contactgroups.cfg(默认就有去掉注释)
cfg_file=/etc/nagios/contacts.cfg(默认)
cfg_file=/etc/nagios/miscommands.cfg(自己定义的)
即创建自定义文件cheng.cfgcontactgroups.cfgcontacts.cfgmiscommands.cfg
配置cheng.cfg
define host{

        use                     linux-server

        host_name               vfast

        contact_groups          vfastgroup

        max_check_attempts        5

        alias                   localhost

        address                 192.168.0.105

        }

define service{

        use                             local-service

        host_name                      admin
        contact_groups                  admingroup

        service_description             PING

        check_command                   check_ping!100.0,20%!500.0,60%

        }
define service{

        use                             local-service

        host_name                       chao

        contact_groups                  admingroup

        service_description             HTTP_CHECK

        check_command                   check_http

       }

define host{

        use                     linux-server

        host_name               chao

        contact_groups          admingroup

        max_check_attempts      5

        alias                   localhost

        address                 192.168.0.110

        }

 

define hostgroup{

        hostgroup_name  chaoguo
        alias           Test Servers

        members         admin,chao

        }

 
define service {

        host_name             chao

        service_description   check-host-alive

        check_period          24x7

        max_check_attempts    4

        normal_check_interval 3

        retry_check_interval  2

        contact_groups        admingroup

        notification_interval   10

        notification_period     24x7

        notification_options    w,u,c,r

        check_command           check-host-alive

        }

配置contactgroups.cfg
define contactgroup {

      contactgroup_name    admingroup

      alias                system administrator group

      members              admin
      }

配置contacts.cfg
define contact {

       contact_name                    admin
       alias                           system admin

       host_notification_period        24x7

       service_notification_period     24x7

       host_notification_options       d,r

       service_notification_options    c,w,r

       service_notification_commands   notify-service-by-fetion

#      service_notification_commands   notify-service-by-email

       host_notification_commands      notify-host-by-fetion

#      email                          [email protected]

       pager                         1312323232323 #手机号

  }

配置miscommands.cfg文件
define command {

         command_name            notify-host-by-fetion

         command_line       /usr/bin/fetion --mobile=13422222222 --pwd=xxxxxxxx --to=$CONTACTPAGER$ --msg-utf8="Host $HOSTSTATE$ alert for $HOSTNAME$! on '$LONGDATETIME$'" $CONTACTPAGER$

}

 define command {

         command_name         notify-service-by-fetion

command_line    /usr/bin/fetion --mobile=134663xxxx --pwd=xxxxxxxx --to=$CONTACTPAGER$ --msg-utf8="$HOSTADDRESS$ $HOSTALIAS$/$SERVICEDESC$ is $SERVICESTATE$ on $LONGDATETIME$" $CONTACTPAGER$

              }

三、客户端的配置:

1、需求软件的下载:

nagios插件程序:

nrpe软件:

2、软件的安装

(1) nagios插件的安装:

     首先在安装前建立nagios用户,命令如下:

useradd nagios -s /sbin/nologin –M

tar zxvf nagios-plugins-1.4.13.tar.gz

cd nagios-plugins-1.4.13

./configure --prefix=/usr/local/nagios

make && make install

chown -R nagios.nagios /usr/local/nagios/

(2) nrpe的程序的安装:

tar zxvf nrpe-2.12.tar.gz

cd nrpe-2.12

./configure

Make all

Make install-plugin

Make install-daemon

Make install-daemon-config

 (3) 修改nrpe.cfg配置文件:

vi /usr/local/nagios/etc/nrpe.cfg

server_address修改为本机ip地址

allowed_hosts地址改为远程控制器ip地址

 (4) 运行nrpe服务:

/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg -d

 (5) 查看nrpe运行情况:

Netstat –pant | grep nrpe

nrpe是否运行成功,占用端口5666

 (6) 设置nrpe自启动:

Vi /etc/rc.local

/usr/local/nagios/bin/nrpe -c /usr/local/nagios/etc/nrpe.cfg –d

至此客户端配置玩活.

本文出自 “技行天下” 博客,请务必保留此出处http://52199999.blog.51cto.com/740826/202514

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章