Icinga(アイシンガ)は「Nagios」から派生して開発され、CPU、メモリ、ディスク使用量や、Ping、HTTP、DNSなどのネットワークサービスを監視するためのオープンソースのITインフラストラクチャ監視ツールです
1.前提条件
Icinga2 をインストールするための要件として、LAMP がインストールされている必要があります。またPHP 7.3 以降のバージョンが必要です。
今回は下記が構築されていることを前提とします
MySQL 8.4.11
PHP 8.3.33
Apache(HTTPD) 2.4.68
2. Icinga2 をインストール
# pkg update
# pkg upgrade -y
# pkg install -y icinga2
Icinga2有効化と起動
# sysrc icinga2_enable="YES"
# service icinga2 start
# service icinga2 status
icinga2 is running as pid 2212.
3. ファイアウォールでポート開放
IpfwでIcingaポート5665を開放
# vi /usr/local/etc/ipfw.rules
xxxは他と重ならないようにして、下記を追加
$IPF xxx allow tcp from any to any 5665 in
$IPF xxx allow tcp from any to any 5665 out
# service ipfw restart
Firewall rules loaded.
4. モニタリングプラグインをインストール
# pkg install monitoring-plugins
プラグインは/usr/local/libexec/nagios/ に保存され、プラグインが正常にインストールされたかどうかは、ディレクトリの内容を一覧
# ls /usr/local/libexec/nagios/
check_apt check_icmp check_nntps check_ssh
check_breeze check_ifoperstatus check_nscp_api check_ssmtp
check_by_ssh check_ifstatus check_ntp_peer check_swap
check_clamd check_imap check_ntp_time check_tcp
check_cluster check_ircd check_oracle check_time
check_dhcp check_jabber check_ping check_udp
check_dig check_load check_pop check_ups
check_disk check_log check_procs check_uptime
check_disk_smb check_mailq check_real check_users
check_dummy check_mrtg check_rpc check_wave
check_file_age check_mrtgtraf check_sensors negate
check_flexlm check_mssql check_simap urlize
check_ftp check_nagios check_smtp utils.pm
check_http check_nntp check_spop utils.sh
5. インストール済みのバージョンを確認
# icinga2 --version
icinga2 - The Icinga 2 network monitoring daemon (version: r2.16.3-1)
Copyright (c) 2012-2026 Icinga GmbH (https://icinga.com/)
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl-3.0.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
System information:
Platform: FreeBSD
Platform version: 15.1-RELEASE-p3
Kernel: FreeBSD
Kernel version: 15.1-RELEASE-p3
Architecture: amd64
Build information:
Compiler: Clang 19.1.7
Build host: 150amd64-quarterly-job-04
OpenSSL version: OpenSSL 3.5.6 7 Apr 2026
Application information:
General paths:
Config directory: /usr/local/etc/icinga2
Data directory: /var/lib/icinga2
Log directory: /var/log/icinga2
Cache directory: /var/cache/icinga2
Spool directory: /var/spool/icinga2
Run directory: /var/run/icinga2
Old paths (deprecated):
Installation root: /usr/local
Sysconf directory: /usr/local/etc
Run directory (base): /var/run
Local state directory: /var
Internal paths:
Package data directory: /usr/local/share/icinga2
State path: /var/lib/icinga2/icinga2.state
Modified attributes path: /var/lib/icinga2/modified-attributes.conf
Objects path: /var/cache/icinga2/icinga2.debug
Vars path: /var/cache/icinga2/icinga2.vars
PID path: /var/run/icinga2/icinga2.pid
6. Icinga 2 APIを有効にする
# 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//lepard.csr'.
information/base: Writing private key to '/var/lib/icinga2/certs//lepard.key'.
information/base: Writing certificate signing request to '/var/lib/icinga2/certs//lepard.csr'.
information/cli: Signing CSR with CA and writing certificate to '/var/lib/icinga2/certs//lepard.crt'.
information/pki: Writing certificate to file '/var/lib/icinga2/certs//lepard.crt'.
information/cli: Copying CA certificate to '/var/lib/icinga2/certs//ca.crt'.
information/cli: Adding new ApiUser 'root' in '/usr/local/etc/icinga2/conf.d/api-users.conf'.
information/cli: Reading '/usr/local/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 '/usr/local/etc/icinga2/constants.conf'.
information/cli: Created backup file '/usr/local/etc/icinga2/constants.conf.orig'.
information/cli: Updating 'ZoneName' constant in '/usr/local/etc/icinga2/constants.conf'.
information/cli: Backup file '/usr/local/etc/icinga2/constants.conf.orig' already exists. Skipping backup.
Done.
Now restart your Icinga 2 daemon to finish the installation!
Icinga 2デーモンを再起動
# service icinga2 restart
Icinga 2 APIはTCPポート5665で受信しているので、サービスが接続を受け入れているか確認
# sockstat -l | grep :5665
icinga icinga2 3138 18 tcp46 *:5665 *:*
7. MySQL/MariaDB の設定
Icinga2はデータバックエンドとしてIcingaDBを使用しており、IcingaDBにはMySQLまたはMariaDBが必要です。
今回はMySQL として進めます。
次の2つのデータベースとユーザーを作成する
IcingaDBデータベースとユーザー:
データベース名 : icingadb
ユーザ名 : icingauser
パスワード : ?Ww123456
Icingaweb2データベースとユーザー:
データベース名 : icingaweb2db
ユーザ名 : icingaweb2user
パスワード : ?Yy123456
# mysql -u root -p
> CREATE DATABASE icingadb;
> CREATE USER 'icingauser'@'localhost' IDENTIFIED BY '?Ww123456';
> GRANT ALL ON icingadb.* TO 'icingauser'@'localhost';
> CREATE DATABASE icingaweb2db;
> CREATE USER 'icingaweb2user'@'localhost' IDENTIFIED BY '?Yy123456';
> GRANT ALL ON icingaweb2db.* TO 'icingaweb2user'@'localhost';
> FLUSH PRIVILEGES;
> exit;
8. IcingaDBとRedisをインストール
①インストール
# pkg install net-mgmt/icingadb databases/redis
➁Redisの設定
# vi /usr/local/etc/redis.conf
139行目当たり
port 6380
Redisサービスの有効化と起動
# sysrc redis_enable="YES"
# service redis start
➂先ほど作成したデータベースに、IcingaDBデータベーススキーマをインポートする
# mysql -u root -p icingadb < /usr/local/share/examples/icingadb/schema/mysql/schema.sql
④IcingaDBの設定を編集して、データベースの認証情報を設定する
# vi /usr/local/etc/icingadb/config.yml
6行目以降database:項目の内容を次のようにする
database:
type: mysql
host: localhost
port: 3306
database: icingadb
user: icingauser
password: ?Ww123456
64行目 Redis接続設定項目を編集
redis:
host: "localhost"
port: 6380
# vi /usr/local/etc/icinga2/features-available/icingadb.conf
下記の通り設定
object IcingaDB "icingadb" {
host = "127.0.0.1"
port = 6380
//password = "xxx"
}
⑤Icinga DBの設定と有効化
# sysrc icingadb_enable="YES"
# service icingadb start
⑥Icinga 2側の設定
Icinga 2本体側でIcinga DB機能(feature)を有効にする必要があります。
# icinga2 feature enable icingadb
# service icinga2 restart
9. Icinga Web 2をインストール
Icinga Webは、監視データの表示、設定の管理、アラートの処理を行うためのWebベースのフロントエンドです。IcingaDB WebモジュールとApacheと一緒にインストールしてください。
Icinga Web 2 と必要な PHP エクステンション、Web サーバーをインストールします
# pkg install mod_php83 php83-mysqli php83-gettext php83-intl php83-mbstring php83-xml php83-curl php83-gd php83-ldap icingaweb2-php83
# pkg install icingaweb2-php83
# pkg install icingaweb2-module-icingadb-php83
# pkg install php83-filter
icingacli を使って、Apache用の設定ファイルを自動生成する
# icingacli setup config webserver apache > /usr/local/etc/apache24/Includes/icingaweb2.conf
mod_rewrite モジュールを有効
# vi /usr/local/etc/apache24/httpd.conf
181行目あたり : コメント解除
LoadModule rewrite_module libexec/apache24/mod_rewrite.so
Apacheとphp-fpm再起動
# service apache24 restart
# service php_fpm restart
10. Icinga Web 2セットアップウィザードを実行
10.1 ウェブセットアップウィザード用の認証トークンを生成する
# icingacli setup token create
The newly generated setup token is: 7bbef81db5c239cc
# chown -R root:www /usr/local/etc/icingaweb2
# chmod 2770 /usr/local/etc/icingaweb2
# chmod 640 /usr/local/etc/icingaweb2/setup.token
10.2 ブラウザを開き、以下のセットアップウィザードにアクセスする
http://[server IP]/icingaweb2/setup
①作成したトークンを入力して「Next」をクリック

➁IcingadbがONになっていることを確認し、「Next」をクリック

➂PHP構成要件画面が表示される
下図のようにThe PHP module Imagick is missing.が表示される場合は下記をインストールしてApacheを再起動する

# pkg install php83-pecl-imagick
ApacheとPHPを再起動
# service apache24 restart
# service php_fpm restart
PHP モジュール、ライブラリ、ディレクトリなどの PHP 前提条件がすべて満たされていることを確認します。すべて問題がなければ、下にスクロールして [Next] をクリック


④認証タイプを「Database」にして「Next」をクリック

⑤データベースリソース
以下の画面が表示されるので、icingaweb2 用のデータベース名、ユーザ名、パスワードを入力する。
確認のため、"Validate Configuration"をクリック

間違いがなければ下図のように"The configuration has been successfuly validated."と表示されのでNextをクリック

⑥バックエンド
Nextをクリック

⑦Icinga Web2用の管理者アカウントの作成
Icinga Web2にアクセスするためのユーザおよびパスワードを設定し「Next」をクリック
今回はユーザー名をadminとしている

⑧アプリケーション設定
以下の画面が表示される。変更がなければ「Next」をクリック

⑨設定完了画面
以下の画面が表示される。設定が正しければ「Next」をクリック

⑩Icinga DB Webの設定
「Next」をクリック

icinga 用のデータベース名・ユーザ名・パスワードを入力する。入力が終わったら"Validate Configuration"をクリックして検証する。

間違いがなければ下図のように"The configuration has been successfuly validated."と表示されのでNextをクリック

⑪Redisの設定
Redisのセットアップページが表示されます。Redis Hostはlocalhostにして、 Nextをクリック

⑫Icinga2 APi の設定
Host => localhost
Port => 5665

Api Username 及び Api Passwordは下記ファイル中を確認する
# vi /usr/local/etc/icinga2/conf.d/api-users.conf
object ApiUser "root" {
password = "a721e6d0d0ccbce6"
入力後Nextをクリックすると概要ページに入りますので、Finishをクリック

設定がすべて正常に完了しましたので"Login to Icinga Web 2"をクリック

icingadbを再起動
# systemctl restart icingadb
⑬IcingaDB-Web ログイン画面
先ほど作成したIcinga Web にログインするためアカウント情報を入力し、ログインする


11. Icinga Directorをインストール
Icinga Directorは、Webベースの設定モジュールであり、設定ファイルを手動で編集する代わりに、Icinga Webインターフェースを通じてホスト、サービス、テンプレートを管理できます
11.1 Directorパッケージをインストール
# pkg install icingaweb2-module-director-php83
11.2 Director専用のデータベースを作成
Directorデータベース : directordb
Directorユーザー : directoruser
パスワード : ?Xx123456
# mysql -u root -p
> CREATE DATABASE directordb ;
> CREATE USER 'directoruser'@'localhost' IDENTIFIED BY '?Xx123456';
> GRANT ALL ON directordb.* TO 'directoruser'@'localhost';
> FLUSH PRIVILEGES;
> EXIT;
データベースに、Icingadirectorデータベーススキーマをインポートする
# mysql -u root -p icingadb < /usr/local/www/icingaweb2/modules/director/schema/mysql.sql
icinga-director.service を有効化
# sysrc icinga_director_enable="YES"
# service icinga-director start
incubator モジュールを有効化
# icingacli module enable incubator
hostsファイルの編集
# vi /etc/hosts
下記記入
192.168.11.83 lepard ←ホスト名
11.3 Icinga Web 2画面でIcinga director有効化
Icinga Web 2 にログインし、左下の鍵マークをクリックし[Modules][director]を選択し、右ペインのリフレッシュマークをクリックする

すると以下のように画面左に「Icinga director」が追加される。

11.4 リソースの登録
画面左ペインの右下の鍵マークをクリックし、「Configration」の「Application」を選択する。

ここで、「Resources」タブをクリックする。

この画面の「Create a New Resource 」をクリックする。

「リソースの種類」で “SQL Database” を選択、「Resource Nmae」に “director”、「Database Type」に “MySQL” を指定、「Database Name」、「Username」、「Password」に先ほど director 用に作成したデータベースのものを入力、「文字コード」には “utf8” を指定する。
「Validate Configuration」をクリックして問題なければ「Save Changes」をクリックする。


画面左ペインの「Icinga Director」をクリック
なぜかIcinga directorだけ日本語になっている

「DB リソース」で “director” を選択

すると次の画面に自動的に切り替わる。

上記画面で「スキーマの作成」をクリックするとしばらく時間が経過したのち以下の「キックスタートウィザード」画面になる。
キックスタートウィザード画面
エンドポイント名 : # hostname -f で確認
Icinga ホスト : サーバの IP アドレス
API ユーザー , パスワード : icinga api ユーザのユーザ名とパスワード

入力が終わったら「インポートを実行」をクリックする。
12. Icinga Directorで監視サービスの追加
12.1 サービステンプレートの作成
Icinga Director を使用して、今回はSSH、HTTP、PINGを監視するためのテンプレートを作成します。
「サービス」をクリックし、ページ上の「サービステンプレート」をクリック。

新しいサービステンプレートを作成するには、「+追加A」ボタンをクリックします。

SSH サービスの監視に関する詳細を入力し、[追加]ボタンをクリック

同様にPING,HTTPサービスの監視に関する詳細を入力


12.2 サービスセットを作成し、サービステンプレートを追加する
作成したサービステンプレートをを1つのサービスセットにまとめます。
「サービス」ページで、「サービスセット」をクリック

「+追加」ボタンをクリック

「サービスセット名」と「説明」に独自の名前と内容を入力し、「追加」ボタンをクリック

「basic service Linux」という名前のサービスセットが作成されました。

次に、サービステンプレートを「basic service Linux」サービスセットに追加します。サービスセットの名前をクリックし、右側の画面にある「Services」タブをクリック

「+サービスを追加」ボタンをクリック

[Check_ssh]を追加する
「追加」ボタンをクリック

同様に[Check_ping][Check_http]を追加する


最終的に"3 人のメンバー"になっている

12.3 ホストテンプレートを作成し、サービスセットを追加する
Director を通じて Icinga2 に新しいホストを追加するには、ホストテンプレートを作成する必要があります
Icinga Director のメニューで、「ホスト」と「ホストテンプレート」の順にクリック

「+追加」ボタンをクリック

「ホストテンプレート」に関する詳細を、以下のように入力してください。
監視コマンド : hostalive

もう一度「追加」ボタンをクリックすると、「basic Linux」という名前のホストテンプレートが作成されます。

次に、ホストテンプレートに「basic services Linux」という名前のサービスセットを追加します。
ホストテンプレート名をクリックし、右側の画面にある「サービス」タブをクリックします。

「サービスセットを追加」ボタンをクリックします

「basic service Linux」という名前のサービスセットを選択し、「追加」をクリックします。

サービスセットが追加されたホストテンプレートが作成されました。これで、Icinga2に新しいホストを追加する準備が整いました。

13. Icinga Directorで監視ホストの追加
ホスト名「Lion」(hostname -fで確認)、IPアドレス「192.168.11.85」を持つFreeBSD14を追加します。
Icinga2のダッシュボードで、「Icinga director」メニューをクリックし、「ホスト」→[ホスト]をクリック

画面右側の「追加」ボタンをクリック

「basic Linux」ホストテンプレートを選択し、下記の通り詳細なホスト設定を入力し、「追加」ボタンをクリック

「Lion」ホストがIcinga2に追加されました。

左側の「アクティビティログ」メニューをクリックし、「xxx 個の保留された変更を反映」をクリックして設定を適用します。

14. 監視対象サーバー(エージェント)側の設定手順
監視対象サーバーFreeBSD14(IP : 192.168.11.85)で作業する
14.1 Icinga2 をインストール
# pkg install -y icinga2
Icinga2有効化と起動
# sysrc icinga2_enable="YES"
# service icinga2 start
# service icinga2 status
icinga2 is running as pid 1477.
14.2 ファイアウォール設定
IpfwでIcingaポート5665を開放
# vi /usr/local/etc/ipfw.rules
xxxは他と重ならないようにして、下記を追加
$IPF xxx allow tcp from any to any 5665 in
$IPF xxx allow tcp from any to any 5665 out
# service ipfw restart
Firewall rules loaded.
14.3 モニタリングプラグインをインストール
# pkg install monitoring-plugins
プラグインは/usr/local/libexec/nagios/ に保存され、プラグインが正常にインストールされたかどうかは、ディレクトリの内容を一覧
# ls /usr/local/libexec/nagios/
check_apt check_icmp check_nntps check_ssh
check_breeze check_ifoperstatus check_nscp_api check_ssmtp
check_by_ssh check_ifstatus check_ntp_peer check_swap
check_clamd check_imap check_ntp_time check_tcp
check_cluster check_ircd check_oracle check_time
check_dhcp check_jabber check_ping check_udp
check_dig check_load check_pop check_ups
check_disk check_log check_procs check_uptime
check_disk_smb check_mailq check_real check_users
check_dummy check_mrtg check_rpc check_wave
check_file_age check_mrtgtraf check_sensors negate
check_flexlm check_mssql check_simap urlize
check_ftp check_nagios check_smtp utils.pm
check_http check_nntp check_spop utils.sh
14.4 インストール済みのバージョンを確認
# icinga2 --version
icinga2 - The Icinga 2 network monitoring daemon (version: r2.16.3-1)
Copyright (c) 2012-2026 Icinga GmbH (https://icinga.com/)
License GPLv3+: GNU GPL version 3 or later <https://gnu.org/licenses/gpl-3.0.html>
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
System information:
Platform: FreeBSD
Platform version: 14.3-RELEASE-p16
Kernel: FreeBSD
Kernel version: 14.3-RELEASE-p16
Architecture: amd64
Build information:
Compiler: Clang 19.1.7
Build host: 144amd64-quarterly-job-24
OpenSSL version: OpenSSL 3.0.20 7 Apr 2026
Application information:
General paths:
Config directory: /usr/local/etc/icinga2
Data directory: /var/lib/icinga2
Log directory: /var/log/icinga2
Cache directory: /var/cache/icinga2
Spool directory: /var/spool/icinga2
Run directory: /var/run/icinga2
Old paths (deprecated):
Installation root: /usr/local
Sysconf directory: /usr/local/etc
Run directory (base): /var/run
Local state directory: /var
Internal paths:
Package data directory: /usr/local/share/icinga2
State path: /var/lib/icinga2/icinga2.state
Modified attributes path: /var/lib/icinga2/modified-attributes.conf
Objects path: /var/cache/icinga2/icinga2.debug
Vars path: /var/cache/icinga2/icinga2.vars
PID path: /var/run/icinga2/icinga2.pid
14.5 hostsファイルの編集
# vi /etc/hosts
192.168.11.83 lepard
192.168.11.85 Lion
14.6 Agentを追加するためのPKIチケットの発行(Master側で実行)
# icinga2 pki ticket --cn 'Lion'
0cf1682f55272481d5634acf9b2b188ecdcebdb5
14.7 Agent (監視対象)での設定
# icinga2 node wizard
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
Starting the Agent/Satellite setup routine...
Please specify the common name (CN) [Lion]:
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): lepard
Do you want to establish a connection to the parent node from this node? [Y/n]: y
Please specify the master/satellite connection information:
Master/Satellite endpoint host (IP address or FQDN): 192.168.11.83
Master/Satellite endpoint port [5665]:
Add more master/satellite endpoints? [y/N]: N
Parent certificate information:
Version: 3
Subject: CN = lepard
Issuer: CN = Icinga CA
Valid From: Sep 6 09:33:09 2026 GMT
Valid Until: Oct 8 09:33:09 2027 GMT
Serial: ae:1c:cc:4c:2e:b9:a5:39:cb:b2:1f:25:ca:02:1e:3b:6b:89:7d:a6
Signature Algorithm: sha256WithRSAEncryption
Subject Alt Names: lepard
Fingerprint: 12 49 9E 72 FD D9 D1 7A C1 82 DA 68 EF 54 6E 3E C6 30 25 3A 20 17 65 FE 9A 48 52 C5 7B 58 51 90
Is this information correct? [y/N]: y
Please specify the request ticket generated on your Icinga 2 master (optional).
(Hint: # icinga2 pki ticket --cn 'Lion'): 0cf1682f55272481d5634acf9b2b188ecdcebdb5
Please specify the API bind host/port (optional):
Bind Host []: 0.0.0.0
Bind Port []: 5665
Accept config from parent node? [y/N]: y
Accept commands from parent node? [y/N]: y
Reconfiguring Icinga...
Local zone name [Lion]:
Parent zone name [master]:
Default global zones: global-templates director-global
Do you want to specify additional global zones? [y/N]: N
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を再起動
# service icinga2 restart
14.8 Icingaweb2画面で確認
Icinga2 Dashboard メニューの, 'Overview' 'Hosts'. をクリックするとIcinga2サーバーと「Lion」という2つのホストが表示され、クライアントが起動して実行されていることが確認できます。

「Lion」サーバーをクリックして詳細を表示

Lion ホストの監視対象サービスを確認するには、「Services」タブをクリックしてください。

