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

Zabbix agent 2 テンプレートの運用

Zabbix agent 2 でメトリクスを収集するテンプレートが正しく動作するためのステップです:

  1. ホスト上に agent 2 がインストールされていること、およびインストールされたバージョンに必要なプラグインが含まれていることを
    確認します。場合によっては、以下の作業が必要になることがあります。
    agent 2 のupgrade を先に行う必要があります。
  2. ターゲットホストにテンプレートをLink します。
    (テンプレートが Zabbix インストールにない場合、最初にテンプレートのインポートファイルをインポートする必要があるかもしれません。
  1. 必要に応じて、必須マクロの値を調整します。ユーザーマクロは、設定パラメータを上書きするために使用することができることに
    注意してください。
  2. Zabbixとのデータ共有を許可するように監視対象のインスタンスを設定します。(Additional steps/comments 欄の説明を参照)

Zabbix agent 2テンプレートはプラグインと連動して動作します。基本的な設定は、ユーザマクロを調整することで可能ですが
configuring the plugin自体によって、より詳細なカスタマイズを行うことができます。
例えば、プラグインが名前付きセッションをサポートしている場合、設定ファイルで各エンティティに独自のURI、ユーザ名、パスワードを
持つ名前付きセッションを指定することで、同じ種類の複数のエンティティ(例えば、MySQL1とMySQL2)を監視することが可能です。

このページでは、テンプレートが正しく動作するために必要な最低限のマクロと設定手順のみを掲載しています。
テンプレートの詳細な説明(マクロ、item、trigger の全リストを含む)は、テンプレートの Readme.md ファイル
(テンプレート名をクリックするとアクセスできます)に記載されています。

テンプレート名 必須マクロ Additional steps/comments
Ceph by Zabbix agent 2 {$CEPH.API.KEY} - the API key (default: zabbix_pass).
Required, if {$CEPH.CONNSTRING} is a URI.
Must be empty, if {$CEPH.CONNSTRING} is a session name.
{$CEPH.CONNSTRING} - connection string; can be a session name or a URI defined in the following format: <protocol(host:port)>. For URI only HTTPS schema is supported.
Examples: Prod, https://localhost:8003 (default)
{$CEPH.USER} - user to be used for monitoring (default:zabbix).
Required, if {$CEPH.CONNSTRING} is a URI.
Must be empty, if {$CEPH.CONNSTRING} is a session name.
Works with Ceph plugin; named sessions are supported.

1. Configure the Ceph RESTful Module according to documentation.

2. Make sure a RESTful API endpoint is available for connection.
Docker - Works with Docker plugin; named sessions are not supported.

To set path to Docker API endpoint edit Plugins.Docker.Endpoint parameter in the agent 2 configuration file (default: Plugins.Docker.Endpoint=unix:///var/run/docker.sock).

To test availability, run:
zabbix_get -s docker-host -k docker.info
Memcached {$MEMCACHED.CONN.URI} - connection string in the URI format; port is optional; password is not used.
If not set, the plugin's default value is used: tcp://localhost:11211.
Examples: tcp://127.0.0.1:11211, tcp://localhost, unix:/var/run/memcached.sock.
Works with Memcached plugin; named sessions are supported.

To test availability, run:
zabbix_get -s memcached-host -k memcached.ping
MongoDB cluster by Zabbix agent 2 {$MONGODB.CONNSTRING} - connection string in the URI format; password is not used (default: tcp://localhost:27017).
Can be a session name or a URI defined in the following format: %% <protocol(host:port)>%%
For URI only TCP scheme is supported.
Examples: MongoDB1, tcp://172.16.0.10
{$MONGODB.USER}, {$MONGODB.PASSWORD} - MongoDB credentials (default: none).
If not set and {$MONGODB.CONNSTRING} is a URI, parameters from the configuration file will be used.
Must be empty, if {$MONGODB.CONNSTRING} is a session name.
Works with MongoDB plugin; named sessions are supported.
For MongoDB configuration instructions, see plugins.
To test availability, run:
zabbix_get -s mongos.node -k 'mongodb.ping["{$MONGODB.CONNSTRING}","{$MONGODB.USER}","{$MONGODB.PASSWORD}"]"
MongoDB node by Zabbix agent 2 {$MONGODB.CONNSTRING} - connection string in the URI format; password is not used (default: tcp://localhost:27017).
Can be a session name or a URI defined in the following format: %% <protocol(host:port)>%%
For URI only TCP scheme is supported.
Examples: MongoDB1, tcp://172.16.0.10
{$MONGODB.USER}, {$MONGODB.PASSWORD} - MongoDB credentials (default: none).
If not set and {$MONGODB.CONNSTRING} is a URI, parameters from the configuration file will be used.
Must be empty, if {$MONGODB.CONNSTRING} is a session name.
Works with MongoDB plugin; named sessions are supported.
For MongoDB configuration instructions, see plugins.
To test availability, run:
zabbix_get -s mongodb.node -k 'mongodb.ping["{$MONGODB.CONNSTRING}","{$MONGODB.USER}","{$MONGODB.PASSWORD}"]"
MySQL by Zabbix agent 2 {$MYSQL.DSN} - the system data source name of the MySQL instance (default: <Put your DSN>).
Can be a session name or a URI defined in the following format: %% <protocol(host:port or /path/to/socket)/>%%
For URI only TCP and Unix schemas are supported.
Examples: MySQL1, tcp://localhost:3306, tcp://172.16.0.10, unix:/var/run/mysql.sock
{$MYSQL.USER}, {$MYSQL.PASSWORD} - MySQL credentials (default: none). Required, if {$MYSQL.DSN} is a URI.
Must be empty, if {$MYSQL.DSN} is a session name.
Works with MySQL plugin; named sessions are supported.

To grant required privileges to a MySQL user that will be used for monitoring, run:
GRANT USAGE,REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON *.* TO '<username>'@'%';

See MySQL documentation for information about user privileges and Unix sockets.
Oracle by Zabbix agent 2 {$ORACLE.CONNSTRING} - connection string; can be a session name or a URI defined in the following format: <protocol(host:port or /path/to/socket)/>
For URI only TCP schema is supported.
Examples: Oracle1, tcp://localhost:1521

{$ORACLE.SERVICE} - Oracle Service name (default: ORA). Required, if {$ORACLE.CONNSTRING} is a URI.
Must be empty, if {$ORACLE.CONNSTRING} is a session name.

{$ORACLE.USER}, {$ORACLE.PASSWORD} - Oracle credentials (default username: zabbix, password: zabbix_password). Required, if {$ORACLE.CONNSTRING} is a URI.
Must be empty, if {$ORACLE.CONNSTRING} is a session name.
Works with Oracle plugin; named sessions are supported.

Install Oracle Instant Client.
To create Oracle user with required privileges, run:
CREATE USER zabbix_mon IDENTIFIED BY <PASSWORD>;
-- Grant access to the zabbix_mon user.
GRANT CONNECT, CREATE SESSION TO zabbix_mon;
GRANT SELECT ON DBA_TABLESPACE_USAGE_METRICS TO zabbix_mon;
GRANT SELECT ON DBA_TABLESPACES TO zabbix_mon;
GRANT SELECT ON DBA_USERS TO zabbix_mon;
GRANT SELECT ON SYS.DBA_DATA_FILES TO zabbix_mon;
GRANT SELECT ON V$ACTIVE_SESSION_HISTORY TO zabbix_mon;
GRANT SELECT ON V$ARCHIVE_DEST TO zabbix_mon;
GRANT SELECT ON V$ASM_DISKGROUP TO zabbix_mon;
GRANT SELECT ON V$DATABASE TO zabbix_mon;
GRANT SELECT ON V$DATAFILE TO zabbix_mon;
GRANT SELECT ON V$INSTANCE TO zabbix_mon;
GRANT SELECT ON V$LOG TO zabbix_mon;
GRANT SELECT ON V$OSSTAT TO zabbix_mon;
GRANT SELECT ON V$PGASTAT TO zabbix_mon;
GRANT SELECT ON V$PROCESS TO zabbix_mon;
GRANT SELECT ON V$RECOVERY_FILE_DEST TO zabbix_mon;
GRANT SELECT ON V$RESTORE_POINT TO zabbix_mon;
GRANT SELECT ON V$SESSION TO zabbix_mon;
GRANT SELECT ON V$SGASTAT TO zabbix_mon;
GRANT SELECT ON V$SYSMETRIC TO zabbix_mon;
GRANT SELECT ON V$SYSTEM_PARAMETER TO zabbix_mon;
PostgreSQL Agent 2 {$PG.URI} - connection string; can be a session name or a URI defined in the following format:
%% <protocol(host:port or /path/to/socket)/>%%. For URI only TCP and Unix schemas are supported.
Examples: Postgres1, tcp://localhost:5432, tcp://172.16.0.10
{$PG.USER}, {$PG.PASSWORD} - PostgreSQL credentials (default username: postgres, password:postgres).
Required, if {$PG.URI} is a URI. Must be empty, if {$PG.URI} is a session name.
Works with PostgreSQL plugin; named sessions are supported.

To create a user with required privileges, for PostgreSQL 10 and newer, run:
CREATE USER 'zbx_monitor' IDENTIFIED BY '<password>';
GRANT EXECUTE ON FUNCTION pg_catalog.pg_ls_dir(text) TO zbx_monitor;\\GRANT EXECUTE ON FUNCTION pg_catalog.pg_stat_file(text) TO zbx_monitor;

Edit pg_hba.conf to allow connections from Zabbix agent (see PostgreSQL documentation for details).
Redis {$REDIS.CONN.URI} -connection string in the URI format; port is optional; password is not used.
If not set, the plugin's default value is used: tcp://localhost:6379
Works with Redis plugin; named sessions are supported.

To test availability, run:
zabbix_get -s redis-master -k redis.ping
SMART by Zabbix agent 2 / SMART by Zabbix agent 2 active - Sudo/root access rights to smartctl are required for the user executing Zabbix agent 2. The minimum required smartctl version is 7.1.

Disk discovery LLD rule finds all HDD, SSD, NVMe disks with S.M.A.R.T. enabled.

Attribute discovery LLD rule finds all Vendor Specific Attributes for each disk.

To skip some attributes, set regular expressions with disk names in {$SMART.DISK.NAME.MATCHES} and with attribute IDs in {$SMART.ATTRIBUTE.ID.MATCHES} on the host level.
Systemd by Zabbix agent 2 - No specific configuration is required.
Website certificate by Zabbix agent 2 ** {$CERT.WEBSITE.HOSTNAME}** - the website's DNS name for the connection (default: <Put DNS name>). Works with WebCertificate plugin; named sessions are not supported.
To test availability, run:
zabbix_get -s <zabbix_agent_addr> -k web.certificate.get[<website_DNS_name>]

Create a separate host for the TLS/SSL certificate with Zabbix agent interface and link the template to this host.