性能統計グラフ追加(Nagios+PNP)

最終更新日: 2014.02.19

<<トップページ <<新着情報 <<サイト内検索 <<CentOSで自宅サーバー構築 <<Scientific Linuxで自宅サーバー構築

■概要

NagiosのアドオンPNPを導入して、Nagios監視項目の性能統計データをグラフ化する。

Nagios導入済であることが前提


■PNPインストール

[root@fedora ~]# yum -y install rrdtool php-gd ← PNPに必要なパッケージインストール

[root@fedora ~]# /etc/rc.d/init.d/httpd reload ← Apache設定再読み込み
httpd を再読み込み中:                                      [  OK  ]

[root@fedora ~]# wget http://jaist.dl.sourceforge.net/sourceforge/pnp4nagios/pnp-0.4.13.tar.gz ← PNPダウンロード

※最新版のURLはダウンロードページで確認すること

[root@fedora ~]# tar zxvf pnp-0.4.13.tar.gz ← PNP展開

[root@fedora ~]# cd pnp-0.4.13 ← PNP展開先ディレクトリへ移動

[root@fedora pnp-0.4.13]# ./configure && make all && make install && make install-config ← PNPインストール

[root@fedora pnp-0.4.13]# cd ← PNP展開先ディレクトリを抜ける

[root@fedora ~]# rm -rf pnp-0.4.13 ← PNP展開先ディレクトリを削除

[root@fedora ~]# rm -f pnp-0.4.13.tar.gz ← ダウンロードしたファイルを削除


■PNP設定

(1)PNP設定
[root@fedora pnp]# cp /usr/local/nagios/etc/pnp/process_perfdata.cfg-sample /usr/local/nagios/etc/pnp/process_perfdata.cfg
 ← サンプルよりprocess_perfdata.cfgコピー

[root@fedora pnp]# cp /usr/local/nagios/etc/pnp/rra.cfg-sample /usr/local/nagios/etc/pnp/rra.cfg
 ← サンプルよりrra.cfgコピー

[root@fedora ~]# vi /usr/local/nagios/etc/pnp/config.php ← PNP設定ファイル編集
$conf['date_fmt'] = "Y.m.d G:i"; ← 日付形式をYYYY.MM.DDにする

(2)Nagios設定
[root@fedora ~]# vi /usr/local/nagios/etc/nagios.cfg ← nagios.cfg編集
process_performance_data=1 ← パフォーマンスデータ取得を有効化

host_perfdata_command=process-host-perfdata ← ホストパフォーマンスデータ取得コマンドを有効化
service_perfdata_command=process-service-perfdata ← サービスパフォーマンスデータ取得コマンドを有効化

[root@fedora ~]# vi /usr/local/nagios/etc/objects/commands.cfg ← commands.cfg編集
−−削除(ここから)−−
# 'process-host-perfdata' command definition
define command{
       command_name    process-host-perfdata
       command_line    /usr/bin/printf "%b" "$LASTHOSTCHECK$\t$HOSTNAME$\t$HOSTSTATE$\t$HOSTATTEMPT$\t$HOSTSTATETYPE$\t$HOSTEXECUTIONTIME$\t$HOSTOUTPUT$\t$HOSTPERFDATA$\n" >> /usr/local/nagios/var/host-perfdata.out
       }


# 'process-service-perfdata' command definition
define command{
       command_name    process-service-perfdata
       command_line    /usr/bin/printf "%b" "$LASTSERVICECHECK$\t$HOSTNAME$\t$SERVICEDESC$\t$SERVICESTATE$\t$SERVICEATTEMPT$\t$SERVICESTATETYPE$\t$SERVICEEXECUTIONTIME$\t$SERVICELATENCY$\t$SERVICEOUTPUT$\t$SERVICEPERFDATA$\n" >> /usr/local/nagios/var/service-perfdata.out
       }
−−削除(ここまで)−−

以下を最終行へ追加
define command {
  command_name    process-service-perfdata
  command_line    /usr/bin/perl /usr/local/nagios/libexec/process_perfdata.pl
}

