■環境
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.cfgnagiosの設定ファイルを確認してみる # 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.cfghost-notify-by-emailもminimal.cfgとmisccommands.cfgで2重定義になっているので、 これもnagios.cfgの40行目でコメントアウトしておく。
#cfg_file=/etc/nagios/misccommands.cfg
最終的にこのようにファイルチェックの結果が表示されればOKである。
# nagios -v nagios.cfgNagios 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認証の設定をすればよい。
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=nagiosadminnagiosadminという特権ユーザーと、閲覧のみの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をインストールしたマシンを監視し始めているのを確認することができる。
