Powered by
Movable Type 4.1

« Xの設定 | メインですよ(エントリーアーカイブ) | MIB データベース »

Nagios2インストール(RPM)

■環境
OSはCentOS4.3
apacheがすでにインストールされている。


■インストール前に用意するもの
http://dag.wieers.com/packages/
から、下記のファイルをダウンロードしてくる。

nagios-2.5-1.el4.rf.i386.rpm
nagios-plugins-1.4.1-1.2.el4.rf.i386.rpm
fping-2.4-1.b2.2.el4.rf.i386.rpm
perl-Crypt-DES-2.05-3.2.el4.rf.i386.rpm
perl-Net-SNMP-5.2.0-1.2.el4.rf.noarch.rpm
perl-Socket6-0.19-1.2.el4.rf.i386.rpm


■インストールする順番

# rpm -ivh nagios-2.5-1.el4.rf.i386.rpm
警告: nagios-2.5-1.el4.rf.i386.rpm: V3 DSA signature: NOKEY, key ID 6b8d79e6
Preparing... ########################################### [100%]
1:nagios ########################################### [100%]

# rpm -ivh fping-2.4-1.b2.2.el4.rf.i386.rpm
警告: fping-2.4-1.b2.2.el4.rf.i386.rpm: V3 DSA signature: NOKEY, key ID 6b8d79e6
Preparing... ########################################### [100%]
1:fping ########################################### [100%]

# rpm -ivh perl-Crypt-DES-2.05-3.2.el4.rf.i386.rpm
警告: perl-Crypt-DES-2.05-3.2.el4.rf.i386.rpm: V3 DSA signature: NOKEY, key ID 6b8d79e6
Preparing... ########################################### [100%]
1:perl-Crypt-DES ########################################### [100%]

# rpm -ivh perl-Socket6-0.19-1.2.el4.rf.i386.rpm
警告: perl-Socket6-0.19-1.2.el4.rf.i386.rpm: V3 DSA signature: NOKEY, key ID 6b8d79e6
Preparing... ########################################### [100%]
1:perl-Socket6 ########################################### [100%]

# rpm -ivh perl-Net-SNMP-5.2.0-1.2.el4.rf.noarch.rpm
警告: perl-Net-SNMP-5.2.0-1.2.el4.rf.noarch.rpm: V3 DSA signature: NOKEY, key ID 6b8d79e6
Preparing... ########################################### [100%]
1:perl-Net-SNMP ########################################### [100%]

# rpm -ivh nagios-plugins-1.4.1-1.2.el4.rf.i386.rpm
警告: nagios-plugins-1.4.1-1.2.el4.rf.i386.rpm: V3 DSA signature: NOKEY, key ID 6b8d79e6
Preparing... ########################################### [100%]
1:nagios-plugins ########################################### [100%]


■とりあえず、動かしてみるには。

/etc/nagiosに移動する
# cd /etc/nagios
# ls
bigger.cfg         command-plugins.cfg  nagios.cfg
cgi.cfg            minimal.cfg          nagios.cfg.rpmsave
checkcommands.cfg  misccommands.cfg     resource.cfg

nagiosの設定ファイルを確認してみる
# nagios -v nagios.cfg
Reading configuration data...
Error: Command 'check-host-alive' has already been defined
Error: Could not register command (config file '/etc/nagios/minimal.cfg', starting on line 76)

***> One or more problems was encountered while processing the config files...

これは 'check-host-alive' が、minimal.cfgとcheckcommands.cfgで、2重定義になってしまっているからである。

なので、nagios.cfgにちょっと手を加える。
/etc/nagios/nagios.cfg 37行目

cfg_file=/etc/nagios/checkcommands.cfg

をコメントアウトする
#cfg_file=/etc/nagios/checkcommands.cfg

host-notify-by-emailもminimal.cfgとmisccommands.cfgで2重定義になっているので、
これもnagios.cfgの40行目でコメントアウトしておく。

#cfg_file=/etc/nagios/misccommands.cfg

最終的にこのようにファイルチェックの結果が表示されればOKである。

# nagios -v nagios.cfg

Nagios 2.5
Copyright (c) 1999-2006 Ethan Galstad (http://www.nagios.org)
Last Modified: 07-13-2006
License: GPL

Reading configuration data...

Running pre-flight check on configuration data...

Checking services...
Checked 5 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 8 commands.
Checking time periods...
Checked 1 time periods.
Checking extended host info definitions...
Checked 0 extended host info definitions.
Checking extended service info definitions...
Checked 0 extended service info definitions.
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

■Apacheの認証の設定

RPMでインストールすると、
/etc/httpd/conf.d/nagios.conf
というファイルが一緒にインストールされているので、
これにしたがってApacheのBASIC認証の設定をすればよい。

cgi.cfgをず~っとみていけばわかるが、
nagiosadmin, theboss, jdoe, guest などの名前が登場する。
これらのauthorized_forではじまる行をかたっぱしからコメントアウトする。

authorized_for_system_information=nagiosadmin,theboss,jdoe
authorized_for_configuration_information=nagiosadmin,jdoe
authorized_for_system_commands=nagiosadmin
authorized_for_all_services=nagiosadmin,guest
authorized_for_all_hosts=nagiosadmin,guest
authorized_for_all_service_commands=nagiosadmin
authorized_for_all_host_commands=nagiosadmin

nagiosadminという特権ユーザーと、閲覧のみのguestという
2つのユーザーをつくっておけばよいだろう。
これらのユーザーの認証ファイルを/etc/nagios/htpasswd.usersとして作成する。

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


■httpdを再起動し、nagiosも起動する。

# /etc/init.d/httpd restart
httpd を停止中: [ OK ]
httpd を起動中: [ OK ]
# /etc/init.d/nagios start
Starting network monitor: nagios
#

あとは、http://IPアドレス/nagios/ にアクセスし、
nagiosadminかguestでログインすれば、
nagiosをインストールしたマシンを監視し始めているのを確認することができる。


コメント

大変わかりやすく参考になりました!
これからも寄らせていただこうと思っています。ありがとうございました!!

tarballからのインストール方法は見つかるのですがrpmパッケージからのインストール方法に詳しくかつ分かりやすく載ってたので非常に助かりました。
参考にさせていただきます。
ありがとうございました。

rpmからのインストールで大変参考になりました。ありがとうございます。

コメントを投稿

(いままで、ここでコメントしたことがないときは、コメントを表示する前にこのブログのオーナーの承認が必要になることがあります。承認されるまではコメントは表示されません。そのときはしばらく待ってください。)