監視ソフトウェア · 11 min read · Nov 07, 2025

Ubuntu 22.04 LTSにIcinga 2監視ソフトウェアをインストールする方法

Icinga2は、ネットワークからリソースの可用性をチェックし、ユーザーに障害を通知する無料のオープンソースネットワーク監視ソフトウェアです。Icinga2を使用して、ネットワークサービス(SMTP、POP3、HTTP、NNTP、ping)、ホストリソース(CPU使用率、ディスク使用率)、およびネットワークコンポーネント(スイッチ、ルーター、温度および湿度センサー)を監視できます。Nagiosプラグインと統合することも可能です。

以下のチュートリアルでは、Ubuntu 22.04サーバーにIcinga2をインストールし、クライアントノードに接続する方法を学びます。デフォルトのApacheサーバーの代わりに、Nginxを使用してIcinga2 Webを実行します。

前提条件

  • Ubuntu 22.04を実行している2台のマシン。一方はマスターサーバーとして機能し、もう一方は監視用のクライアントとして機能します。
  • 両方のサーバーでsudo権限を持つ非rootユーザー。
  • マスターサーバー用の完全修飾ドメイン名(FQDN)icinga.example.comとクライアントノード用のclient.example.com
  • すべてが更新されていることを確認してください。 $ sudo apt update $ sudo apt upgrade
  • システムに必要な数個のパッケージ。 $ sudo apt install wget curl nano software-properties-common dirmngr apt-transport-https gnupg2 ca-certificates lsb-release ubuntu-keyring unzip -y これらのパッケージのいくつかは、すでにシステムにインストールされている場合があります。

ステップ1 - マスターサーバーのファイアウォールを構成する

最初のステップは、ファイアウォールを構成することです。Ubuntuにはデフォルトでufw(Uncomplicated Firewall)が付属しています。

ファイアウォールが実行中かどうかを確認します。

$ sudo ufw status

次の出力が得られるはずです。

Status: inactive

SSHポートを許可して、ファイアウォールを有効にしたときに現在の接続が切断されないようにします。

$ sudo ufw allow OpenSSH

サーバーに接続するためにIcinga2クライアントが必要とするポート5665を許可します。

$ sudo ufw allow 5665

HTTPおよびHTTPSポートも許可します。

$ sudo ufw allow http
$ sudo ufw allow https

ファイアウォールを有効にします。

$ sudo ufw enable
コマンドは既存のssh接続を中断する可能性があります。操作を続行しますか(y|n)? y
ファイアウォールはアクティブで、システム起動時に有効になります

再度ファイアウォールの状態を確認します。

$ sudo ufw status

同様の出力が表示されるはずです。

Status: active

To                         Action      From
--                         ------      ----
OpenSSH                    ALLOW       Anywhere
80/tcp                     ALLOW       Anywhere
443                        ALLOW       Anywhere
5665                       ALLOW       Anywhere
OpenSSH (v6)               ALLOW       Anywhere (v6)
80/tcp (v6)                ALLOW       Anywhere (v6)
443 (v6)                   ALLOW       Anywhere (v6)
5665 (v6)                  ALLOW       Anywhere (v6)

ステップ2 - MySQLをインストールする

Ubuntu 22.04には最新のMySQLバージョンが付属しています。単一のコマンドでインストールできます。

$ sudo apt install mysql-server

MySQLのバージョンを確認します。

$ mysql --version
mysql  Ver 8.0.32-0ubuntu0.22.04.2 for Linux on x86_64 ((Ubuntu))

このステップは、MySQLバージョン8.0.28以上に必要です。MySQLシェルに入ります。

$ sudo mysql

次のコマンドを実行して、rootユーザーのパスワードを設定します。数字、大文字、小文字、特殊文字を組み合わせてください。

mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'YourPassword12!';

シェルを終了します。

mysql> exit

MySQLのセキュアインストールスクリプトを実行します。

$ sudo mysql_secure_installation

最初に、rootパスワードを求められます。入力してください。次に、Validate Password Componentをインストールするかどうかを尋ねられます。これはMySQLで使用されるパスワードの強度をチェックします。インストールするにはYを押してください。次に、パスワード検証ポリシーのレベルを設定するように求められます。最も強力な2を選択してください。

MySQLサーバーのデプロイメントを保護しています。

ユーザーrootのパスワードを入力してください:

VALIDATE PASSWORD COMPONENTはパスワードをテストしてセキュリティを向上させるために使用できます。パスワードの強度をチェックし、ユーザーが十分に安全なパスワードのみを設定できるようにします。VALIDATE PASSWORDコンポーネントを設定しますか?

はいの場合はy|Yを押し、いいえの場合は他のキーを押してください:Y

パスワード検証ポリシーには3つのレベルがあります:

LOW    Length >= 8
MEDIUM Length >= 8, numeric, mixed case, and special characters
STRONG Length >= 8, numeric, mixed case, special characters and dictionary                  file