define command {
  command_name    process-host-perfdata
  command_line    /usr/bin/perl /usr/local/nagios/libexec/process_perfdata.pl -d HOSTPERFDATA
}

[root@fedora ~]# vi /usr/local/nagios/etc/objects/templates.cfg ← templates.cfg編集
###############################################################################
###############################################################################
#
# HOST TEMPLATES
#
###############################################################################
###############################################################################

# Generic host definition template - This is NOT a real host, just a template!

define host{
        name                            generic-host    ; The name of this host template
        notifications_enabled           1               ; Host notifications are enabled
        event_handler_enabled           1               ; Host event handler is enabled
        flap_detection_enabled          1               ; Flap detection is enabled
        failure_prediction_enabled      1               ; Failure prediction is enabled
        process_perf_data               1               ; Process performance data
        retain_status_information       1               ; Retain status information across program restarts
        retain_nonstatus_information    1               ; Retain non-status information across program restarts
        notification_period             24x7            ; Send host notifications at any time
        register                        0               ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL HOST, JUST A TEMPLATE!
        action_url /nagios/pnp/index.php?host=$HOSTNAME$' onmouseover="get_g('$HOSTNAME$','_HOST_')" onmouseout="clear_g()" ← 追加(Nagios画面からPNP画面へのリンク表示(ホスト))
        }

###############################################################################
## SERVICE TEMPLATES
#
###############################################################################
###############################################################################

# Generic service definition template - This is NOT a real service, just a template!

define service{
        name                            generic-service         ; The 'name' of this service template
        active_checks_enabled           1                       ; Active service checks are enabled
        passive_checks_enabled          1                       ; Passive service checks are enabled/accepted
        parallelize_check               1                       ; Active service checks should be parallelized (disabling this can lead to major performance problems)
        obsess_over_service             1                       ; We should obsess over this service (if necessary)
        check_freshness                 0                       ; Default is to NOT check service 'freshness'
        notifications_enabled           1                       ; Service notifications are enabled
        event_handler_enabled           1                       ; Service event handler is enabled
        flap_detection_enabled          1                       ; Flap detection is enabled
        failure_prediction_enabled      1                       ; Failure prediction is enabled
        process_perf_data               1                       ; Process performance data
        retain_status_information       1                       ; Retain status information across program restarts
        retain_nonstatus_information    1                       ; Retain non-status information across program restarts
        is_volatile                     0                       ; The service is not volatile
        check_period                    24x7                    ; The service can be checked at any time of the day
        max_check_attempts              3                       ; Re-check the service up to 3 times in order to determine its final (hard) state
        normal_check_interval           10                      ; Check the service every 10 minutes under normal conditions
        retry_check_interval            2                       ; Re-check the service every two minutes until a hard state can be determined
        contact_groups                  admins                  ; Notifications get sent out to everyone in the 'admins' group
        notification_options            w,u,c,r                 ; Send notifications about warning, unknown, critical, and recovery events
        notification_interval           60                      ; Re-notify about service problems every hour
        notification_period             24x7                    ; Notifications can be sent out at any time
        register                        0                       ; DONT REGISTER THIS DEFINITION - ITS NOT A REAL SERVICE, JUST A TEMPLATE!
        action_url /nagios/pnp/index.php?host=$HOSTNAME$&srv=$SERVICEDESC$' onmouseover="get_g('$HOSTNAME$','$SERVICEDESC$')" onmouseout="clear_g()" ← 追加(Nagios画面からPNP画面へのリンク表示(サービス))
        }

[root@fedora ~]# /etc/rc.d/init.d/nagios restart ← Nagios再起動
Running configuration check...done.
Stopping nagios: done.
Starting nagios: done.

■PNP確認

http://サーバー名/nagios/へアクセスし、「サービス稼動状態」でホストまたはサービス横のをクリックして性能統計グラフが表示されることを確認。

※一部監視項目はパフォーマンスデータを出力しないため、グラフ表示できない


■関連コンテンツ




▲このページのトップへ戻る

プライバシーポリシー