新版飛信+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

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