Fedora」タグアーカイブ

玄箱/Fedora9へのNagiosのインストール

Fedora9を入れている玄箱へのNagiosのインストール方法

パッケージのインストール

# yum -y install nagios nagios-plugins-all
Nagiso本体とプラグインのすべてがインストールされる。Nagiosは、このプラグインが無いと各サービスへの監視はできない。

次のパッケージがインストールされる
nagios-plugins-1.4.13-9.fc9.ppc
nagios-plugins-mysql-1.4.13-9.fc9.ppc
nagios-plugins-snmp-1.4.13-9.fc9.ppc
nagios-plugins-procs-1.4.13-9.fc9.ppc
nagios-plugins-cluster-1.4.13-9.fc9.ppc
nagios-plugins-by_ssh-1.4.13-9.fc9.ppc
nagios-plugins-ping-1.4.13-9.fc9.ppc
nagios-plugins-swap-1.4.13-9.fc9.ppc
nagios-plugins-mrtg-1.4.13-9.fc9.ppc
nagios-plugins-load-1.4.13-9.fc9.ppc
nagios-plugins-ldap-1.4.13-9.fc9.ppc
nagios-plugins-tcp-1.4.13-9.fc9.ppc
nagios-plugins-real-1.4.13-9.fc9.ppc
nagios-plugins-nagios-1.4.13-9.fc9.ppc
nagios-plugins-ups-1.4.13-9.fc9.ppc
nagios-plugins-overcr-1.4.13-9.fc9.ppc
nagios-plugins-dig-1.4.13-9.fc9.ppc
nagios-plugins-fping-1.4.13-9.fc9.ppc
nagios-plugins-game-1.4.13-9.fc9.ppc
nagios-plugins-perl-1.4.13-9.fc9.ppc
nagios-plugins-wave-1.4.13-9.fc9.ppc
nagios-plugins-ircd-1.4.13-9.fc9.ppc
nagios-plugins-breeze-1.4.13-9.fc9.ppc
nagios-plugins-log-1.4.13-9.fc9.ppc
nagios-2.11-3.fc9.ppc
nagios-plugins-all-1.4.13-9.fc9.ppc
nagios-plugins-pgsql-1.4.13-9.fc9.ppc
nagios-plugins-nt-1.4.13-9.fc9.ppc
nagios-plugins-disk-1.4.13-9.fc9.ppc
nagios-plugins-ssh-1.4.13-9.fc9.ppc
nagios-plugins-hpjd-1.4.13-9.fc9.ppc
nagios-plugins-dhcp-1.4.13-9.fc9.ppc
nagios-plugins-http-1.4.13-9.fc9.ppc
nagios-plugins-ntp-1.4.13-9.fc9.ppc
nagios-plugins-mrtgtraf-1.4.13-9.fc9.ppc
nagios-plugins-ide_smart-1.4.13-9.fc9.ppc
nagios-plugins-icmp-1.4.13-9.fc9.ppc
nagios-plugins-nwstat-1.4.13-9.fc9.ppc
nagios-plugins-time-1.4.13-9.fc9.ppc
nagios-plugins-dummy-1.4.13-9.fc9.ppc
nagios-plugins-users-1.4.13-9.fc9.ppc
nagios-plugins-smtp-1.4.13-9.fc9.ppc
nagios-plugins-dns-1.4.13-9.fc9.ppc
nagios-plugins-flexlm-1.4.13-9.fc9.ppc
nagios-plugins-file_age-1.4.13-9.fc9.ppc
nagios-plugins-mailq-1.4.13-9.fc9.ppc
nagios-plugins-udp-1.4.13-9.fc9.ppc
nagios-plugins-oracle-1.4.13-9.fc9.ppc
nagios-plugins-rpc-1.4.13-9.fc9.ppc
nagios-plugins-disk_smb-1.4.13-9.fc9.ppc

Nagios自体は、nagios-2.11-3.fc9.ppcとなる。3.xがリリースされているが、2.xでも事足りそうなので、このまま使うことに。

Nagiosの設定ファイルの編集

# vi /etc/nagios/nagios.cfg
以下の項目の数値を変更
check_external_commands=1 // Nagiosのコマンド実行のためのコマンドファイル確認を行う
date_format=iso8601 // 日付・時刻の表示フォーマットを変更

date_formatは、お好みで

NagiosのWEBインタフェース設定ファイルの編集

# vi /etc/nagios/cgi.cfg
以下の項目をhtpasswdで設定したユーザ名に変更
authorized_for_system_information=nagios
authorized_for_configuration_information=nagios
authorized_for_system_commands=nagios
authorized_for_all_services=nagios
authorized_for_all_hosts=nagios
authorized_for_all_service_commands=nagios
authorized_for_all_host_commands=nagios

Nagiosの監視設定のメイン的なファイルを編集する

# vi /etc/nagios/localhost.cfg

通知先アドレスの設定
エラーが等があった際の通知を送るメールアドレスを設定する
define_contactの項のemailを変更
email admin@foo.com

Apacheの設定

Nagiosは、WEBインタフェースを利用する。その画面の認証を設定する。
htpasswd -c /etc/nagios/passwd nagios
ユーザ名は、設定ファイルで変更できるので、任意で付けても構わない。

/etc/httpd/conf.d/nagios.conf を編集
ScriptAlias /nagios/cgi-bin/ /usr/lib/nagios/cgi-bin/

Options ExecCGI
order deny,allow
#deny from all
#allow from 127.0.0.1
AuthType Basic
AuthUserFile /etc/nagios/passwd
AuthName "nagios"
require valid-user

Alias /nagios/ /usr/share/nagios/html/

Options None
order deny,allow
#deny from all
#allow from 127.0.0.1
AuthType Basic
AuthUserFile /etc/nagios/passwd
AuthName "nagios"
require valid-user

ローカルホスト以外からもWEB閲覧が出来る様に、deny, allowの行をコメントアウト

自動起動設定

# /sbin/chkconfig --add nagios
# /sbin/chkconfig nagios on

Nagiosを起動

# /etc/rc.d/init.d/nagios start

この設定で、localhostの監視がデフォルト設定で始まる。監視画面は、http://localhost/nagios/