監視ツール · 3 min read · Nov 08, 2025
Ubuntu 22.04にNagios監視ツールをインストールする方法

Nagiosは、LinuxおよびWindowsサーバー、ネットワーク、インフラストラクチャを監視するために使用される強力な無料のオープンソース監視ツールです。Nagiosを使用すると、CPU使用率、ディスク使用率、HTTP、SSH、FTP、SMTPなどのいくつかのサービスを監視できます。すべてのサーバーを中央の場所から監視するのに役立つシンプルでユーザーフレンドリーなWebインターフェースがあります。複数のAPIを使用してサードパーティアプリケーションと簡単に統合できます。Nagiosは、指定したホストとサービスを継続的に監視し、問題が発生したときに通知します。
このチュートリアルでは、Ubuntu 22.04サーバーにNagios Coreをインストールする方法を示します。
前提条件
- Ubuntu 22.04を実行しているサーバー。
- サーバーに設定されたrootパスワード。
必要な依存関係のインストール
始める前に、システムパッケージを更新し、サーバーに他の必要な依存関係をインストールする必要があります:
apt-get update -y
apt-get install wget unzip vim curl openssl build-essential libgd-dev libssl-dev libapache2-mod-php php-gd php apache2 -yすべてのパッケージがインストールされたら、次のステップに進むことができます。
ソースからNagios Coreをインストール
デフォルトでは、最新のNagios Coreバージョンは22.04のデフォルトリポジトリにはありません。したがって、ソースからNagiosをコンパイルすることをお勧めします。
まず、次のコマンドを使用してGitリポジトリから最新のNagios Coreバージョンをダウンロードします:
wget https://assets.nagios.com/downloads/nagioscore/releases/nagios-4.4.7.tar.gzダウンロードが完了したら、次のコマンドを使用してダウンロードしたファイルを抽出します:
tar -xvzf nagios-4.4.7.tar.gz次に、抽出されたディレクトリに移動し、次のコマンドでNagios Coreを構成します:
cd nagios-4.4.7
./configure --with-httpd-conf=/etc/apache2/sites-enabled次の出力が表示されるはずです:
* Configuration summary for nagios 4.4.7 2022-04-14 *:
General Options:
-------------------------
Nagios executable: nagios
Nagios user/group: nagios,nagios
Command user/group: nagios,nagios
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/apache2/sites-enabled
Mail program: /bin/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):
Review the options above for accuracy. If they look okay,
type 'make all' to compile the main program and CGIs.
次に、次のコマンドを実行してNagiosをコンパイルします:
make all次に、必要なユーザーとグループを作成し、次のコマンドでNagiosユーザーをwww-dataグループに追加します:
make install-groups-users
usermod -a -G nagios www-data次に、次のコマンドを使用してNagios Coreをインストールします:
make install次の出力が表示されるはずです:
* Main program, CGIs and HTML files installed *
You can continue with installing Nagios as follows (type 'make'
without any arguments for a list of all possible options):
make install-init
- This installs the init script in /lib/systemd/system
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/nagios/etc
make[1]: Leaving directory '/root/nagios-4.4.7'
Nagios Coreがインストールされたら、Nagiosサービスを管理するためのsystemdサービスファイルを作成する必要があります。次のコマンドでsystemd initスクリプトを作成できます:
make install-daemoninit次に、次のコマンドでNagiosインストールディレクトリの適切な権限を設定します:
make install-commandmode次に、次のコマンドでサンプルのNagios構成ファイルを作成します:
make install-config次に、次のコマンドでNagios Webインターフェースをインストールします:
make install-webconf
a2enmod rewrite cgi次に、変更を適用するためにApacheサービスを再起動します:
systemctl restart apache2次に、Nagios Webインターフェースのテーマをインストールします。
make install-exfoliationNagios管理ユーザーの作成
次に、Nagios Webインターフェースにアクセスするための管理ユーザーを作成する必要があります。次のコマンドで作成できます:
htpasswd -c /usr/local/nagios/etc/htpasswd.users nagiosadmin以下のように希望のパスワードを設定します:
New password:
Re-type new password:
Adding password for user nagiosadmin
Nagiosプラグインのインストール
次に、システムサービスを監視するためのNagiosプラグインをダウンロードする必要があります。次のコマンドでGitリポジトリからダウンロードできます:
wget https://github.com/nagios-plugins/nagios-plugins/releases/download/release-2.4.0/nagios-plugins-2.4.0.tar.gzダウンロードが完了したら、次のコマンドを使用してダウンロードしたファイルを抽出します:
tar -xvzf nagios-plugins-2.4.0.tar.gz次に、抽出されたディレクトリに移動し、次のコマンドで構成します:
cd nagios-plugins-2.4.0
./configure --with-nagios-user=nagios --with-nagios-group=nagios次に、次のコマンドでインストールします:
make
make install次に、次のコマンドでNagios構成ファイルのサンプルを確認します:
/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfgすべてが正常であれば、次の出力が表示されるはずです:
Running pre-flight check on configuration data...
Checking objects...
Checked 8 services.
Checked 1 hosts.
Checked 1 host groups.
Checked 0 service groups.
Checked 1 contacts.
Checked 1 contact groups.
Checked 24 commands.
Checked 5 time periods.
Checked 0 host escalations.
Checked 0 service escalations.
Checking for circular paths...
Checked 1 hosts
Checked 0 service dependencies
Checked 0 host dependencies
Checked 5 timeperiods
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
Nagiosサービスの開始
次に、Nagiosサービスを開始し、システム再起動時に自動的に開始されるように設定します:
systemctl start nagios
systemctl enable nagios次のコマンドでNagiosサービスのステータスを確認することもできます:
systemctl status nagios次の出力が表示されるはずです:
? nagios.service - Nagios Core 4.4.7
Loaded: loaded (/lib/systemd/system/nagios.service; enabled; vendor preset: enabled)
Active: active (running) since Wed 2022-05-04 17:18:52 UTC; 1s ago
Docs: https://www.nagios.org/documentation
Process: 15854 ExecStartPre=/usr/local/nagios/bin/nagios -v /usr/local/nagios/etc/nagios.cfg (code=exited, status=0/SUCCESS)
Process: 15855 ExecStart=/usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg (code=exited, status=0/SUCCESS)
Main PID: 15856 (nagios)
Tasks: 6 (limit: 2241)
Memory: 5.2M
CPU: 355ms
CGroup: /system.slice/nagios.service
??15856 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
??15857 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
??15858 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
??15859 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
??15860 /usr/local/nagios/bin/nagios --worker /usr/local/nagios/var/rw/nagios.qh
??15861 /usr/local/nagios/bin/nagios -d /usr/local/nagios/etc/nagios.cfg
June 12 06:10:52 jellyfish nagios[15856]: qh: core query handler registered
June 12 06:10:52 jellyfish nagios[15856]: qh: echo service query handler registered
June 12 06:10:52 jellyfish nagios[15856]: qh: help for the query handler registered
June 12 06:10:52 jellyfish nagios[15856]: wproc: Successfully registered manager as @wproc with query handler
June 12 06:10:52 jellyfish nagios[15856]: wproc: Registry request: name=Core Worker 15858;pid=15858
June 12 06:10:52 jellyfish nagios[15856]: wproc: Registry request: name=Core Worker 15857;pid=15857
June 12 06:10:52 jellyfish nagios[15856]: wproc: Registry request: name=Core Worker 15860;pid=15860
June 12 06:10:52 jellyfish nagios[15856]: wproc: Registry request: name=Core Worker 15859;pid=15859
June 12 06:10:53 jellyfish nagios[15856]: Successfully launched command file worker with pid 15861
June 12 06:10:53 jellyfish nagios[15856]: HOST ALERT: localhost;DOWN;SOFT;1;(No output on stdout)
Nagios Webインターフェースにアクセス
今、Webブラウザを開き、URL http://your-server-ip/nagios を入力します。Nagiosログイン画面にリダイレクトされます:

Nagios管理ユーザー名、パスワードを入力し、OKボタンをクリックします。次の画面にNagiosのデフォルトダッシュボードが表示されるはずです:

結論
おめでとうございます!Ubuntu 22.04サーバーに最新のNagios Coreを正常にインストールしました。これで、インフラストラクチャにNagiosを実装し、監視ホストを追加し、Webブラウザを介してそれらを監視を開始できます。質問があればお気軽にお尋ねください。
新しい投稿を受信箱で受け取る
スパムはありません。いつでも購読を解除できます。