日本综合一区二区|亚洲中文天堂综合|日韩欧美自拍一区|男女精品天堂一区|欧美自拍第6页亚洲成人精品一区|亚洲黄色天堂一区二区成人|超碰91偷拍第一页|日韩av夜夜嗨中文字幕|久久蜜综合视频官网|精美人妻一区二区三区

RELATEED CONSULTING
相關咨詢
選擇下列產(chǎn)品馬上在線溝通
服務時間:8:30-17:00
你可能遇到了下面的問題
關閉右側(cè)工具欄

新聞中心

這里有您想知道的互聯(lián)網(wǎng)營銷解決方案
nagios分布式配置

Nagios分布式配置

作者:SA Team 2011-03-28 13:39:45
運維
系統(tǒng)運維
分布式 nagios的分布式是通過在主服務端開啟nsca接口進行內(nèi)容的接收,客戶端通過調(diào)用send_nsca程序,進行內(nèi)容的傳輸,服務端在接收到約定格式的內(nèi)容后,進行告警。以下內(nèi)容省略了,nagios的主服務端與分布式服務端的安裝步驟。

目前創(chuàng)新互聯(lián)公司已為近1000家的企業(yè)提供了網(wǎng)站建設、域名、雅安服務器托管、網(wǎng)站托管、服務器托管、企業(yè)網(wǎng)站設計、大峪網(wǎng)站維護等服務,公司將堅持客戶導向、應用為本的策略,正道將秉承"和諧、參與、激情"的文化,與客戶和合作伙伴齊心協(xié)力一起成長,共同發(fā)展。

圖-nagios

nagios分布式配置具體過程如下:

  一、NSCA插件安裝與配置

  http://nchc.dl.sourceforge.net/sourceforge/nagios/nsca-2.7.2.tar.gz

  編譯安裝nsca:

  查看源代碼

  打印幫助0./configure && make all

  nagios主服務端:

  1.拷貝nsca相關文件至nagios目錄

  查看源代碼

  打印幫助0cp sample-config/nsca.cfg /usr/local/nagios/etc/

  1cp src/nsca /usr/local/nagios/bin/

  2chown nagios.nagios /usr/local/nagios/etc/nsca.cfg

  3chown nagios.nagios /usr/local/nagios/bin/nsca

  2.配置nsca.cfg文件中password

  查看源代碼

  打印幫助0vi /usr/local/nagios/etc/nsca.cfg #去掉password前面的#,設置密碼

  1password=xxx

  3.開啟nsca程序

  查看源代碼

  打印幫助0/usr/local/nagios/bin/nsca -c /usr/local/nagios/etc/nsca.cfg

  4.開啟防火墻5667端口

  查看源代碼

  打印幫助0iptables -I RH-Firewall-1-INPUT -m state --state NEW -m tcp -p tcp --dport 5667 -j ACCEPT

  nagios分布式服務端:

  1.拷貝send_nsca相關文件至nagios目錄

  查看源代碼

  打印幫助0cp sample-config/send_nsca.cfg /usr/local/nagios/etc/

  1cp src/send_nsca /usr/local/nagios/bin/

  2chown nagios.nagios /usr/local/nagios/etc/send_nsca.cfg

  3chown nagios.nagios /usr/local/nagios/bin/send_nsca

  2.配置nsca.cfg文件中password

  查看源代碼

  打印幫助0vi /usr/local/nagios/etc/send_nsca.cfg #去掉password前面的#,配置與主服務端相同的密碼

  1password=xxx

