Nagiosをインストールする

インストール方法のおさらいということで。
#基本的に公式サイトほぼそのままです。


まずは関連パッケージをインストールします。

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


ユーザー/グループを作成します。

# useradd -m nagios
# passwd nagios
# groupadd  nagcmd
# usermod -a -G nagcmd nagios
# usermod -a -G nagcmd apache


Nagiosのソースファイルをダウンロードして、コンパイルします。

# cd /usr/local/src
# wget http://prdownloads.sourceforge.net/sourceforge/nagios/nagios-3.2.3.tar.gz
# cd nagios-3.2.3
#  ./configure --with-command-group=nagcmd
#  make all
#  make install
#  make install-init
#  make install-config
#  make install-commandmode
#  make install-webconf


管理画面に対する認証の設定(ベーシック認証)を行います。
ユーザーは「nagiosadmin」とします。

#  htpasswd -c -m /usr/local/nagios/etc/htpasswd.users nagiosadmin


続いて「nagios-plugins」をインストールします。

cd /usr/local/src/
# wget http://prdownloads.sourceforge.net/sourceforge/nagiosplug/nagios-plugins-1.4.15.tar.gz
#  tar -xvzf nagios-plugins-1.4.15.tar.gz 
#  cd nagios-plugins-1.4.15
#  ./configure --with-nagios-user=nagios --with-nagios-group=nagios
#  make
#  make install


自動起動するように設定します。

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


Nagiosを起動する前にコンフィグのチェックを行います。

# /usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg 

Nagios Core 3.2.3
Copyright (c) 2009-2010 Nagios Core Development Team and Community Contributors
Copyright (c) 1999-2009 Ethan Galstad
Last Modified: 10-03-2010
License: GPL

Website: http://www.nagios.org
Reading configuration data...
   Read main config file okay...
Processing object config file '/usr/local/nagios/etc/objects/commands.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/contacts.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/timeperiods.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/templates.cfg'...
Processing object config file '/usr/local/nagios/etc/objects/localhost.cfg'...
   Read object config files okay...

Running pre-flight check on configuration data...

Checking services...
	Checked 8 services.
Checking hosts...
	Checked 1 hosts.
Checking host groups...
	Checked 1 host groups.
Checking service groups...
	Checked 0 service groups.
Checking contacts...
	Checked 1 contacts.
Checking contact groups...
	Checked 1 contact groups.
Checking service escalations...
	Checked 0 service escalations.
Checking service dependencies...
	Checked 0 service dependencies.
Checking host escalations...
	Checked 0 host escalations.
Checking host dependencies...
	Checked 0 host dependencies.
Checking commands...
	Checked 24 commands.
Checking time periods...
	Checked 5 time periods.
Checking for circular paths between hosts...
Checking for circular host and service dependencies...
Checking global event handlers...
Checking obsessive compulsive processor commands...
Checking misc settings...

Total Warnings: 0
Total Errors:   0

Things look okay - No serious problems were detected during the pre-flight check


ApacheNagiosを起動させます。

# /etc/init.d/nagios start
Starting nagios: done.
# /etc/init.d/httpd start
httpd を起動中: [  OK  ]


http://xxx.xxx.xxx.xxx/nagios」にアクセスして、以下のような画面が表示されればOKです。



初期状態では自分自身が監視されるようになっています。


おまけ


今回当初「make all」したところ、以下のエラーが出ました。

# make all
cd ./base && make
make[1]: Entering directory `/usr/local/src/nagios/base'
make[1]: *** No rule to make target `../include/locations.h', needed by `broker.o'.  Stop.
make[1]: Leaving directory `/usr/local/src/nagios/base'
make: *** [all] Error 2


確かに、「/usr/local/src/nagios/include」に「locations.h」がいない・・・。

# ls -ltr
total 268
-rwxr--r--. 1 nagios nagios    57 Aug 15  2003 snprintf.h.in
-rwxr--r--. 1 nagios nagios  2315 Dec  1  2008 neberrors.h
-rwxr--r--. 1 nagios nagios  2284 Dec  1  2008 locations.h.in
-rwxr--r--. 1 nagios nagios   244 Dec  9  2008 netutils.h
-rwxr--r--. 1 nagios nagios  1056 Jan 16  2009 epn_nagios.h
-rwxr--r--. 1 nagios nagios  6480 Oct 23  2010 config.h.in
-rwxr--r--. 1 nagios nagios   219 Oct 23  2010 Makefile
-rwxr--r--. 1 nagios nagios  6973 Jul 26 09:16 statusdata.h
-rwxr--r--. 1 nagios nagios  1343 Jul 26 09:16 sretention.h
-rwxr--r--. 1 nagios nagios  2535 Jul 26 09:16 skiplist.h
-rwxr--r--. 1 nagios nagios  1311 Jul 26 09:16 shared.h
-rwxr--r--. 1 nagios nagios  1540 Jul 26 09:16 perfdata.h
-rwxr--r--. 1 nagios nagios 28751 Jul 26 09:16 objects.h
-rwxr--r--. 1 nagios nagios 14709 Jul 26 09:16 nebstructs.h
-rwxr--r--. 1 nagios nagios  3082 Jul 26 09:16 nebmodules.h
-rwxr--r--. 1 nagios nagios  1951 Jul 26 09:16 nebmods.h
-rwxr--r--. 1 nagios nagios  3563 Jul 26 09:16 nebcallbacks.h
-rwxr--r--. 1 nagios nagios 41968 Jul 26 09:16 nagios.h
-rwxr--r--. 1 nagios nagios 13190 Jul 26 09:16 macros.h
-rwxr--r--. 1 nagios nagios  3092 Jul 26 09:16 logging.h
-rwxr--r--. 1 nagios nagios   455 Jul 26 09:16 getcgi.h
-rwxr--r--. 1 nagios nagios  4107 Jul 26 09:16 downtime.h
-rwxr--r--. 1 nagios nagios  5633 Jul 26 09:16 comments.h
-rwxr--r--. 1 nagios nagios 17188 Jul 26 09:16 cgiutils.h
-rwxr--r--. 1 nagios nagios 10861 Jul 26 09:16 broker.h
-rwxr--r--. 1 nagios nagios  2440 Jul 26 10:26 cgiauth.h
-rwxr--r--. 1 nagios nagios 18805 Jul 26 12:16 common.h
-rw-r--r--. 1 root   root    6844 Nov 19 22:37 config.h
-rw-r--r--. 1 root   root     121 Nov 19 22:37 snprintf.h


色々調べた結果、原因はperlが入っていなかった事でした。
# yum install perl してから、再度作業して問題なく完了。


今日はこんなところで。