lost and found ( for me ? )

How to install Nagios n' monitor remote hosts

参考URL

http://nagios.sourceforge.net/docs/3_0/quickstart-fedora.html

# cat /etc/redhat-release
CentOS release 5.4 (Final)

# uname -r
2.6.18-164.6.1.el5

# yum install -y httpd php gcc glibc glibc-common gd gd-devel

[ Nagios 用のアカウントを作成 ]

# useradd nagios
# passwd nagios

# usermod -a -G nagcmd nagios
# usermod -a -G nagcmd apache

# egrep nagcmd /etc/group
nagcmd:x:1001:nagios,apache

[ Nagios , plug-in をダウンロード ]

# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.1.2.tar.gz
# wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.14.tar.gz

[ インストール ]

# tar xzvf nagios-3.1.2.tar.gz
# cd nagios-3.1.2
# ./configure --with-command-group=nagcmd
# make all
1031 make install
1032 make install-init
1033 make install-config
1034 make install-commandmode

[ コンフィグの修正 ]

# pwd
/usr/local/nagios/etc/objects

下記メールアドレスにアラートが飛ぶ。適宜変更。

# egrep mail contacts.cfg
email nagios@localhost ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ******


[ web interface コンフィグのインストール ]

apache の conf.d 下に nagios.conf をインストール

# make install-webconf
/usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf

ログインアカウントの作成

# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin
New password:nagiosadmin
Re-type new password:nagiosadmin
Adding password for user nagiosadmin
#

-c Create the passwdfile. If passwdfile already exists, it is rewrit-
ten and truncated. This option cannot be combined with the -n
option.

httpd プロセスを起動

# service httpd start

[ plug-in のインストール ]

# tar xzvf nagios-plugins-1.4.14.tar.gz
# cd nagios-plugins-1.4.14
# ./configure --with-nagios-user=nagios --with-nagios-group=nagios
# make; make install

[ Nagios の起動 ]

# chkconfig --add nagios
# chkconfig nagios on

# chkconfig --list | grep nagios
nagios 0:off 1:off 2:on 3:on 4:on 5:on 6:off

コンフィグのチェック。

# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Total Warnings: 0
Total Errors: 0
Things look okay - No serious problems were detected during the pre-flight check

# /etc/init.d/nagios start
Starting nagios: done.

[ SElinux の設定 ]

切り分けが面倒なので、無効。

# egrep -i disable /etc/selinux/config
# disabled - SELinux is fully disabled.
SELINUX=disabled

[ ブラウザからログイン ]

http://127.1/nagios

ユーザ名、パスワードを聞かれるので、先の htpasswd で作成したユーザ,パスワードでログイン。



[ リモートホスト ( Linux ) の監視 ]

参考URL

http://nagios.sourceforge.net/docs/3_0/monitoring-publicservices.html

- 監視ホストの定義

リモートホストの定義ファイル名を /usr/local/nagios/etc/nagios.cfg ファイルに記述

nagios.cfg

# Definitions for monitoring the remote (Linux) host
cfg_file=/usr/local/nagios/etc/objects/remote_linux.cfg

# touch nagios.nagios remote_linux.cfg
# chown nagios.nagios remote_linux.cfg

# cat remote_linux.cfg
define host{
use linux-server ; Name of host template to use
host_name remotehost
alias Some remote host ; a longer name associated with the host
address 192.168.100.2
hostgroups linux-servers ; The name of the hostgroup
}

define service{
use generic-service ; Inherit default values from a template
host_name remotehost
service_description HTTP
check_command check_http
}
#

コンフィグのチェック

# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg
Total Warnings: 0
Total Errors: 0

nagiosをリロード

# /etc/init.d/nagios reload
Running configuration check...done.
Reloading nagios configuration...done

追加した remotehost が表示された。


No comments:

Post a Comment

Note: Only a member of this blog may post a comment.