0 = LOW、1 = MEDIUM、2 = STRONGを入力してください:2
既存のパスワードをrootに使用します。

推定されるパスワードの強度:100

次に、rootパスワードを変更しないことを拒否するためにNを入力します。また、匿名ユーザーを削除し、リモートrootログインを禁止し、テストデータベースを削除し、特権テーブルを再読み込みするためにYを入力します。

rootのパスワードを変更しますか?(はいの場合はy|Yを押し、いいえの場合は他のキーを押してください):N

 ... スキップ中。
デフォルトでは、MySQLインストールには匿名ユーザーがあり、ユーザーアカウントを作成せずに誰でもMySQLにログインできます。これはテスト用のみであり、インストールを少しスムーズにするためのものです。生産環境に移行する前に削除する必要があります。

匿名ユーザーを削除しますか?(はいの場合はy|Yを押し、いいえの場合は他のキーを押してください):Y
成功。

通常、rootは「localhost」からのみ接続を許可されるべきです。これにより、誰かがネットワークからrootパスワードを推測できないようにします。

リモートでのrootログインを禁止しますか?(はいの場合はy|Yを押し、いいえの場合は他のキーを押してください):Y
成功。

デフォルトでは、MySQLには「test」という名前のデータベースが付属しており、誰でもアクセスできます。これはテスト用のみであり、生産環境に移行する前に削除する必要があります。

テストデータベースとそのアクセスを削除しますか?(はいの場合はy|Yを押し、いいえの場合は他のキーを押してください):Y
 - テストデータベースを削除中...
成功。

 - テストデータベースの特権を削除中...
成功。

特権テーブルを再読み込みすると、これまでに行ったすべての変更が即座に適用されます。

特権テーブルを再読み込みしますか?(はいの場合はy|Yを押し、いいえの場合は他のキーを押してください):Y
成功。

すべて完了!

ステップ3 - MySQLを構成する

MySQLシェルにログインします。プロンプトが表示されたら、rootパスワードを入力します。

$ sudo mysql -u root -p

Icingaデータベースを作成します。

mysql> CREATE DATABASE icinga2;

Icinga2用のSQLユーザーアカウントを作成します。デフォルトで設定されているデータベースとユーザー名を変更しないでください。変更したい場合は、ステップ5でMySQLドライバーをインストールする際にいくつかの追加手順を実行する必要があります。パスワードを入力すると、エラーが表示され、その後再構成を求められ、カスタムデータベース名とユーザーを指定できます。

mysql> CREATE USER 'icinga2'@'localhost' IDENTIFIED BY 'Your_password2';

ユーザーにデータベースへのすべての特権を付与します。

mysql> GRANT ALL PRIVILEGES ON icinga2.* TO 'icinga2'@'localhost';

ユーザー特権をフラッシュします。

mysql> FLUSH PRIVILEGES;

シェルを終了します。

mysql> exit

ステップ4 - マスターサーバーにIcinga2と監視プラグインをインストールする

インストールにはIcinga2の公式リポジトリを使用します。Icinga2 GPGキーをダウンロードしてインポートします。

$ wget -O - https://packages.icinga.com/icinga.key | sudo gpg --dearmor -o /usr/share/keyrings/icinga-archive-keyring.gpg

次のコマンドを実行して、Icinga2リポジトリ情報をAPTソースリストに作成して追加します。

$ echo "deb [signed-by=/usr/share/keyrings/icinga-archive-keyring.gpg] https://packages.icinga.com/ubuntu icinga-`lsb_release -cs` main" | sudo tee /etc/apt/sources.list.d/$(lsb_release -cs)-icinga.list
$ echo "deb-src [signed-by=/usr/share/keyrings/icinga-archive-keyring.gpg] http://packages.icinga.com/ubuntu icinga-`lsb_release -cs` main" | sudo tee -a /etc/apt/sources.list.d/$(lsb_release -cs)-icinga.list

システムリポジトリリストを更新します。

$ sudo apt update

Icinga2と監視プラグインをインストールします。

$ sudo apt install icinga2 monitoring-plugins -y

ステップ5 - マスターサーバーにIDO MySQLドライバーをインストールする

Icinga2が機能するためには、データベースが必要です。そのために、IDO MySQLドライバーをインストールしてデータベース接続を設定する必要があります。次のコマンドを実行してMySQLドライバーをインストールします。

$ sudo apt install -y icinga2-ido-mysql

ドライバーを設定し、dbconfig-commonユーティリティを使用してデータベースを作成するように求められます。続行するにははいを選択します。

次に、icinga2データベースのMySQLパスワードを尋ねられます。ステップ3で設定したパスワードを入力して続行します。

Icinga2用のデータベースパスワードを入力

再度パスワードを確認するように求められます。

Icinga2パスワード確認

次に、ido-mysql機能を有効にするように求められます。続行するにははいを選択します。

Icinga IDO-MySQL機能

データベースの詳細は/etc/icinga2/features-available/ido-mysql.confファイルで確認できます。

