2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

7.4のオマケ?もう1つのエージェントインストール方法

Last updated at Posted at 2025-12-02

Zabbix Advent Calendar 3日目の _BSmile_です。

どうぞよろしくお願いします。

はじめに

タイトルを見て、「Zabbix 7.4にエージェントのインストーラなんてあったっけ?」と思われるかもしれません。それもそのはず、Zabbix 7.4の新機能「ホストウィザード」で登場したスクリプトですから。

ホストウィザードとは?

ホストの登録からホストに適用するテンプレートの適用など、ガイド付きでステップ実行することができる新しい機能です。このホストウィザードの中で、Zabbixエージェントをインストールするステップがあり、「次のスクリプト[root下のbash]を実行して、監視対象にZabbixエージェントを設定します。」というメッセージとともにスクリプトを実行してねの情報があります。
次の項目では、インストールスクリプトの中身を少しみてみましょう

Zabbixエージェントインストールスクリプト

コマンドの流れ

  1. wgetでスクリプトをダウンロード
  2. ダウンロードしたスクリプトに引数を指定し実行
    --server-host ... ZabbixサーバーのIP(Server & ServerActive)
    --hostname ... ホスト名(Hostname)
    --psk-identity ... 事前共有鍵(TLSPSKIdentity)
    --psk ... 秘密鍵(PSK有効化)
  3. systemdでZabbixエージェントのサービスを有効化

スクリプトの中身

wgetしているスクリプトは、Zabbix LLC社が提供するZabbixのソフトウェアを提供するサイト にあります。ここから、Zabbixのパッケージやソースなどがダウンロードできます。
※ Zabbixサーバーをインストールする Linux用のrpmパッケージは repo.zabbix.com にあります
🔗 リポジトリ

ファイルをダウンロードして、中身を見てみましょう。 冒頭に、「--help」を指定するとオプション一覧が出るみたいですね。

root@ubuntu-74:~# ./install-zabbix.sh --help
Usage:
    install-zabbix.sh (--install|--reinstall) [--agent|--agent2] [--version X.Y] [<configuration options>]
    install-zabbix.sh --configure [--agent|--agent2] [<configuration options>]
    install-zabbix.sh --uninstall [...]

Options:
    One of four modes can be selected --install, --reinstall, --configure, --uninstall
      --install             : Install Zabbix agent or agent 2 and write values to its configuration file.
                            : --install mode includes --configure mode.
      --uninstall           : Purge Zabbix from the system.
      --configure           : Write values to agent or agent 2 configuration files.
      --reinstall           : Combines --uninstall and --install options.
    Default mode is --install

    --agent | --agent2      : Select which Zabbix component to install.
    --version X.Y           : Select which Zabbix verion to install. Default 7.4

   <configuration options>:
      --server-host <str>   : Value for Server and ServerActive fields.
      --server-host-stdin   : Same as --server-host, but prompt for the key using stdin.
      --psk <key>           : Enable PSK encryption and setup the key.
      --psk-stdin           : Same as --psk, but prompt for the key using stdin.
      --psk-identity <str>  : PSK itentity to go with the PSK key.
      --psk-identity-stdin  : Same as --psk-identity, but prompt for the key using stdin.
      --hostname <str>      : Set Hostname value.
      --repo-url <URL>        : Override default repo url. Default: 

インストールモードは4つあります。

  • install ... Zabbixエージェント(エージェント2)をインストール
  • uninstall ... パッケージをアンインストール
  • configure ... confのオプションを更新
  • reinstall ... 再インストール

エージェントインストール

インストールだけ

手始めに、インストールだけをしてみましょう。

