Contents
オープンソースの統合監視ソフトウェア「Nagios Server」インストール
Nagiosは、Linux 上で実行するオープンソースの監視ソリューションです。
Nagiosは、 Ethan Galstadによって開発され、 1999 年に最初にリリースされました。その後、このプロジェクトは、いくつかの貢献者によってオープンソース プロジェクトとして改良されました。
Nagiosは、ネットワーク、アプリケーション、またはサーバーの重要なパラメーターを定期的にチェックするように設計されています。これらのパラメータには、マイクロプロセッサの負荷、実行中のプロセス数、ログ ファイル、ディスクおよびメモリの使用量の他、SMTP (Simple Mail Transfer Protocol)、HTTP (Hypertext Transfer Protocol)、POP3 ( Post Office Protocol 3)の他の多くのサービスもチェックできます。
Nagoisを実行するにはPHP、MySQLなどのデータベース、ApacheやNginxなどのWebサーバーが必要です。今回はこれらすべてが構成済みという前提で進めます。
1. 必要なパッケージをインストール
|
1 2 |
# dnf install -y gcc glibc glibc-common # dnf install -y gd gd-devel |
2. Nagios Coreのインストール
①Nagiosユーザーを作成し、パスワードを設定する。
|
1 2 |
# /usr/sbin/useradd -m nagios # passwd nagios |
➁Webインターフェース経由で外部コマンドを送信できるようにするため、新しいnagcmdグループを作成します。nagiosユーザーとapacheユーザーの両方をそのグループに追加します。
|
1 2 3 |
# /usr/sbin/groupadd nagcmd # /usr/sbin/usermod -a -G nagcmd nagios # /usr/sbin/usermod -a -G nagcmd apache |
➂Nagios ダウンロード
|
1 |
# wget https://sourceforge.net/projects/nagios/files/nagios-4.x/nagios-4.5.12/nagios-4.5.12.tar.gz |
④インストール
|
1 2 3 |
# tar zxvf nagios-4.5.12.tar.gz # cd nagios-4.5.12 # ./configure --with-command-group=nagcmd |
以下のように表示される
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
*** Configuration summary for nagios 4.5.12 2026-03-25 ***: General Options: ------------------------- Nagios executable: nagios Nagios user/group: nagios,nagios Command user/group: nagios,nagcmd Event Broker: yes Install ${prefix}: /usr/local/nagios Install ${includedir}: /usr/local/nagios/include/nagios Lock file: /run/nagios.lock Check result directory: /usr/local/nagios/var/spool/checkresults Init directory: /lib/systemd/system Apache conf.d directory: /etc/httpd/conf.d Mail program: /usr/sbin/mail Host OS: linux-gnu IOBroker Method: epoll Web Interface Options: ------------------------ HTML URL: http://localhost/nagios/ CGI URL: http://localhost/nagios/cgi-bin/ Traceroute (used by WAP): /usr/sbin/traceroute Review the options above for accuracy. If they look okay, type 'make all' to compile the main program and CGIs. |
コンパイル
|
1 |
# make all |
以下のように表示される
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
*** Support Notes ******************************************* If you have questions about configuring or running Nagios, please make sure that you: - Look at the sample config files - Read the documentation on the Nagios Library at: https://library.nagios.com 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: https://support.nagios.com ************************************************************* Enjoy. |
Nagios Core をインストール
|
1 |
# make install |
Nagios の init スクリプトをインストール
|
1 2 3 |
# make install-init /usr/bin/install -c -m 755 -d -o root -g root /lib/systemd/system /usr/bin/install -c -m 755 -o root -g root startup/default-service /lib/systemd/system/nagios.service |
外部コマンド ファイルと権限をインストール
|
1 2 3 4 5 6 |
# make install-commandmode /usr/bin/install -c -m 775 -o nagios -g nagios -d /usr/local/nagios/var/rw chmod g+s /usr/local/nagios/var/rw *** External command directory configured *** |
Nagios 構成ファイルをインストール
|
1 2 3 4 5 6 |
# make install-config *** Config files installed *** Remember, these are *SAMPLE* config files. You'll need to read the documentation for more information on how to actually define services, hosts, etc. to fit your particular needs. |
/usr/local/nagios/etc/objects/contacts.cfg 設定ファイルを編集し、nagiosadmin コンタクト定義に関連付けられているメールアドレスを、アラート受信に使用するアドレスに変更する。
|
1 2 3 4 |
# vi /usr/local/nagios/etc/objects/contacts.cfg 32行目 : 自身のメールアドレスに変更 email nagios@localhost ; <<***** CHANGE THIS TO YOUR EMAIL ADDRESS ****** |
Nagios 用の Apache 構成ファイルをインストール
|
1 2 3 4 5 6 7 |
# make install-webconf /usr/bin/install -c -m 644 sample-config/httpd.conf /etc/httpd/conf.d/nagios.conf if [ 0 -eq 1 ]; then \ ln -s /etc/httpd/conf.d/nagios.conf /etc/apache2/sites-enabled/nagios.conf; \ fi *** Nagios/Apache conf file installed *** |
3. Nagios プラグインをインストール
①Nagios Pluginsページから最新の codeをダウンロード
|
1 |
# wget https://nagios-plugins.org/download/nagios-plugins-2.5.tar.gz |
②インストール
|
1 2 3 4 5 |
# tar zxvf nagios-plugins-2.5.tar.gz # cd nagios-plugins-2.5 # ./configure --with-nagios-user=nagios --with-nagios-group=nagios # make # make install |
下記のとおりnagios-pluginsが利用可能である
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 |
# ls /usr/local/nagios/libexec check_apt check_disk check_http check_jabber check_nntp check_oracle check_breeze check_disk_smb check_icmp check_load check_nntps check_overcr check_by_ssh check_dns check_ide_smart check_log check_nt check_ping check_clamd check_dummy check_ifoperstatus check_mailq check_ntp check_pop check_cluster check_file_age check_ifstatus check_mrtg check_ntp_peer check_procs check_dhcp check_flexlm check_imap check_mrtgtraf check_ntp_time check_real check_dig check_ftp check_ircd check_nagios check_nwstat check_rpc [root@Lepard nagios-plugins-2.5]# ls /usr/local/nagios/libexec check_apt check_file_age check_load check_ntp_time check_smtp check_users check_breeze check_flexlm check_log check_nwstat check_spop check_wave check_by_ssh check_ftp check_mailq check_oracle check_ssh negate check_clamd check_http check_mrtg check_overcr check_ssl_validity remove_perfdata check_cluster check_icmp check_mrtgtraf check_ping check_ssmtp urlize check_dhcp check_ide_smart check_nagios check_pop check_swap utils.pm check_dig check_ifoperstatus check_nntp check_procs check_tcp utils.sh check_disk check_ifstatus check_nntps check_real check_time check_disk_smb check_imap check_nt check_rpc check_udp check_dns check_ircd check_ntp check_sensors check_ups check_dummy check_jabber check_ntp_peer check_simap check_uptime |
③必要なディレクトリを作成
|
1 2 |
# mkdir -p /usr/local/nagios/var/spool/checkresults # chown -R nagios:nagios /usr/local/nagios/var/spool/checkresults |
4. Nagios Web ユーザーの作成
Nagios Web ダッシュボードにアクセスするためのユーザー アカウントを作成する。このユーザーアカウントは、認証に使用される。
ユーザーのデフォルト名はnagiosadminで、/usr/local/nagios/etc/cgi.cfgファイル内に優先ユーザー名として定義されています。
|
1 2 3 4 |
# htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin New password: [password] Re-type new password: [again password] Adding password for user nagiosadmin |
所有権と権限を設定
|
1 2 |
# chown apache:apache /usr/local/nagios/etc/htpasswd.users # chmod 640 /usr/local/nagios/etc/htpasswd.users |
Apache を再起動
|
1 |
# systemctl restart httpd |
ファイアウォールで HTTP サービスポートを解放します
|
1 2 |
# firewall-cmd --add-service=http --permanent # firewall-cmd --reload |
Nagios サービスを有効化
|
1 2 |
# systemctl enable nagios --now Created symlink /etc/systemd/system/multi-user.target.wants/nagios.service → /lib/systemd/system/nagios.service. |
システムを再起動
|
1 |
# shutdown -r now |
サービスが実行しているか確認
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# systemctl status nagios ● nagios.service - Nagios Core 4.5.12 Loaded: loaded (/usr/lib/systemd/system/nagios.service; enabled; preset: disabled) Drop-In: /usr/lib/systemd/system/service.d └─10-timeout-abort.conf Active: active (running) since Fri 2026-05-01 15:52:12 JST; 1min 8s ago Invocation: 29b6d17a31fe4a98b7d35417272a1eeb Docs: https://www.nagios.org/documentation Process: 1266 ExecStartPre=/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg (code=exited, status=0/SUCCESS) Process: 1288 ExecStart=/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg (code=exited, status=0/SUCCESS) Main PID: 1292 (nagios) Tasks: 8 (limit: 3436) Memory: 8.1M (peak: 9.4M) CPU: 211ms CGroup: /system.slice/nagios.service ├─1292 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg ├─1295 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh ├─1296 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh ├─1297 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh ├─1299 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh ├─1300 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh ├─1301 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh └─1305 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg May 01 15:52:12 Lepard nagios[1292]: qh: echo service query handler registered May 01 15:52:12 Lepard nagios[1292]: qh: help for the query handler registered May 01 15:52:12 Lepard nagios[1292]: wproc: Successfully registered manager as @wproc with query handler May 01 15:52:12 Lepard nagios[1292]: wproc: Registry request: name=Core Worker 1295;pid=1295 May 01 15:52:12 Lepard nagios[1292]: wproc: Registry request: name=Core Worker 1300;pid=1300 May 01 15:52:12 Lepard nagios[1292]: wproc: Registry request: name=Core Worker 1296;pid=1296 |
5. Nagios Web インターフェイスにアクセス
任意のブラウザで http://[FQDN]/nagios/ もしくは http://[IP address]/nagios にアクセスし[Username]にnagiosadmin、[Password]には上記でユーザーを作成したとき指定したパスワードを入力し、[Log in]

