This is a translation of the original English documentation page. Help us make it better.

1 ZabbixエージェントでLinuxを監視する

はじめに

このページでは、Zabbix を使って Linux マシンの基本的な監視を開始するために必要な手順を順を追って説明します。 このチュートリアルで説明する手順は、あらゆる Linux ベースのオペレーティングシステムに適用できます。

このガイドの対象者

このガイドは、Zabbixを初めて使用するユーザー向けに設計されており、Linuxマシンの基本的な監視を有効にするために必要な最小限の手順が記載されています。詳細なカスタマイズオプションや、より高度な設定が必要な場合は、Zabbixマニュアルの設定セクションを参照してください。

前提条件

このガイドを進める前に、お使いのOSの手順に従って、ZabbixサーバーとZabbixフロントエンドをダウンロードしてインストールする必要があります。

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

Zabbix エージェントは、データ収集を担当するプロセスです。

Zabbix サーバーのバージョンを確認してください。

zabbix_server -V

監視対象の Linux マシンに、同じバージョン(推奨)の Zabbix エージェントをインストールしてください。

監視のニーズに応じて、Zabbix サーバーがインストールされているマシンと同じマシンにインストールすることも、全く別のマシンにインストールすることもできます。

最適なインストール方法を選択してください。

  • Docker コンテナとして実行 - Zabbix Docker リポジトリ で利用可能なイメージのリストを参照してください。

  • Zabbix パッケージ からインストールする (Alma Linux、CentOS、Debian、Oracle Linux、Raspberry Pi OS、RHEL、Rocky Linux、SUSE Linux Enterprise Server、Ubuntu で利用可能)。

  • ソースからをコンパイルします。

Configure Zabbix for monitoring

Zabbix agent can collect metrics in active or passive mode (simultaneously).

A passive check is a simple data request. Zabbix server or proxy asks for some data (for example, CPU load) and Zabbix agent sends back the result to the server. Active checks require more complex processing. The agent must first retrieve from the server(s) a list of items for independent processing and then bulk send the data back. See Passive and active agent checks for more info.

Monitoring templates provided by Zabbix usually offer two alternatives - a template for Zabbix agent and a template for Zabbix agent (active). With the first option, the agent will collect metrics in passive mode. Such templates will deliver identical monitoring results, but using different communication protocols.

Further Zabbix configuration depends on whether you select a template for active or passive Zabbix agent checks.

パッシブチェック

Zabbix agent

1. Open the agent configuration file on the machine where the agent is installed.

sudo vi /etc/zabbix/zabbix_agentd.conf

2. Add the IP address or DNS name (and optional port) of your Zabbix server to the server parameter. For example:

Server=192.0.2.0:10051

Zabbix agent will use this address to accept incoming connections only from the specified Zabbix servers or proxies to retrieve data.

3. Restart Zabbix agent.

systemctl restart zabbix-agent

Zabbix frontend

1. Log in to Zabbix frontend.

2. Create a host in Zabbix web interface.

  • In the Host name field, enter a host name (e.g., "Linux server").
  • In the Templates field, type or select the template "Linux by Zabbix agent" that will be linked to the host.
  • In the Host groups field, type or select a host group (e.g., "Linux servers").
  • In the Interfaces parameter, add Agent interface and specify the IP address or DNS name of the Linux machine where the agent is installed.

3. Click on Add to add the host. This host will represent the monitored Linux machine.

アクティブチェック

Zabbix agent

Open Zabbix agent configuration file (by default, the path is /usr/local/etc/zabbix_agentd.conf):

sudo vi /usr/local/etc/zabbix_agentd.conf

Add:

  • The name of the host you created in Zabbix web interface to the Hostname parameter.
  • The IP address or DNS name of your Zabbix server to the ServerActive parameter.

For example:

ServerActive= 192.0.2.22
       Hostname=Linux server

Zabbix frontend

1. Log in to Zabbix frontend.

2. Create a host in Zabbix web interface.

This host will represent your Linux machine.

3. In the Templates parameter, type or select Linux by Zabbix agent active.

View collected metrics

Congratulations! At this point, Zabbix is already monitoring your Linux machine.

To view collected metrics, open the Monitoring->Hosts menu section and click on the Latest data next to the host.

This action will open a list of all the latest metrics collected from Linux server host.

問題アラートの設定

Zabbix は、インフラの問題を様々な方法で通知できます。

このガイドでは、メールアラートを送信するための設定手順を説明します。

1. ユーザー設定 -> プロファイル に移動し、メディア タブに切り替えて メールアドレスを追加 します。

2. 問題通知の受信 のガイドに従います。

次回以降、Zabbix が問題を検出すると、メールでアラートが届くようになります。

Test your configuration

On Linux, you can simulate high CPU load and as a result receive a problem alert by running:

cat /dev/urandom | md5sum

You may need to run several md5sum processes for CPU load to exceed the threshold.

When Zabbix detects the problem, it will appear in the Monitoring->Problems section.

If the alerts are configured, you will also receive the problem notification.

See also:

  • Creating an item - how to start monitoring additional metrics (custom monitoring without templates).
  • Zabbix agent items, Zabbix agent items for Windows - full list of metrics you can monitor using Zabbix agent on Windows.
  • Problem escalations - how to create multi-step alert scenarios (e.g., first send message to the system administrator, then, if a problem is not resolved in 45 minutes, send message to the data center manager).