アットウィキロゴ
室井の部屋
掲示板 掲示板 ページ検索 ページ検索 メニュー メニュー

室井の部屋

Nagios

最終更新:

momijimanjyu

- view
管理者のみ編集可

Nagios監視サーバ構築


環境

Nagiosを使ってserver2台をサービス単位で監視する。
Server1から監視する形にする。

Server1
OS CentOS カーネル2.6
IPadd 10.1.2.102/24
監視対象サービス HTTP,PING

Server2
OS WindowsXP
IPadd 172.19.11.90
監視対象サービス PING

Nagios-status
Souce nagios-2.9
nagios-plugins-1.4.8
日本語化patch nagios-2.9-ja.patch.gz

手順


1.sorceとpatchのdownload
下記の3つをサイトからdownloadして適当なディレクトリに置く。

nagios-2.9.tar.gz
nagios-plugins-1.4.8.tar.gz
nagios-2.9-ja.patch.gz

2.展開&Patch適用&コンパイル
Nagios
tar zxvf nagios-2.9.tar.gz
cd nagios-2.9
gzip -dc nagios-2.9-ja.patch.gz | patch -p0
./configure
mkdir /usr/local/nagios
make all
make install
make install-init
make install-config

Plugin
tar zxvf nagios-plugins-1.4.8.tar.gz
cd nagios-plugins-1.4.8
./configure
make all
make install


3.Webサーバの設定
/etc/httpd/conf/httpd.confに下記の文を追記する。

ScriptAlias /nagios/cgi-bin /usr/local/nagios/sbin

<Directory "/usr/local/nagios/sbin">
   Options ExecCGI
   AllowOverride None
   Order allow,deny
   Allow from all
   AuthName "Nagios Access"
   AuthType Basic
   AuthUserFile /usr/local/nagios/etc/htpasswd.users
   Require valid-user
</Directory>

Alias /nagios /usr/local/nagios/share

<Directory "/usr/local/nagios/share">
   Options None
   AllowOverride None
   Order allow,deny
   Allow from all
   AuthName "Nagios Access"
   AuthType Basic
   AuthUserFile /usr/local/nagios/etc/htpasswd.users
   Require valid-user
</Directory>


4.passの設定
/usr/local/nagios/share と /usr/local/nagios/sbinに./htaccessファイルを作成し下記の内容を記入する

AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/nagios/etc/htpasswd.users
require valid-user

次にユーザを設定する
htpasswd -c /usr/local/nagios/etc/htpasswd.users adm

5.監視内容の設定
/usr/local/nagios/etc/localhost.confの設定をする
※注意※自分はlocalhost.confになっているが、基本的にはhosts.cfg,hostgroups.cfg,contacts.cfg,contactgroups.cfgとなっている。
nafgios.cfgで設定し分けることも統合することも出来る。

監視内容の設定は下記localhost.confを参考にして自分なりに設定してください。


6.確認
IEでhttp://10.1.2.102/nagios/ に接続してNagiosの画面が表示されHost情報などが正しく表示されているかを確認する。

7.終了

3Dステータスマップを表示されない場合はこちらのサイトからクライアントにプラグインをインストールする。
http://www.parallelgraphics.com/products/cortona/download/netscape/


設定Config(localhost.conf)


###############################################################################
# LOCALHOST.CFG - SAMPLE OBJECT CONFIG FILE FOR MONITORING THIS MACHINE
#
# Last Modified: 11-27-2006
#
# NOTE: This config file is intended to servce as an *extremely* simple
# example of how you can create your object configuration file(s).
#
###############################################################################



###############################################################################
###############################################################################
#
# TIME PERIODS
#
###############################################################################
###############################################################################

# This defines a timeperiod where all times are valid for checks,
# notifications, etc. The classic "24x7" support nightmare. :-)

define timeperiod{
       timeperiod_name 24x7
       alias           24 Hours A Day, 7 Days A Week
       sunday          00:00-24:00
       monday          00:00-24:00
       tuesday         00:00-24:00
       wednesday       00:00-24:00
       thursday        00:00-24:00
       friday          00:00-24:00
       saturday        00:00-24:00
       }


# 'workhours' timeperiod definition
define timeperiod{
       timeperiod_name workhours
       alias           "Normal" Working Hours
       monday          09:00-17:00
       tuesday         09:00-17:00
       wednesday       09:00-17:00
       thursday        09:00-17:00
       friday          09:00-17:00
       }


# 'nonworkhours' timeperiod definition
define timeperiod{
       timeperiod_name nonworkhours
       alias           Non-Work Hours
       sunday          00:00-24:00
       monday          00:00-09:00,17:00-24:00
       tuesday         00:00-09:00,17:00-24:00
       wednesday       00:00-09:00,17:00-24:00
       thursday        00:00-09:00,17:00-24:00
       friday          00:00-09:00,17:00-24:00
       saturday        00:00-24:00
       }


# 'none' timeperiod definition
define timeperiod{
       timeperiod_name none
       alias           No Time Is A Good Time
       }



###############################################################################
###############################################################################
#
# COMMANDS
#
###############################################################################
###############################################################################

# NOTE: Sample command definitions can now be found in the sample commands.cfg
# file




###############################################################################
###############################################################################
#
# CONTACTS
#
###############################################################################
###############################################################################

# In this simple config file, a single contact will receive all alerts.
# This assumes that you have an account (or email alias) called
# "nagios-admin" on the local host.

define contact {
       contact_name                    adm                                             ; 名前
       alias                           adm                                             ; 別名
       service_notification_period     24x7                                            ; 通知する時間帯の指定
       host_notification_period        24x7                                            ; 通知する時間帯の指定
       service_notification_options    w,u,c,r                                         ; どの状態の時通知するか
       host_notification_options       d,u,r                                           ; どの状態の時通知するか
       service_notification_commands   notify-by-email, notify-by-epager               ; 通知メッセージの内容
       host_notification_commands      host-notify-by-email, host-notify-by-epager     ; 通知メッセージの内容
       email                           [email protected]         ; 自分のE-mailアドレスに変更してください。
}


