PNP4Nagios

    版本為 02:54, 27 Dec 2024

    到這個版本。

    返回到 版本存檔.

    查閱目前版本

    PNP4Nagios - http://www.pnp4nagios.org/

    NOTE: 必須事先安裝及設定好 Nagios

    開始安裝

    必要的套件

    yum install gcc perl-Time-HiRes rrdtool-perl make
    
    tar xzf pnp4nagios-0.6.21.tar.gz
    cd pnp4nagios-0.6.21
    ./configure 
    

    NOTE: 

    如果 Nagios 的系統帳號與群組不是預設的 nagios,必須加上參數
    ./configure --with-nagios-user=icinga --with-nagios-group=icinga

    如果出現以下訊息,表示 configure 完成

    *** Configuration summary for pnp4nagios-0.6.21 03-24-2013 ***

      General Options:
      -------------------------         -------------------
      Nagios user/group:                nagios nagios
      Install directory:                /usr/local/pnp4nagios
      HTML Dir:                         /usr/local/pnp4nagios/share
      Config Dir:                       /usr/local/pnp4nagios/etc
      Location of rrdtool binary:       /usr/bin/rrdtool Version 1.3.8
      RRDs Perl Modules:                FOUND (Version 1.3008)
      RRD Files stored in:              /usr/local/pnp4nagios/var/perfdata
      process_perfdata.pl Logfile:      /usr/local/pnp4nagios/var/perfdata.log
      Perfdata files (NPCD) stored in:  /usr/local/pnp4nagios/var/spool

      Web Interface Options:
      -------------------------         -------------------
      HTML URL:                         http://localhost/pnp4nagios
      Apache Config File:               /etc/httpd/conf.d/pnp4nagios.conf


      Review the options above for accuracy.  If they look okay,
      type 'make all' to compile.

     

    開始編譯

    make all
    make fullinstall 
    

    設定

    編輯 /etc/httpd/conf.d/pnp4nagios.conf

    ...
    AuthUserFile /etc/nagios/htpasswd.users <-- 將這行改成與 Nagio 設定相同
    
    ... 
    

    瀏覽首頁:http://xxx.xxx.xxx.xxx/pnp4nagios/

    如果頁面的內容沒有出現錯誤,將以下檔案作更名

    mv /usr/local/pnp4nagios/share/install.php /usr/local/pnp4nagios/share/install.php.xxx
    

    Nagios 設定

    編輯 /etc/nagios/nagios.cfg

    process_performance_data=1
    
    service_perfdata_command=process-service-perfdata
    host_perfdata_command=process-host-perfdata 
    

    編輯 /etc/nagios/objects/commands.cfg

    define command {
           command_name    process-host-perfdata
           command_line    /usr/bin/perl /usr/local/pnp4nagios/libexec/process_perfdata.pl -d HO
    STPERFDATA
    }
    
    
    define command {
           command_name    process-service-perfdata
           command_line    /usr/bin/perl /usr/local/pnp4nagios/libexec/process_perfdata.pl
    }
    

    編輯 /etc/nagios/objects/templates.cfg

    • 將 generic-host 與 generic-service 的 process_perf_data 改為 0,否則預設為 1 時,所有的 host 與 服務都會自動啟用這功能
    define host {
       name                            generic-host
       ...
       process_perf_data 0
       ...
    }
    
    define service {
       name                            generic-service
       ...
       process_perf_data 0
       ...
    }
    

    對特定 host 或 service 啟用圖形功能

    編輯 /etc/nagios/objects/MES-servers.cfg,在 host 或 service 的設定裡加上 process_perf_data 1

    註:MES-server.cfg 是以筆者環境為例

    define host {
       use                            generic-host
       host_name                      ap1
       ...
       process_perf_data              1
       action_url                     /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_
       ...
    }
    
    define service {
       use                            generic-service
       host_name                      ap1
       service_description            PING 
       ...
       process_perf_data              1
       action_url                     /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$
       ...
    }
    

    設定 popup 顯示(optional)

    從 pnp4nagios 安裝程式裡複製 status-header.ssi

    cp <pnp4nagios 原始程式目錄>/contrib/ssi/status-header.ssi /usr/share/nagios/ssi
    

    NOTE:

    此檔不可有執行的權限

    /usr/share/nagios/ssi 此目錄會因為 nagios 安裝版本不同有所差異

    編輯 /etc/nagios/objects/MES-servers.cfg,改變 action_url

    define host {
       use                            generic-host
       host_name                      ap1
       ...
       process_perf_data              1
       action_url                     /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=_HOST_' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=_HOST_
       ...
    }
    
    define service {
       use                            generic-service
       host_name                      ap1
       service_description            PING 
       ...
       process_perf_data              1
       action_url                     /pnp4nagios/index.php/graph?host=$HOSTNAME$&srv=$SERVICEDESC$' class='tips' rel='/pnp4nagios/index.php/popup?host=$HOSTNAME$&srv=$SERVICEDESC$
       ...
    }

    Performance Data 客制化

    Performance  Data 格式

    label=value[UOM];[warning-range];[critical-range];[min];[max]

    HTTP 輸出資訊範例

    HTTP OK: HTTP/1.1 200 OK - 46869 bytes in 0.294 second response time | time=0.294561s;;;0 size=46869B;;;0
    

    NOTE:

    資訊內容從 | 符號以後的就是 Performance Data

    Performance Data 格式更多詳細資訊如下:

    1. space separated list of label/value pairs
    2. label can contain any characters
    3. the single quotes for the label are optional. Required if spaces, = or ' are in the label
    4. label length is arbitrary, but ideally the first 19 characters are unique (due to a limitation in RRD). Be aware of a limitation in the amount of data that NRPE returns to Nagios
    5. to specify a quote character, use two single quotes
    6. warn, crit, min/ or max/ may be null (for example, if the threshold is not defined or min and max do not apply). Trailing unfilled semicolons can be dropped
    7. min and max are not required if UOM=%
    8. value, min and max in class [-0-9.]. Must all be the same UOM
    9. warn and crit are in the range format (see Section 2.5). Must be the same UOM
    10. UOM (unit of measurement) is one of:
      • no unit specified - assume a number (int or float) of things (eg, users, processes, load averages)
      • s - seconds (also us, ms)
      • % - percentage
      • B - bytes (also KB, MB, TB, GB?)
      • c - a continous counter (such as bytes transmitted on an interface)
    Powered by MindTouch Core