#p#

  二、Nagios主服務端與分布式服務端配置

  nagios主服務端:

  1.修改nagios.cfg文件

  查看源代碼

  打印幫助0vi /usr/local/nagios/etc/nagios.cfg

  1#修改以下參數(shù)值

  2check_external_commands=1

  3accept_passive_service_checks=1

  4accept_passive_host_checks=1

  2.修改服務與主機的監(jiān)控,以下為配置示例,該示例定義的服務與主機應該與分布式服務端相同

  查看源代碼

  打印幫助00define host{

  01name test

  02use generic-host

  03address 192.168.0.8 #分布式服務端內(nèi)監(jiān)控的主機地址

  04check_freshness 1 #開啟強制刷新

  05freshness_threshold 480 #主服務端強制刷新的時間,具體含義請參考手冊

  06passive_checks_enabled 1 #開啟被動檢測模式

  07active_checks_enabled 0 #關閉主服務端對該服務的主動檢測

  08

      09}

      10define service{

      11use generic-service #根據(jù)實際情況修改

      12host_name test

      13service_description CPU Load

      14check_command check_nrpe!check_load

      15

      16check_freshness 1 #開啟強制刷新

      17freshness_threshold 480 #主服務端強制刷新的時間,具體含義請參考手冊

      18passive_checks_enabled 1 #開啟被動檢測模式

      19active_checks_enabled 0 #關閉主服務端對該服務的主動檢測

      20}

    #p#

      nagios分布式服務端:

      1.修改nagios.cfg文件

      查看源代碼

      打印幫助0vi /usr/local/nagios/etc/nagios.cfg

      1#修改以下參數(shù)值

      2enable_notifications=0

      3obsess_over_services=1

      4ocsp_command=submit_service_check_result

      5obsess_over_hosts=1

      6ochp_command=submit_host_check_result

      2.創(chuàng)建submit_service_check_result腳本

      查看源代碼

      打印幫助00vi /usr/local/nagios/libexec/submit_service_check_result

      01#!/bin/sh

      02# Arguments:

      03# = host_name (Short name of host that the service is

      04# associated with)

      05# = svc_description (Description of the service)

      06# = state_string (A string representing the status of

      07# the given service - "OK", "WARNING", "CRITICAL"

      08# or "UNKNOWN")

      09# = plugin_output (A text string that should be used

      10# as the plugin output for the service checks)

      11#

      12# Convert the state string to the corresponding return code

      13return_code=-1

      14case "$3" in

      15OK)

      16return_code=0

      17;;

      18WARNING)

      19return_code=1

      20;;

      21CRITICAL)

      22return_code=2

      23;;

      24UNKNOWN)

      25return_code=-1

      26;;

      27esac

      28# pipe the service check info into the send_nsca program, which

      29# in turn transmits the data to the nsca daemon on the central

      30# monitoring server

      31/usr/bin/printf "%s\t%s\t%s\t%s\n" "$1" "$2" "$return_code" "$4" | /usr/local/nagios/bin/send_nsca -H 1.1.1.1(修改為主服務端的ip) -c /usr/local/nagios/etc/send_nsca.cfg

      查看源代碼

      打印幫助0chmod +x /usr/local/nagios/libexec/submit_service_check_result

      1chown nagios.nagios submit_service_check_result

      3.創(chuàng)建submit_host_check_result腳本

      查看源代碼

      打印幫助00vi /usr/local/nagios/libexec/submit_host_check_result

      01#!/bin/sh

      02# Arguments:

      03# = host_name (Short name of host that the service is

      04# associated with)

      05# = svc_description (Description of the service)

      06# = state_string (A string representing the status of

      07# the given service - "OK", "WARNING", "CRITICAL"

      08# or "UNKNOWN")

      09# = plugin_output (A text string that should be used

      10# as the plugin output for the service checks)

      11#

      12# Convert the state string to the corresponding return code

      13return_code=-1

      14case "$2" in

      15UP)

      16return_code=0

      17;;

      18DOWN)

      19return_code=1

      20;;

      21UNREACHABLE)

      22return_code=2

      23;;

      24esac

      25# pipe the service check info into the send_nsca program, which

      26# in turn transmits the data to the nsca daemon on the central

      27# monitoring server

      28/usr/bin/printf "%s\t%s\t%s\n" "$1" "$return_code" "$3" | /usr/local/nagios/bin/send_nsca -H 1.1.1.1(修改為主服務端的ip) -c /usr/local/nagios/etc/send_nsca.cfg

    #p#

      查看源代碼

      打印幫助0chmod +x /usr/local/nagios/libexec/submit_host_check_result

      1chown nagios.nagios submit_host_check_result

      3.在command.cfg文件中定義submit_service_check_result,submit_host_check_result命令

      查看源代碼

      打印幫助0vi /usr/local/nagios/etc/objects/command.cfg #加入以下內(nèi)容

      1define command{

      2command_name submit_service_check_result

      3command_line /usr/local/nagios/libexec/submit_service_check_result $HOSTNAME$ '$SERVICEDESC$' $SERVICESTATE$ '$SERVICEOUTPUT$'

      4}

      5define command{

      6command_name submit_host_check_result

      7command_line /usr/local/nagios/libexec/submit_host_check_result $HOSTNAME$ $HOSTSTATE$ '$HOSTOUTPUT$'

      8}

      4.配置示例

      查看源代碼

      打印幫助00define host{

      01name test

      02use generic-host

      03address 192.168.0.8 #分布式服務端內(nèi)監(jiān)控的主機地址

      04}

      05define service{

      06use generic-service #根據(jù)實際情況修改

      07host_name test

      08service_description CPU Load

      09check_command check_nrpe!check_load

      10}

      BTW:請注意分布式服務端與主服務端定義主機與服務配置的區(qū)別,當分布式服務端定義了主機與服務時,同樣需要在主服務端定義一次。以下幾個參數(shù)無需在分布式服務端特殊定義。

      check_freshness,freshness_threshold,passive_checks_enabled,active_checks_enabled

      freshness_threshold 強制刷新時間,主要的作用是當分布式服務端未提交新的數(shù)據(jù)時,服務端可以強制進行狀態(tài)刷新,進行及時的預警。

      如何在不安裝分布式nagios的情況下,監(jiān)控另一防火墻后的內(nèi)網(wǎng)主機呢?其實方法很多,比如check_ssh,這里共享一個方法,該方法是同事nonamexz想到的。

      通過nagios的自定義變量,在nrpe的命令行增加一個端口的參數(shù),自定義端口,通過防火墻進行映射至內(nèi)網(wǎng)不同的服務器

      查看源代碼

      打印幫助00define command{

      01command_name check_NRPE #定義一個新的命令

      02command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -p $_HOSTPORT$ -t 60

      03}

      04define host{

      05name test

      06use generic-host

      07address 2.2.2.2 #需要監(jiān)控的服務器的外網(wǎng)地址,比如防火墻地址

      08_PORT 5668 #自定義的外網(wǎng)端口,改端口是通過防火墻進行內(nèi)的需要監(jiān)控的服務器的nrpe的端口映射

      09}

      10define service{

      11use generic-service

      12host_name test

      13service_description CPU Load

      14check_command check_NRPE!check_load #這里定義的時候,使用自定義的nrpe

通過文章的介紹,我們清楚的知道了nagios分布式配置全過程!

成都網(wǎng)站建設公司-創(chuàng)新互聯(lián),建站經(jīng)驗豐富10多年以來專注數(shù)字化網(wǎng)站開發(fā)營銷,提供企業(yè)網(wǎng)站建設,高端網(wǎng)站設計,響應式網(wǎng)站制作,設計師量身打造品牌風格,熱線:028-86922220
當前標題:nagios分布式配置
URL地址:http://www.dlmjj.cn/article/ccddgdg.html