Webで見かけて面白そうだったので試しにLS-GLで動かしてみました。尚、作業にあたっては、ここのサイトを参考にさせて頂きました(貴重な情報ありがたいです)。
どこでも構いません、当方は/usr/local/src(/mnt/disk1/srcへのリンク)下で行いました。
GDライブラリやzlib、libpng、libjpeg等が必要みたいですが、既にVineのSRPMから頂いて導入してあるのでOK。opensslも元から入っているのでOK(BuffaloのソースCDからヘッダ等抜き出す必要はあり)。
nagios用のユーザとグループを作成しておきます。ユーザapacheにもグループを追加しておく。
$ useradd -m nagios
$ passwd nagios
$ groupadd nagcmd
$ usermod -G nagcmd nagios
$ usermod -G nagcmd apache
$
$ mkdir -p /usr/local/develop/nagios ←インストール先のdirを作成
$ chown nagios:nagios /usr/local/develop/nagios/ ←dirの所有者を変更
ここからNagiosのソース、ここから日本語化パッチ、ここからplug-inのソースを頂いてきます。
$ cd /usr/local/src
$ tar xvzf nagios-3.0.3.tar.gz ← nagiosソース展開
$ cd nagios-3.0.3
$ gzip -dc nagios-3.0.3-ja-utf8.patch.gz| patch -p0 ←日本語化パッチを当てる
$
$ cd /usr/local/src
$ tar xvzf nagios-3.0.3.tar.gz ← nagiosソース展開
$ cd nagios-3.0.3
$ gzip -dc nagios-3.0.3-ja-utf8.patch.gz| patch -p0 ←日本語化パッチを当てる
$ ./configure \ ←環境に合わせてconfigする
$ --prefix=/usr/local/develop/nagios \
$ --with-httpd-conf=/usr/local/develop/etc/apache2/conf.d \
$ --with-init-dir=/usr/local/develop/etc/init.d \
$ --with-command-group=nagcmd
:
:(中略)
:
*** Configuration summary for nagios 3.0.3 06-25-2008 ***:
General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagcmd
Embedded Perl: no
Event Broker: yes
Install ${prefix}: /usr/local/develop/nagios
Lock file: ${prefix}/var/nagios.lock
Check result directory: ${prefix}/var/spool/checkresults
Init directory: /usr/local/develop/etc/init.d
Apache conf.d directory: /usr/local/develop/etc/apache2/conf.d
Mail program: /bin/mail
Host OS: linux-gnu
Web Interface Options:
------------------------
HTML URL: http://localhost/nagios/
CGI URL: http://localhost/nagios/cgi-bin/
Traceroute (used by WAP):
Review the options above for accuracy. If they look okay,
type 'make all' to compile the main program and CGIs.
$ make all ←ビルド開始
:
:(中略)
:
*** Compile finished ***
If the main program and CGIs compiled without any errors, you
can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):
make install
- This installs the main program, CGIs, and HTML files
make install-init
- This installs the init script in /usr/local/develop/etc/init.d
make install-commandmode
- This installs and configures permissions on the
directory for holding the external command file
make install-config
- This installs *SAMPLE* config files in /usr/local/develop/nagios/etc
You'll have to modify these sample files before you can
use Nagios. Read the HTML documentation for more info
on doing this. Pay particular attention to the docs on
object configuration files, as they determine what/how
things get monitored!
make install-webconf
- This installs the Apache config file for the Nagios
web interface
*** Support Notes *******************************************
If you have questions about configuring or running Nagios,
please make sure that you:
- Look at the sample config files
- Read the HTML documentation
- Read the FAQs online at http://www.nagios.org/faqs
before you post a question to one of the mailing lists.
Also make sure to include pertinent information that could
help others help you. This might include:
- What version of Nagios you are using
- What version of the plugins you are using
- Relevant snippets from your config files
- Relevant error messages from the Nagios log file
For more information on obtaining support for Nagios, visit:
http://www.nagios.org/support/
*************************************************************
Enjoy.
$ make install ←順次インストール
$ make install-init
$ make install-commandmode
$ make install-config
$ make install-webconf
$ cd /usr/local/src
$ tar xvzf nagios-plugins-1.4.12.tar.gz ← plug-inソース展開
$ cd nagios-plugins-1.4.12
$ ./configure \ ←環境に合わせてconfigする
$ --prefix=/usr/local/develop/nagios \
$ --with-httpd-conf=/usr/local/develop/etc/apache2/conf.d \
$ --with-nagios-user=nagios \
$ --with-nagios-group=nagios \
$ --without-ping-command ← iptablesに引っ掛かってるのかICMPチェックで止まってしまうので追加
:
:(中略)
:
config.status: creating po/Makefile
--with-apt-get-command:
--with-ping6-command:
--with-ping-command: no
--with-ipv6: yes
--with-mysql: /usr/local/develop/bin/mysql_config
--with-openssl: yes
--with-gnutls: no
--enable-extra-opts: no
--with-perl: /usr/bin/perl
--enable-perl-modules: no
--with-cgiurl: /nagios/cgi-bin
--with-trusted-path: /bin:/sbin:/usr/bin:/usr/sbin
$ make ←ビルド開始
$ make install ←インストール
ビルドとインストールまで済んだら設定を行います。まずは標準でインストールされたcfgのチェック:
$ cd /usr/local/develop/nagios/etc
$ ../bin/nagios -v ./nagios.cfg
Nagios 3.0.3
Copyright (c) 1999-2008 Ethan Galstad (http://www.nagios.org)
Last Modified: 06-25-2008
License: GPL
Reading configuration data...
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
問題はなさそうですね。
認証用のIDとパスワードを設定します。尚、当方の環境では、LS-GLには標準のApache 1.3系を止めて、Vineから拝借したApache2を入れて動かしているます。
$ htpasswd2 -c /usr/local/develop/nagios/etc/htpasswd.users nagiosadmin
New password:
Re-type new password:
Adding password for user nagiosadmin
/usr/local/develop/etc/apache2/conf.d/nagios.confの設定も行いアクセス制限します:
ScriptAlias /nagios/cgi-bin "/usr/local/develop/nagios/sbin"
<Directory "/usr/local/develop/nagios/sbin">
SSLRequireSSL
Options ExecCGI
AllowOverride None
Order deny,allow
Deny from all
Allow from 192.168.XX ← LAN内からのアクセスのみを許可する
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/develop/nagios/etc/htpasswd.users
Require valid-user
</Directory>
Alias /nagios "/usr/local/develop/nagios/share"
<Directory "/usr/local/develop/nagios/share">
SSLRequireSSL
Options None
AllowOverride None
Order deny,allow
Deny from all
Allow from 192.168.XX ← LAN内からのアクセスのみを許可する
AuthName "Nagios Access"
AuthType Basic
AuthUserFile /usr/local/develop/nagios/etc/htpasswd.users
Require valid-user
</Directory>
これで、まずは一通りの設定ができました。
実際動くか適当に試してみます、まずはnagiosを開始し、apacheを再起動します:
$ /usr/local/develop/etc/init.d/nagios start
$ /usr/local/develop/etc/init.d/apache2 restart
ブラウザからnagios(https://192.168.XX.YY/nagios/)にアクセスしてみます(SSLを無効にした設定ならhttp://192.168.XX.YY/nagios/)。
うまく動作していれば、ログインダイアログが表示されユーザ"nagiosadmin"でパスワードを入力すると初期画面が表示されます。
何となくやってみたかっただけで・・・、普段は止めてますけどねw