このページでは、ブラウザアイテムを使用してウェブサイトの基本的な監視を開始するために必要な手順について説明します。
このガイドの対象者
このガイドは、Zabbixを初めて使用するユーザー向けに設計されており、ブラウザアイテムを使用してウェブサイトの基本的な監視を行うために必要な最小限の手順が記載されています。 より詳細なカスタマイズオプションや、より高度な設定が必要な場合は、Zabbixマニュアルのブラウザアイテムページまたは設定セクションをご覧ください。
前提条件
このガイドを進める前に、お使いのOSの手順に従って、ZabbixサーバーとZabbixフロントエンドをダウンロードしてインストールする必要があります。
このガイドは、以下の環境に基づいています。
Browser items require an automation framework (either Selenium Server or a plain WebDriver, for example, ChromeDriver) as a web testing endpoint that controls and interacts with a browser, executing test commands such as clicking buttons or entering text. As an example, this guide will use Selenium Server with Chrome in a Docker container.
It is assumed that Docker is already configured. This guide does not cover the configuration of Docker. For installation instructions, see Install Docker Engine on Ubuntu.
1. Launch Selenium Server with Chrome in a Docker container with the following options:
docker run --name browser
- runs a new Docker container named "browser";-p 4444:4444
- maps port 4444 on your host machine to port 4444 on the container (this is the port used by Selenium Server to accept commands);-p 7900:7900
- maps port 7900 on your host machine to port 7900 on the container (this is the port used by the Virtual Network Computing (VNC) server, allowing you to view the browser GUI remotely; requires a VNC client);--shm-size="2g"
- allocates 2GB of shared memory to the container (this is important for Chrome to run properly, as it can require a significant amount of shared memory to avoid crashes);-d
- runs the container in detached mode, meaning it will run in the background;selenium/standalone-chrome:latest
- specifies the Docker image to use; in this case, the latest version of Selenium Server with Chrome.docker run --name browser \
-p 4444:4444 \
-p 7900:7900 \
--shm-size="2g" \
-d selenium/standalone-chrome:latest
2. Ensure that the browser
Docker container is running and accessible.
ip addr
# 1: lo: <LOOPBACK,UP,LOWER_UP>
# ...
# 3: docker0: <NO-CARRIER,BROADCAST,MULTICAST,UP> ...
# inet 192.0.2.1/16 brd 192.0.255.255 scope global docker0
# ...
curl -L 192.0.2.1:4444
# <!DOCTYPE html>
# <html lang="en">
#
# <head>
# <meta charset="utf-8"/>
# <link href="favicon.svg" rel="icon" type="image/svg">
# <meta content="width=device-width, initial-scale=1" name="viewport"/>
# <link href="logo192.png" rel="apple-touch-icon"/>
# <link href="manifest.json" rel="manifest"/>
# <title>Selenium Grid</title>
# </head>
#
# <body>
# ...
For troubleshooting, refer to Docker documentation.
ブラウザアイテムは、ブラウザポーラー Zabbix プロセスによって実行・処理されます。このプロセスは、StartBrowserPollers サーバー設定パラメータを調整して有効化する必要があります。 さらに、WebDriverURL パラメータには、事前に設定した Web テストエンドポイントを指定する必要があります。
デフォルトでは、StartBrowserPollers パラメータは 1 に設定されているため、Web テストエンドポイントのみを指定する必要があります。
1. Zabbix サーバー設定ファイルを開きます。
2. Zabbixサーバー設定ファイルでWebDriverURLパラメータを探して設定します。
### Option: WebDriverURL
# WebDriver interface HTTP[S] URL. For example http://localhost:4444 used with Selenium WebDriver standalone server.
#
# Mandatory: no
# Default:
# WebDriverURL=
WebDriverURL=192.0.2.1:4444
3. Zabbixサーバーを再起動します。
1. Log into Zabbix frontend.
2. Create a host in Zabbix web interface:
3. Click the Add button to create the host. This host will represent the website you want to monitor.
Congratulations! At this point, Zabbix is already monitoring the website you specified.
To view collected metrics, navigate to the Monitoring → Hosts menu section and click on Dashboards next to the host.
This action will take you to the host dashboard (configured on the template level) with the most important metrics collected from the website.
Zabbix can notify you about a problem with your infrastructure using a variety of methods. This guide provides basic configuration steps for sending email alerts.
1. Navigate to User settings → Profile, switch to the Media tab and add your email.
2. Follow the guide for Receiving a problem notification.
Next time, when Zabbix detects a problem, you should receive an alert via email.
To test your configuration, we can simulate a real problem by updating the host configuration in Zabbix frontend.
1. Open your website host configuration in Zabbix.
2. Switch to the Macros tab and select Inherited and host macros.
3. Click on Change next to, for example, the previously configured {$WEBSITE.DOMAIN} macro value and set an incorrect domain name (for example, /git.zabbix.com/projects/ZBX/repos/zabbix/browse).
4. Click on Update to update the host configuration.
5. In a few moments, Zabbix will detect the problem "Failed to get JSON of the requested website", because it will not be able to connect to the specified website. The problem will appear in Monitoring → Problems.
If alerts are configured, you will also receive the problem notification.
6. Change the macro value back to its previous value to resolve the problem and continue monitoring the website.