$ cat /etc/icinga2/features-available/ido-mysql.conf
/**
 * The db_ido_mysql library implements IDO functionality
 * for MySQL.
 */

library "db_ido_mysql"

object IdoMysqlConnection "ido-mysql" {
  user = "icinga2",
  password = "Your_password2",
  host = "localhost",
  database = "icinga2"
}

ido-mysql機能を有効にします。

$ sudo icinga2 feature enable ido-mysql

Icinga2サービスを再起動します。

$ sudo systemctl restart icinga2

サービスの状態を確認します。

$ sudo systemctl status icinga2
? icinga2.service - Icinga host/service/network monitoring system
     Loaded: loaded (/lib/systemd/system/icinga2.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/icinga2.service.d
             ??limits.conf
     Active: active (running) since Mon 2023-05-01 08:02:36 UTC; 1s ago
    Process: 9823 ExecStartPre=/usr/lib/icinga2/prepare-dirs /etc/default/icinga2 (code=exited, status=0/SUCCESS)
   Main PID: 9828 (icinga2)
     Status: "Startup finished."
      Tasks: 10
     Memory: 17.6M
        CPU: 657ms
     CGroup: /system.slice/icinga2.service
             ??9828 /usr/lib/x86_64-linux-gnu/icinga2/sbin/icinga2 --no-stack-rlimit daemon --close-stdio -e /var/log/icinga2/error.log
             ??9846 /usr/lib/x86_64-linux-gnu/icinga2/sbin/icinga2 --no-stack-rlimit daemon --close-stdio -e /var/log/icinga2/error.log
             ??9849 /usr/lib/x86_64-linux-gnu/icinga2/sbin/icinga2 --no-stack-rlimit daemon --close-stdio -e /var/log/icinga2/error.log

ステップ6 - Icinga2 APIを構成する

HTTPを介してIcinga2監視を管理および構成するには、Icinga2 APIを構成する必要があります。次のコマンドを実行してIcinga2 APIを有効にし、Icinga2用のTLS証明書を生成し、Icinga2の構成を更新します。

$ sudo icinga2 api setup

次のような出力が得られます。

information/cli: Generating new CA.
information/base: Writing private key to '/var/lib/icinga2/ca//ca.key'.
information/base: Writing X509 certificate to '/var/lib/icinga2/ca//ca.crt'.
information/cli: Generating new CSR in '/var/lib/icinga2/certs//icinga.example.com.csr'.
information/base: Writing private key to '/var/lib/icinga2/certs//icinga.example.com.key'.
information/base: Writing certificate signing request to '/var/lib/icinga2/certs//icinga.example.com.csr'.
information/cli: Signing CSR with CA and writing certificate to '/var/lib/icinga2/certs//icinga.example.com.crt'.
information/pki: Writing certificate to file '/var/lib/icinga2/certs//icinga.example.com.crt'.
information/cli: Copying CA certificate to '/var/lib/icinga2/certs//ca.crt'.
information/cli: Adding new ApiUser 'root' in '/etc/icinga2/conf.d/api-users.conf'.
information/cli: Reading '/etc/icinga2/icinga2.conf'.
information/cli: Enabling the 'api' feature.
Enabling feature api. Make sure to restart Icinga 2 for these changes to take effect.
information/cli: Updating 'NodeName' constant in '/etc/icinga2/constants.conf'.
information/cli: Created backup file '/etc/icinga2/constants.conf.orig'.
information/cli: Updating 'ZoneName' constant in '/etc/icinga2/constants.conf'.
information/cli: Backup file '/etc/icinga2/constants.conf.orig' already exists. Skipping backup.
Done.

上記のコマンドは、Icinga2 APIに対してすべての権限を持つデフォルトユーザーrootを持つ/etc/icinga2/conf.d/api-users.confファイルを作成します。最小限の権限を持つ新しいユーザーが必要です。後でウェブサイトにアクセスするために必要な資格情報をメモしておいてください。Icinga2 APIサーバーはデフォルトでポート5665で待機しています。変更を適用するためにサービスを再起動します。

$ sudo systemctl restart icinga2

次のステップは、Icinga Webインターフェースをインストールすることです。これはApache用に事前構成されていますが、Nginxサーバーを使用します。したがって、最初にNginxとSSL証明書をインストールする必要があります。

ステップ7 - Nginxをインストールする

Ubuntu 22.04には古いバージョンのNginxが付属しています。最新バージョンをインストールするには、公式のNginxリポジトリをダウンロードする必要があります。

Nginxの署名キーをインポートします。

$ curl https://nginx.org/keys/nginx_signing.key | gpg --dearmor \
| sudo tee /usr/share/keyrings/nginx-archive-keyring.gpg >/dev/null

Nginxの安定版リポジトリを追加します。

$ echo "deb [signed-by=/usr/share/keyrings/nginx-archive-keyring.gpg arch=amd64] \
http://nginx.org/packages/ubuntu `lsb_release -cs` nginx" \
| sudo tee /etc/apt/sources.list.d/nginx.list

システムリポジトリを更新します。

$ sudo apt update

Nginxをインストールします。

$ sudo apt install nginx

インストールを確認します。

$ nginx -v
nginx version: nginx/1.24.0

Nginxサーバーを起動します。

$ sudo systemctl start nginx

ステップ8 - SSLをインストールする

SSL証明書を生成するためにCertbotをインストールする必要があります。Ubuntuのリポジトリを使用してCertbotをインストールするか、Snapdツールを使用して最新バージョンを取得できます。Snapdバージョンを使用します。

Ubuntu 22.04にはデフォルトでSnapdがインストールされています。次のコマンドを実行して、Snapdのバージョンが最新であることを確認します。

$ sudo snap install core && sudo snap refresh core

Certbotをインストールします。

$ sudo snap install --classic certbot

次のコマンドを使用して、Certbotコマンドが/usr/binディレクトリで実行できるようにシンボリックリンクを作成します。

$ sudo ln -s /snap/bin/certbot /usr/bin/certbot

次のコマンドを実行してSSL証明書を生成します。

$ sudo certbot certonly --nginx --agree-tos --no-eff-email --staple-ocsp --preferred-challenges http -m [email protected] -d icinga.example.com

上記のコマンドは、サーバーの/etc/letsencrypt/live/icinga.example.comディレクトリに証明書をダウンロードします。

Diffie-Hellmanグループ証明書を生成します。

$ sudo openssl dhparam -dsaparam -out /etc/ssl/certs/dhparam.pem 4096

Certbotの更新スケジューラーサービスを確認します。

$ sudo systemctl list-timers

snap.certbot.renew.serviceがスケジュールされたサービスの1つとして表示されます。

NEXT                        LEFT          LAST                        PASSED         UNIT                     ACTIVATES
------------------------------------------------------------------------------------------------------------------------------------
Mon 2023-05-01 13:37:57 UTC 3h 45min left Mon 2023-05-01 07:20:42 UTC 2h 31min ago   ua-timer.timer           ua-timer.service
Mon 2023-05-01 14:39:29 UTC 4h 47min left Sat 2023-02-04 16:04:18 UTC 2 months ago   motd-news.timer          motd-news.service
Mon 2023-05-01 15:53:00 UTC 6h left       n/a                         n/a            snap.certbot.renew.timer snap.certbot.renew.service

プロセスのドライランを実行して、SSL更新が正常に機能しているかどうかを確認します。

$ sudo certbot renew --dry-run

エラーが表示されない場合は、すべて設定完了です。証明書は自動的に更新されます。

ステップ9 - NginxとPHPを構成する

IcingaはApache用に構成されているため、PHP-FPMパッケージはデフォルトでインストールされていません。PDFにグラフをエクスポートする場合は、PHP Imagickモジュールも必要です。次のコマンドを実行してPHP-FPMとPHP Imagickライブラリをインストールします。

$ sudo apt install php-fpm php-imagick

PHP-FPMを構成する

/etc/php/8.1/fpm/pool.d/www.confファイルを開きます。

$ sudo nano /etc/php/8.1/fpm/pool.d/www.conf

PHPプロセスのUnixユーザー/グループをnginxに設定する必要があります。ファイル内のuser=www-dataおよびgroup=www-data行を見つけて、nginxに変更します。

...
; Unix user/group of processes
; Note: The user is mandatory. If the group is not set, the default user's group
;       will be used.
user = nginx
group = nginx
...

ファイル内のlisten.owner = www-dataおよびlisten.group = www-data行を見つけて、nginxに変更します。

; Set permissions for unix socket, if one is used. In Linux, read/write
; permissions must be set in order to allow connections from a web server. Many
; BSD-derived systems allow connections regardless of permissions. The owner
; and group can be specified either by name or by their numeric IDs.
; Default Values: user and group are set as the running user
;                 mode is set to 0660
listen.owner = nginx
listen.group = nginx

ファイルを保存するには、Ctrl + Xを押し、プロンプトが表示されたらYを入力します。

PHP-FPMサービスを再起動します。

$ sudo systemctl restart php8.1-fpm

Nginxを構成する

/etc/nginx/conf.d/icinga.confファイルを作成して開きます。

$ sudo nano /etc/nginx/conf.d/icinga.conf

以下のコードを貼り付けます。

server {
    listen       443 ssl http2;
    listen       [::]:443 ssl http2;
    server_name  icinga.example.com;

    access_log  /var/log/nginx/icinga.access.log;
    error_log   /var/log/nginx/icinga.error.log;

    # SSL
    ssl_certificate      /etc/letsencrypt/live/icinga.example.com/fullchain.pem;
    ssl_certificate_key  /etc/letsencrypt/live/icinga.example.com/privkey.pem;
    ssl_trusted_certificate /etc/letsencrypt/live/icinga.example.com/chain.pem;
    ssl_session_timeout  5m;
    ssl_session_cache shared:MozSSL:10m;
    ssl_session_tickets off;
    ssl_protocols TLSv1.2 TLSv1.3;
    ssl_prefer_server_ciphers on;
    ssl_ciphers ECDHE-ECDSA-AES128-GCM-SHA256:ECDHE-RSA-AES128-GCM-SHA256:ECDHE-ECDSA-AES256-GCM-SHA384:ECDHE-RSA-AES256-GCM-SHA384:ECDHE-ECDSA-CHACHA20-POLY1305:ECDHE-RSA-CHACHA20-POLY1305:DHE-RSA-AES128-GCM-SHA256:DHE-RSA-AES256-GCM-SHA384;
    ssl_ecdh_curve X25519:prime256v1:secp384r1:secp521r1;
    ssl_stapling on;
    ssl_stapling_verify on;
    ssl_dhparam /etc/ssl/certs/dhparam.pem;
    resolver 8.8.8.8;

    location ~ ^/index\.php(.*)$ {
        # fastcgi_pass 127.0.0.1:9000;
        fastcgi_pass unix:/run/php/php8.1-fpm.sock; # Depends On The PHP Version
        fastcgi_index index.php;
        # try_files $uri =404;
        # fastcgi_split_path_info ^(.+\.php)(/.+)$;
        include fastcgi_params;
        fastcgi_param SCRIPT_FILENAME /usr/share/icingaweb2/public/index.php;
        fastcgi_param ICINGAWEB_CONFIGDIR /etc/icingaweb2;
        fastcgi_param REMOTE_USER $remote_user;
    }

    location ~ ^/(.*)? {
        alias /usr/share/icingaweb2/public;
        index index.php;
        rewrite ^/$ /dashboard;
        try_files $1 $uri $uri/ /index.php$is_args$args;
    }

    location ~ \.php$ {
        return 404;
    }
}

# enforce HTTPS
server {
    listen       80;
    listen       [::]:80;
    server_name  icinga.example.com;
    return 301   https://$host$request_uri;
}

Nginx構成で使用されるルートディレクトリは/usr/share/icingaweb2/publicであることに注意してください。

ファイルを保存するには、Ctrl + Xを押し、プロンプトが表示されたらYを入力します。

/etc/nginx/nginx.confファイルを開きます。

$ sudo nano /etc/nginx/nginx.conf

include /etc/nginx/conf.d/*.conf;の前に次の行を追加します。

server_names_hash_bucket_size  64;

ファイルを保存するには、Ctrl + Xを押し、プロンプトが表示されたらYを入力します。

Nginx構成ファイルの構文を確認します。

$ sudo nginx -t
nginx: the configuration file /etc/nginx/nginx.conf syntax is ok
nginx: configuration file /etc/nginx/nginx.conf test is successful

Nginxサービスを再起動します。

$ sudo systemctl restart nginx

ステップ10 - ウェブセットアップを準備する

Icinga Webにアクセスする前に、セットアップを行う必要があります。Icinga Webを使用する場合、トークンを使用して認証する必要があります。次のコマンドを使用してトークンを生成します。

$ sudo icingacli setup token create
新しく生成されたセットアップトークンは:3c4d4e155635f512

後で必要になるため、トークンをメモしておいてください。次のコマンドを使用して、後でいつでも取得できます。

$ sudo icingacli setup token show
現在のセットアップトークンは:3c4d4e155635f512

次のステップは、データベースとデータベースユーザーを作成することです。MySQLシェルにログインします。

$ sudo mysql -u root -p

Icinga Webデータベースを作成します。

mysql> CREATE DATABASE icingaweb2;

Icinga Web用のSQLユーザーアカウントを作成します。

mysql> CREATE USER 'icingaweb2'@'localhost' IDENTIFIED BY 'Your_password3';

ユーザーにデータベースへのすべての特権を付与します。

mysql> GRANT ALL PRIVILEGES ON icingaweb2.* TO 'icingaweb2'@'localhost';

ユーザー特権をフラッシュします。

mysql> FLUSH PRIVILEGES;

シェルを終了します。

mysql> exit

ステップ11 - IcingaWebをセットアップする

ブラウザでURL https://icinga.example.comを開くと、次の画面が表示されます。

Icinga Webセットアップページ

前のステップで生成したトークンを入力し、次へボタンを押して続行します。

Icingaモジュールセットアップ

次の画面で、インストールしたいモジュールを選択し、次へをクリックして続行します。監視モジュールはデフォルトで選択されています。次のページでは、要件が表示され、それが満たされているかどうかが示されます。すべての要件が緑色にマークされていることを確認してください。

Icinga要件ページ

次へをクリックして次のページに進み、認証タイプを選択します。

Icinga認証タイプ

認証タイプはデフォルトでデータベースに設定されています。次へをクリックして続行します。次のページでは、データベースの資格情報を入力するように求められます。

Icinga Webデータベース資格情報

ステップ10で作成したデータベースの資格情報を入力します。構成を検証ボタンをクリックして資格情報を確認します。確認が完了したら、次へをクリックして続行します。次に、認証バックエンドの名前を付けるように求められます。

Icinga認証バックエンド

デフォルト値のままにして次へをクリックして続行します。次のページでは、管理者アカウントを作成するように求められます。

Icinga管理者詳細

新しい管理者アカウントの資格情報を入力し、次へをクリックして続行します。次に、アプリケーション構成ページが表示されます。

Icingaアプリケーション構成

アプリケーションおよびログ構成のすべてのデフォルト値をそのままにして、次へをクリックして続行します。最後のページで構成を確認するように求められます。

Icinga構成の確認

設定を変更するために戻ることができます。満足したら、次へをクリックして続行します。

次へをクリックして監視モジュールの構成を続行します。次に、Icingaデータベースの資格情報を尋ねられます。

Icingaデータベース資格情報

ステップ3でのデータベース資格情報を入力し、構成を検証をクリックして接続を確認します。確認が完了したら、次へをクリックして続行します。次に、APIの詳細を入力するように求められます。

Icinga API詳細

ステップ6で作成したAPI資格情報を入力し、構成を検証をクリックして接続を確認します。次へをクリックして続行します。次に、監視セキュリティのための保護されたカスタム変数を選択するように求められます。

Icinga監視セキュリティ

デフォルト値のままにして次へをクリックして続行します。次に、監視構成を確認するように求められます。必要に応じて変更できます。

Icinga監視構成の確認

満足したら、完了をクリックしてインストールを完了します。

Icingaインストール完了

正常に完了したら、Icinga Web 2にログインボタンをクリックしてログインページを開きます。

Icinga Webログインページ

管理者アカウントの詳細を入力し、ログインボタンをクリックしてIcinga Webダッシュボードを開きます。

Icinga Webダッシュボード

概要 >> サービスページに移動して、マスターサーバーの状態を確認します。

Icinga Webサービスページ

ステップ12 - マスターサーバーを初期化する

次のステップは、マスターサーバーをマスターノードとして初期化することです。マスターノードは監視スタックのメインコントローラーとして機能します。次のコマンドを実行して初期化プロセスを開始します。

$ sudo icinga2 node wizard

エージェントセットアップかどうかを尋ねられます。nを入力してマスターノードを設定します。

Welcome to the Icinga 2 Setup Wizard!

We will guide you through all required configuration details.

Please specify if this is an agent/satellite setup ('n' installs a master setup) [Y/n]: n

次に、共通名またはドメイン名を尋ねられます。表示されているデフォルト値を選択するにはEnterを押します。

Please specify the common name (CN) [icinga.example.com]:
Reconfiguring Icinga...
Checking for existing certificates for common name 'icinga.example.com'...
Certificate '/var/lib/icinga2/certs//icinga.example.com.crt' for CN 'icinga.example.com' already existing. Skipping certificate generation.
Generating master configuration for Icinga 2.
'api' feature already enabled.

次に、マスターゾーン名を入力し、Enterを押して続行します。この場合、サーバーのドメイン名と同じです。

Master zone name [master]: icinga.example.com

次に、追加のグローバルゾーンを追加するかどうかを尋ねられます。追加せずにEnterを押して続行します。

Default global zones: global-templates director-global
Do you want to specify additional global zones? [y/N]: n

次のステップでは、APIバインドホストとポートをデフォルトのままにしてEnterを押して続行します。

Please specify the API bind host/port (optional):
Bind Host []:
Bind Port []:

次に、/etc/icinga2/conf.d/ディレクトリ内の構成を無効にするためにYを押します。後でIcinga2ゾーン構成を使用します。

Do you want to disable the inclusion of the conf.d directory [Y/n]: Y
Disabling the inclusion of the conf.d directory...
Checking if the api-users.conf file exists...

Done.

Now restart your Icinga 2 daemon to finish the installation!

変更を適用するためにサービスを再起動します。

$ sudo systemctl restart icinga2

最後に、次のコマンドを実行してクライアントサーバーのチケットを作成します。引数としてクライアントのドメイン名を使用します。

$ sudo icinga2 pki ticket --cn 'client.example.com'
365cd931d3091537622a95b113b17775893a224f

後で使用するためにチケットをメモしておきます。

ステップ13 - クライアントサーバーでIcinga2エージェントを初期化する

クライアントサーバーにログインし、Icinga2と監視プラグインをインストールします。次のコマンドを実行します。

$ wget -O - https://packages.icinga.com/icinga.key | sudo gpg --dearmor -o /usr/share/keyrings/icinga-archive-keyring.gpg
$ echo "deb [signed-by=/usr/share/keyrings/icinga-archive-keyring.gpg] https://packages.icinga.com/ubuntu icinga-`lsb_release -cs` main" | sudo tee /etc/apt/sources.list.d/$(lsb_release -cs)-icinga.list
$ echo "deb-src [signed-by=/usr/share/keyrings/icinga-archive-keyring.gpg] http://packages.icinga.com/ubuntu icinga-`lsb_release -cs` main" | sudo tee -a /etc/apt/sources.list.d/$(lsb_release -cs)-icinga.list
$ sudo apt update
$ sudo apt install icinga2 monitoring-plugins -y

Icingaサービスが有効で実行中であることを確認します。

$ sudo systemctl status icinga2
? icinga2.service - Icinga host/service/network monitoring system
     Loaded: loaded (/lib/systemd/system/icinga2.service; enabled; vendor preset: enabled)
    Drop-In: /etc/systemd/system/icinga2.service.d
             ??limits.conf
     Active: active (running) since Tue 2023-05-02 07:32:07 UTC; 59min ago
   Main PID: 7602 (icinga2)
     Status: "Startup finished."
      Tasks: 8
     Memory: 13.9M
        CPU: 1.018s
     CGroup: /system.slice/icinga2.service
             ??7602 /usr/lib/x86_64-linux-gnu/icinga2/sbin/icinga2 --no-stack-rlimit daemon --close-stdio -e /var/log/icinga2/error.log
             ??7620 /usr/lib/x86_64-linux-gnu/icinga2/sbin/icinga2 --no-stack-rlimit daemon --close-stdio -e /var/log/icinga2/error.log
             ??7623 /usr/lib/x86_64-linux-gnu/icinga2/sbin/icinga2 --no-stack-rlimit daemon --close-stdio -e /var/log/icinga2/error.log

クライアントサーバーでエージェントを初期化するためにIcinga Node Wizardを開始します。

$ sudo icinga2 node wizard

エージェントセットアップかどうかを尋ねられます。Yを入力してエージェントを設定します。

Welcome to the Icinga 2 Setup Wizard!

We will guide you through all required configuration details.

Please specify if this is an agent/satellite setup ('n' installs a master setup) [Y/n]: Y

次に、共通名を指定するように求められます。デフォルト値のままにしてEnterを押して続行します。

Starting the Agent/Satellite setup routine...

Please specify the common name (CN) [client.example.com]:

次に、親エンドポイントをicinga.example.comとして指定し、クライアントから親ノードへの接続を確立するためにYを入力します。

Please specify the parent endpoint(s) (master or satellite) where this node should connect to:
Master/Satellite Common Name (CN from your master/satellite node): icinga.example.com

Do you want to establish a connection to the parent node from this node? [Y/n]: Y

次に、マスターサーバーのIPアドレスを入力し、ポート値はデフォルトのままにします。

Please specify the master/satellite connection information:
Master/Satellite endpoint host (IP address or FQDN): 199.247.31.184
Master/Satellite endpoint port [5665]:

追加のマスターエンドポイントを追加することを拒否するためにNを入力します。

Add more master/satellite endpoints? [y/N]: N

次に、マスターサーバーの証明書情報が表示されます。情報を確認するためにYを押して続行します。

Parent certificate information:

 Version:             3
 Subject:             CN = icinga.example.com
 Issuer:              CN = Icinga CA
 Valid From:          May  1 08:28:26 2023 GMT
 Valid Until:         Jun  1 08:28:26 2024 GMT
 Serial:              53:50:d4:1a:85:c5:70:5b:b1:f6:0e:c3:b6:e4:db:62:df:8d:5e:d9

 Signature Algorithm: sha256WithRSAEncryption
 Subject Alt Names:   icinga.example.com
 Fingerprint:         DC BB 90 68 29 E5 C4 B5 74 F5 BC 8C BF A1 8F BF D2 9D A4 E5 A9 9A 43 2C 3B 24 AE A9 CD 19 32 F4

Is this information correct? [y/N]: Y

次に、前のステップで生成されたリクエストチケットを入力します。

Please specify the request ticket generated on your Icinga 2 master (optional).
 (Hint: # icinga2 pki ticket --cn 'client.example.com'): 365cd931d3091537622a95b113b17775893a224f

APIバインドホストとポートはデフォルトのままにしてEnterを押して続行します。

Please specify the API bind host/port (optional):
Bind Host []:
Bind Port []:

次に、マスターノードからの構成とコマンドを受け入れるためにYを2回入力します。

Accept config from parent node? [y/N]: Y
Accept commands from parent node? [y/N]: Y

デフォルトのローカルゾーン名(クライアントのドメイン名)を受け入れるためにEnterを押します。親ゾーン名としてマスタードメイン名を入力して続行します。

Reconfiguring Icinga...
Disabling feature notification. Make sure to restart Icinga 2 for these changes to take effect.
Enabling feature api. Make sure to restart Icinga 2 for these changes to take effect.

Local zone name [client.example.com]:
Parent zone name [master]: icinga.example.com

追加のグローバルゾーンを追加することを拒否するためにNを入力します。

Default global zones: global-templates director-global
Do you want to specify additional global zones? [y/N]: N

/etc/icinga2/conf.d/ディレクトリからの構成を無効にすることを拒否するためにYを入力します。

Do you want to disable the inclusion of the conf.d directory [Y/n]: Y
Disabling the inclusion of the conf.d directory...

Done.

Now restart your Icinga 2 daemon to finish the installation!

構成変更を適用するためにIcingaサービスを再起動します。

$ sudo systemctl restart icinga2

ステップ14 - マスターサーバーでゾーン構成を作成する

サーバーに再度ログインし、デフォルトゾーンとして新しいディレクトリを作成します。

$ sudo mkdir -p /etc/icinga2/zones.d/icinga.example.com/

次に、新しく作成したディレクトリに構成ファイルを作成し、編集のために開きます。

$ sudo nano /etc/icinga2/zones.d/icinga.example.com/client.example.com.conf

以下のコードを貼り付けます。コード内のIPアドレスは、クライアントのパブリックIPアドレスと一致する必要があります。

// Endpoints object Endpoint "client.example.com" { } // Zones object Zone "client.example.com" { endpoints = [ "client.example.com" ] parent = "icinga.example.com" } // Host Objects object Host "client.example.com" { check_command = "hostalive" address = "95.179.138.148" vars.client_endpoint = name }

ファイルを保存するには、Ctrl + Xを押し、プロンプトが表示されたらYを入力します。

サービスファイルを作成して編集します。

$ sudo nano /etc/icinga2/zones.d/icinga.example.com/services.conf

以下のコードを貼り付けます。

// Ping apply Service "Ping" { check_command = "ping4" assign where host.address // check executed on master } // System Load apply Service "System Load" { check_command = "load" command_endpoint = host.vars.client_endpoint // Check executed on client01 assign where host.vars.client_endpoint } // SSH Service apply Service "SSH Service" { check_command = "ssh" command_endpoint = host.vars.client_endpoint assign where host.vars.client_endpoint } // Icinga 2 Service apply Service "Icinga2 Service" { check_command = "icinga" command_endpoint = host.vars.client_endpoint assign where host.vars.client_endpoint }

次のコマンドを実行して構成を検証します。

$ sudo icinga2 daemon -C

次のような出力が得られます。

[2023-05-02 11:21:23 +0000] information/cli: Icinga application loader (version: r2.13.7-1)
[2023-05-02 11:21:23 +0000] information/cli: Loading configuration file(s).
[2023-05-02 11:21:23 +0000] information/ConfigItem: Committing config item(s).
[2023-05-02 11:21:23 +0000] information/ApiListener: My API identity: icinga.example.com
[2023-05-02 11:21:23 +0000] information/ConfigItem: Instantiated 1 IcingaApplication.
[2023-05-02 11:21:23 +0000] information/ConfigItem: Instantiated 1 Host.
[2023-05-02 11:21:23 +0000] information/ConfigItem: Instantiated 1 FileLogger.
[2023-05-02 11:21:23 +0000] information/ConfigItem: Instantiated 1 IdoMysqlConnection.
[2023-05-02 11:21:23 +0000] information/ConfigItem: Instantiated 1 CheckerComponent.
[2023-05-02 11:21:23 +0000] information/ConfigItem: Instantiated 4 Zones.
[2023-05-02 11:21:23 +0000] information/ConfigItem: Instantiated 2 Endpoints.
[2023-05-02 11:21:23 +0000] information/ConfigItem: Instantiated 2 ApiUsers.
[2023-05-02 11:21:23 +0000] information/ConfigItem: Instantiated 1 ApiListener.
[2023-05-02 11:21:23 +0000] information/ConfigItem: Instantiated 1 NotificationComponent.
[2023-05-02 11:21:23 +0000] information/ConfigItem: Instantiated 244 CheckCommands.
[2023-05-02 11:21:23 +0000] information/ConfigItem: Instantiated 4 Services.
[2023-05-02 11:21:23 +0000] information/ScriptGlobal: Dumping variables to file '/var/cache/icinga2/icinga2.vars'
[2023-05-02 11:21:23 +0000] information/cli: Finished validating the configuration file(s).

Icingaサービスを再起動して構成変更を適用します。

$ sudo systemctl restart icinga2

ステップ15 - Icingaダッシュボードで確認する

Icinga2 Webダッシュボードを開いてクライアントマシンの情報を確認します。左側のメニューから概要 >> ホストを選択すると、次の画面が表示されます。

Icinga Webダッシュボードホストページ

クライアントの状態がUPとして表示されるまでに時間がかかる場合があります。クライアントをクリックして詳細を確認します。概要 >> サービスを選択すると、クライアントに関する次の状態が表示されます。

Icinga Webクライアントサービスの詳細

これにより、クライアントがIcingaマスターサーバーに正しく統計を送信していることが確認されます。

結論

これで、Ubuntu 22.04サーバーにIcinga監視ソフトウェアをインストールし、同じオペレーティングシステムを実行しているクライアントマシンを監視するように構成するチュートリアルが終了します。質問がある場合は、下のコメントに投稿してください。

Share: X/Twitter LinkedIn

新しい投稿を受信箱で受け取る

スパムはありません。いつでも購読を解除できます。