./install-zabbix.sh --install
--2025-12-02 01:20:34--  https://repo.zabbix.com/zabbix/7.4/release/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_7.4+ubuntu24.04_all.deb
Resolving repo.zabbix.com (repo.zabbix.com)... 178.128.6.101, 2604:a880:2:d0::2062:d001
Connecting to repo.zabbix.com (repo.zabbix.com)|178.128.6.101|:443... connected.
HTTP request sent, awaiting response... 200 OK
〜中略〜
Dec 02 01:21:21 ubuntu-74 systemd[1]: Started zabbix-agent2.service - Zabbix Agent 2.
Dec 02 01:21:21 ubuntu-74 zabbix_agent2[4869]: Starting Zabbix Agent 2 (7.4.5)
Dec 02 01:21:21 ubuntu-74 zabbix_agent2[4869]: Zabbix Agent2 hostname: [Zabbix server]
Dec 02 01:21:21 ubuntu-74 zabbix_agent2[4869]: Press Ctrl+C to exit.

無事にインストールが完了し、Zabbixエージェント2が起動しました。
どうやら、デフォルトはZabbixエージェント2がインストールされるようです。
しかしながら、インストールだけではZabbixサーバーと接続できません。zabbix_agent2.confの Server オプションが指定されてないですからね。

Zabbixサーバーを指定してインストール

zabbix_agent2.confのオプションは、--server-hostを指定するとServerServerActive--hostnameを指定するとHostnameが指定されます。 これらは必須ですね。 あと、1点気になるオプションが。

実は下位バージョンもインストールできる

--version X.Y

今日まで、7.4専用のインストーラーだと思っていたのですが違いました。
Ubuntuの場合は5.0のインストールもできます!

./install-zabbix.sh --install --agent --version 5.0 --server-host 192.168.11.188 --hostname Ubuntu
--2025-12-02 02:09:48--  https://repo.zabbix.com/zabbix/5.0/ubuntu/pool/main/z/zabbix-release/zabbix-release_latest_5.0+ubuntu24.04_all.deb
Resolving repo.zabbix.com (repo.zabbix.com)... 178.128.6.101, 2604:a880:2:d0::2062:d001
Connecting to repo.zabbix.com (repo.zabbix.com)|178.128.6.101|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 5480 (5.4K) [application/octet-stream]
Saving to: ‘zabbix-release_latest_5.0+ubuntu24.04_all.deb’

zabbix-release_latest_5.0+ubuntu24.04_all.deb              100%[======================================================================================================================================>]   5.35K  --.-KB/s    in 0s      

〜中略〜

● zabbix-agent.service - Zabbix Agent
     Loaded: loaded (/usr/lib/systemd/system/zabbix-agent.service; enabled; preset: enabled)
     Active: active (running) since Tue 2025-12-02 02:09:55 UTC; 652ms ago
   Main PID: 10456 (zabbix_agentd)
      Tasks: 6 (limit: 38135)
     Memory: 4.8M (peak: 5.5M)
        CPU: 19ms
     CGroup: /system.slice/zabbix-agent.service
             ├─10456 /usr/sbin/zabbix_agentd -c /etc/zabbix/zabbix_agentd.conf
             ├─10457 "/usr/sbin/zabbix_agentd: collector [idle 1 sec]"
             ├─10458 "/usr/sbin/zabbix_agentd: listener #1 [waiting for connection]"
             ├─10459 "/usr/sbin/zabbix_agentd: listener #2 [waiting for connection]"
             ├─10460 "/usr/sbin/zabbix_agentd: listener #3 [waiting for connection]"
             └─10461 "/usr/sbin/zabbix_agentd: active checks #1 [idle 1 sec]"

Dec 02 02:09:55 ubuntu-74 systemd[1]: Starting zabbix-agent.service - Zabbix Agent...
Dec 02 02:09:55 ubuntu-74 systemd[1]: Started zabbix-agent.service - Zabbix Agent.

現状、HTTPプロキシは無くインターネット接続が必要なスクリプトですが、リポジトリ参照先をローカルに変更することで対策可能かもしれません。

default_repo_url=https://repo.zabbix.com/zabbix

エージェントの自動インストールは、王道のAnsibleもありますがこういった手法の検討もご一緒にいかがですか?

2
1
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
2
1

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?