ログインに成功すると、以下のダッシュボードが表示されます。

ホストの可用性を表示
左メニューの[Hosts]をクリック

左メニューの [Tactical Overview] をクリックすると監視データを閲覧できる

左メニューの [Current Status] [Services] をクリック : 現在の監視サービス内容が表示される
6. NRPEプラグインの構成
エージェントを監視するため。以下をインストールする
6.1 nrpeプラグインをインストール
|
1 2 3 |
# wget https://github.com/NagiosEnterprises/nrpe/releases/download/nrpe-4.1.1/nrpe-4.1.1.tar.gz # tar zxvf nrpe-4.1.1.tar.gz # cd nrpe-4.1.1 |
|
1 2 |
# ./configure # make all |
make allでSSLエラーが発生する場合
./configure --disable-ssl フラグを使用して、nrpe の設定で SSL を無効にする
|
1 2 |
# ./configure --disable-ssl # make all |
NRPEプラグインデーモンとサンプル設定ファイルをインストール
|
1 2 3 |
# make install-plugin # make install-daemon # make install-config |
NRPE デーモンをサービスとしてインストール
|
1 |
# make install-init |
/usr/local/nagios/etc/nrpe.cfg ファイルを開き、ローカルホスト と Nagiosモニタリングサーバー の IPアドレス を追加
|
1 2 3 4 |
# vi /usr/local/nagios/etc/nrpe.cfg 106行目 : 追記 allowed_hosts=127.0.0.1,::1,192.168.11.83 |
バージョン確認
|
1 2 3 |
# /usr/local/nagios/bin/nrpe -V NRPE - Nagios Remote Plugin Executor Version: 4.1.1 |
サービスを開始して有効にする
|
1 2 3 4 |
# systemctl enable nrpe Created symlink '/etc/systemd/system/multi-user.target.wants/nrpe.service' → '/usr/lib/systemd/system/nrpe.service'. # systemctl restart nrpe |
ファイアウォールでNRPEのポートを開く
NRPEはデフォルトでTCP 5666ポートを使用します。ファイアウォールが動作している場合は、Nagiosモニタリングサーバーからの外部チェックを許可するために、このポートを開きます。
|
1 2 |
# firewall-cmd --add-port=5666/tcp --permanent # firewall-cmd --reload |
ポート5666/tcpがリッスンされているか確認
|
1 2 3 |
# netstat -na | grep "5666" tcp 0 0 0.0.0.0:5666 0.0.0.0:* LISTEN |
「check_nrpe」コマンドを実行して、NRPEデーモンが正常に動作していることを確認
インストールされているNRPEのバージョンが表示される
|
1 2 |
# /usr/local/nagios/libexec/check_nrpe -H 127.0.0.1 NRPE v4.1.1 |
7. 監視ホストの追加
下記サーバーをホストに追加し、 単純なPing による死活監視対象として設定
OS : Fedora43
IPアドレス : 192.168.11.85
7.1 設定ファイル編集
|
1 2 3 |
# vi /usr/local/nagios/etc/nagios.cfg 51行目 : コメント解除 cfg_dir=/usr/local/nagios/etc/servers |
7.2 ディレクトリー作成
|
1 2 3 |
# mkdir /usr/local/nagios/etc/servers # chgrp nagios /usr/local/nagios/etc/servers # chmod 750 /usr/local/nagios/etc/servers |
7.3 定義ファイル新規作成
"korodes.cfg" 名称は任意でよい
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 |
# vi /usr/local/nagios/etc/servers/korodes.cfg define host { use linux-server host_name korodes alias korodes address 192.168.11.85 } define service { use generic-service host_name korodes service_description PING check_command check_ping!100.0,20%!500.0,60% } |
7.4 Nagiosサーバー再起動
|
1 |
# systemctl restart nagios.service |
Nagios サーバーにログイン(http://[サーバーIPアドレス]/nagios)しHostsを見るとホストが追加されている

8. 監視サービスの追加
上記で追加したホストに監視サービスを追加する
OS : Fedora43
IPアドレス : 192.168.11.85
8.1 監視対象サーバー側の設定
8.1.1 監視対象ホストにエージェントをインストール
nrpe 及び代表的なサービスプラグインをインストール
|
1 |
# dnf -y install nagios-nrpe nagios-plugins-all |
8.1.2 設定ファイル編集
# vi /etc/nagios/nrpe.cfg
106行目 : 接続を許可するホストを追記 (Nagios サーバーを指定)
allowed_hosts=127.0.0.1,::1,192.168.11.83
122行目 : コマンドの引数を許可
dont_blame_nrpe=1
300-304行目コメントにし、追加
# command[check_users]=/usr/lib/nagios/plugins/check_users -w 5 -c 10
# command[check_load]=/usr/lib/nagios/plugins/check_load -r -w .15,.10,.05 -c .30,.25,.20
# command[check_hda1]=/usr/lib/nagios/plugins/check_disk -w 20% -c 10% -p /dev/hda1
# command[check_zombie_procs]=/usr/lib/nagios/plugins/check_procs -w 5 -c 10 -s Z
# command[check_total_procs]=/usr/lib/nagios/plugins/check_procs -w 150 -c 200
pluginの一部を追加する
command[check_by_ssh]=/usr/lib/nagios/plugins/check_by_ssh $ARG1$
command[check_dhcp]=/usr/lib/nagios/plugins/check_dhcp $ARG1$
command[check_disk]=/usr/lib/nagios/plugins/check_disk $ARG1$
command[check_file_age]=/usr/lib/nagios/plugins/check_file_age $ARG1$
command[check_ftp]=/usr/lib/nagios/plugins/check_ftp $ARG1$
command[check_http]=/usr/lib/nagios/plugins/check_http $ARG1$
command[check_imap]=/usr/lib/nagios/plugins/check_imap $ARG1$
command[check_load]=/usr/lib/nagios/plugins/check_load $ARG1$
command[check_log]=/usr/lib/nagios/plugins/check_log $ARG1$
command[check_mysql]=/usr/lib/nagios/plugins/check_mysql $ARG1$
command[check_ntp]=/usr/lib/nagios/plugins/check_ntp $ARG1$
command[check_ntp_peer]=/usr/lib/nagios/plugins/check_ntp_peer $ARG1$
command[check_ntp_time]=/usr/lib/nagios/plugins/check_ntp_time $ARG1$
command[check_ping]=/usr/lib/nagios/plugins/check_ping $ARG1$
command[check_pop]=/usr/lib/nagios/plugins/check_pop $ARG1$
command[check_spop]=/usr/lib/nagios/plugins/check_spop $ARG1$
command[check_procs]=/usr/lib/nagios/plugins/check_procs $ARG1$
command[check_smtp]=/usr/lib/nagios/plugins/check_smtp $ARG1$
command[check_ssmtp]=/usr/lib/nagios/plugins/check_ssmtp $ARG1$
command[check_ssh]=/usr/lib/nagios/plugins/check_ssh $ARG1$
command[check_swap]=/usr/lib/nagios/plugins/check_swap $ARG1$
command[check_tcp]=/usr/lib/nagios/plugins/check_tcp $ARG1$
command[check_udp]=/usr/lib/nagios/plugins/check_udp $ARG1$
command[check_ups]=/usr/lib/nagios/plugins/check_ups $ARG1$
command[check_users]=/usr/lib/nagios/plugins/check_users $ARG1$
8.1.3 nrpeサーバー有効化、起動
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 |
# systemctl enable --now nrpe Created symlink '/etc/systemd/system/multi-user.target.wants/nrpe.service' → '/usr/lib/systemd/system/nrpe.service'. # systemctl start nrpe # systemctl status nrpe ● nrpe.service - Nagios Remote Plugin Executor Loaded: loaded (/usr/lib/systemd/system/nrpe.service; enabled; preset: disabled) Drop-In: /usr/lib/systemd/system/service.d mq10-timeout-abort.conf Active: active (running) since Fri 2026-05-01 16:08:01 JST; 30s ago Invocation: 68c9d5f90c454704a03432d01cadb816 Docs: http://www.nagios.org/documentation Main PID: 5918 (nrpe) Tasks: 1 (limit: 3435) Memory: 1.5M (peak: 1.7M) CPU: 16ms CGroup: /system.slice/nrpe.service mq5918 /usr/bin/nrpe -c /etc/nagios/nrpe.cfg -f May 01 16:08:01 Lion systemd[1]: Started nrpe.service - Nagios Remote Plugin Executor. May 01 16:08:01 Lion nrpe[5918]: Starting up daemon May 01 16:08:01 Lion nrpe[5918]: Server listening on 0.0.0.0 port 5666. May 01 16:08:01 Lion nrpe[5918]: Server listening on :: port 5666. May 01 16:08:01 Lion nrpe[5918]: Warning: Daemon is configured to accept command arguments from clients! May 01 16:08:01 Lion nrpe[5918]: Listening for connections on port 5666 May 01 16:08:01 Lion nrpe[5918]: Allowing connections from: 127.0.0.1,::1,192.168.11.83 |
8.1.4 ファイアウォールでNRPEのポート5666/tcp,5666/udpを開く
|
1 2 3 |
# firewall-cmd --permanent --add-port=5666/tcp # firewall-cmd --permanent --add-port=5666/udp # firewall-cmd --reload |
8.2 Nagios サーバー側の設定
8.2.1 commands.cfg編集
|
1 2 3 4 5 6 7 |
# vi /usr/local/nagios/etc/objects/commands.cfg # 最終行に追記 define command { command_name check_nrpe command_line $USER1$/check_nrpe -H $HOSTADDRESS$ -c $ARG1$ } |
8.2.2 先ほどホストを追加したときに作成した korodes.cfg を編集追加する
今回はHTTP,SSH,FTPを追加してみる
|
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# vi /usr/local/nagios/etc/servers/korodes.cfg # 以下を追加する # 'HTTP' command definition define service{ use local-service host_name korodes service_description HTTP check_command check_http } # 'SSH' command definition define service{ use local-service host_name korodes service_description SSH check_command check_ssh } # 'FTP' command definition define service{ use local-service host_name korodes service_description FTP check_command check_ftp } |
8.2.5 Nagios 再起動
|
1 |
# systemctl restart nagios.service |
8.2.6 http://[Nagios Server IP Address]/nagios にアクセスする
下図のように新しく追加した監視サービスが追加されている