###############################################################################
###############################################################################
#
# CONTACT GROUPS
#
###############################################################################
###############################################################################

# We only have one contact in this simple configuration file, so there is
# no need to create more than one contact group.

define contactgroup {
       contactgroup_name       admins          ; グループ名
       alias                   admins          ; 別名
       members                 adm             ; このグループに属するメンバー
}



###############################################################################
###############################################################################
#
# HOSTS
#
###############################################################################
###############################################################################

define host {
       name                            generic-host            ; このテンプレートの名前

       notifications_enabled           1
       event_handler_enabled           1
       flap_detection_enabled          1
       process_perf_data               1
       retain_status_information       1
       retain_nonstatus_information    1

       check_command                   check-host-alive
       max_check_attempts              10                      ; 通知するまでに何回チェックするか
       notification_interval           120                     ; 通知する間隔(4分)
       notification_period             24x7                    ; 通知する時間帯の指定
       notification_options            d,u,r                   ; どの状態の時通知するか
       contact_groups                  admins
       register                        0
}

define host {
       use                             generic-host            ; 使用するテンプレートの名前

       host_name                       localhost               ; ホスト名
       alias                           localhost               ; 別名
       address                         127.0.0.1               ; ホストのアドレス(IPでもいい)
}

#muroiPC
define host {
       use                             generic-host            ; 使用するテンプレートの名前

       host_name                       muroiPC               ; ホスト名
       alias                           muroiPC               ; 別名
       address                         172.19.11.90               ; ホストのアドレス(IPでもいい)
}
###############################################################################
###############################################################################
#
# HOST GROUPS
#
###############################################################################
###############################################################################

# We only have one host in our simple config file, so there is no need to
# create more than one hostgroup.

define hostgroup {
       hostgroup_name          servers         ; このグループの名前
       alias                   servers         ; 別名
       members                 localhost,muroiPC       ; このグループに属するホスト
}


###############################################################################
###############################################################################
#
# SERVICES
#
###############################################################################
###############################################################################


define service {
       name                            generic-service         ; このテンプレートの名前

       active_checks_enabled           1
       passive_checks_enabled          1
       parallelize_check               1
       obsess_over_service             1
       check_freshness                 0
       notifications_enabled           1
       event_handler_enabled           1
       flap_detection_enabled          1
       process_perf_data               1
       retain_status_information       1
       retain_nonstatus_information    1

       is_volatile                     0
       check_period                    24x7                    ; チェックする時間帯の指定
       max_check_attempts              3                       ; 通知するまでに何回チェックするか
       normal_check_interval           3                       ; 通常のチェック間隔
       retry_check_interval            1                       ; 異常を検知したときのチェック間隔
       notification_interval           120                     ; 通知する間隔
       notification_period             24x7                    ; 通知する時間帯の指定
       notification_options            w,u,c,r                 ; どの状態の時通知するか

       register                        0
}

# HTTP サービスが動いていない場合、この define service { ~ } は必要ありません。
define service {
       use                             generic-service         ; 使用するテンプレートの名前

       host_name                       localhost               ; 対象ホストの名前
       service_description             HTTP                    ; サービスの名前
       contact_groups                  admins                  ; 通知する contactgroups.cfg 内のグループ
       check_command                   check_http              ; チェックするコマンド
}


# muroiPC用のHTTP監視サービス
define service {
       use                             generic-service         ; 使用するテンプレートの名前

       host_name                       muroiPC               ; 対象ホストの名前
       service_description             HTTP                    ; サービスの名前
       contact_groups                  admins                  ; 通知する contactgroups.cfg 内のグループ
       check_command                   check_http              ; チェックするコマンド
}
# FTP サービスが動いていない場合、この define service { ~ } は必要ありません。
#define
service {
# use generic-service
#
# host_name localhost
# service_description FTP
# contact_groups admins
# check_command check_ftp
#}

# POP サービスが動いていない場合、この define service { ~ } は必要ありません。
#define
service {
# use generic-service
#
# host_name localhost
# service_description POP
# contact_groups admins
# check_command check_pop
#}

# SMTP サービスが動いていない場合、この define service { ~ } は必要ありません。
#define
service {
# use generic-service
#
# host_name localhost
# service_description SMTP
# contact_groups admins
# check_command check_smtp
#}

# ローカルホストの/パーティションのディスク領域を監視します。空き領域が 30% 以下になるとWARNING、10% 以下になるとCRITICAL
#define
service {
# use generic-service
#
# host_name localhost
# service_description DISK
# contact_groups admins
# check_command check_local_disk!30%!10%!/
#}

define service{
       use                             generic-service
       host_name                       muroiPC
       service_description             PING
       is_volatile                     0
       check_period                    24x7
       max_check_attempts              3
       normal_check_interval           5
       retry_check_interval            1
       notification_interval           240
       notification_period             24x7
       notification_options            c,r
       check_command                   check_ping!500,10%!1000,25%
       contact_groups                  admins
       }

define service{
       use                             generic-service
       host_name                       localhost
       service_description             PING
       is_volatile                     0
       check_period                    24x7
       max_check_attempts              3
       normal_check_interval           5
       retry_check_interval            1
       notification_interval           240
       notification_period             24x7
       notification_options            c,r
       check_command                   check_ping!500,10%!1000,25%
       contact_groups                  admins
       }





名前:
コメント:

すべてのコメントを見る




記事メニュー
最近更新されたスレッド
ウィキ募集バナー