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

Zabbix agent template operation

Steps to ensure correct operation of templates that collect metrics with Zabbix agent:

1. Make sure that Zabbix agent is installed on the host. For active checks, also make sure that the host is added to the 'ServerActive' parameter of the agent configuration file.
2. Link the template to a target host (if the template is not available in your Zabbix installation, you may need to import the template's .xml file first - see Templates out-of-the-box section for instructions).
3. Adjust the values of mandatory macros as needed.
4. Configure the instance being monitored to allow sharing data with Zabbix - see instructions in the Additional steps/comments column.

This page contains only a minimum set of macros and setup steps that are required for proper template operation. A detailed description of a template, including the full list of macros, items and triggers, is available in the template's Readme.md file (accessible by clicking on a template name).

Template name Mandatory macros Additional steps/comments
Apache by Zabbix agent {$APACHE.STATUS.HOST} - the hostname or IP address of Apache status page (default: 127.0.0.1)
{$APACHE.STATUS.PATH} - the URL path (default: server-status?auto)
{$APACHE.STATUS.PORT} - the port of Apache status page (default: 80)
Apache module mod_status should be set (see Apache documentation for details).
To check availability, run:
httpd -M 2>/dev/null \| grep status_module

Apache configuration example:
<Location "/server-status">
SetHandler server-status
Require host example.com
</Location>
HAProxy by Zabbix agent {$HAPROXY.STATS.PATH} - the path of HAProxy Stats page (default: stats)
{$HAPROXY.STATS.PORT} - the port of HAProxy Stats host or container (default: 8404)
{$HAPROXY.STATS.SCHEME} - the scheme of HAProxy Stats page. Supported: http (default), https
HAProxy Stats page should be set up (see HAProxy blog post for details or template's Readme.md for configuration example).
IIS by Zabbix agent / IIS by Zabbix agent active {$IIS.PORT} - the port IIS Server listens on (default: 80)
{$IIS.SERVICE} - the service for port check (default: http). See net.tcp.service section for details.
The server should have the following roles:
Web Server
IIS Management Scripts and Tools

See IIS documentation for details.
Microsoft Exchange Server 2016 by Zabbix agent/Microsoft Exchange Server 2016 by Zabbix agent active Note, that the template doesn't provide information about Windows services state. It is recommended to use it together with OS Windows by Zabbix agent or OS Windows by Zabbix agent active template.
Nginx by Zabbix agent {$NGINX.STUB_STATUS.HOST} - the hostname or IP address of Nginx stub_status host or container (default: localhost)
{$NGINX.STUB_STATUS.PATH} - the path of Nginx stub_status page (default: basic_status)
{$NGINX.STUB_STATUS.PORT} - the port of Nginx stub_status host or container (default: 80)
ngx_http_stub_status_module should be set up (see Nginx documentation for details or template's Readme.md for configuration example).
To check availability, run:
nginx -V 2>&1 \| grep -o with-http_stub_status_module
PHP-FPM by Zabbix agent {$PHP_FPM.HOST} - a hostname or an IP of PHP-FPM status host or container (default: localhost)
{$PHP_FPM.PING.PAGE} - PHP-FPM ping page path (default:ping)
{$PHP_FPM.PORT} - the port of PHP-FPM status host or container (default: 80)
{$PHP_FPM.PROCESS_NAME} - PHP-FPM process name (default:php-fpm)
{$PHP_FPM.STATUS.PAGE} - PHP-FPM status page path (default:status)
1. Open the php-fpm configuration file and enable the status page:
pm.status_path = /status
ping.path = /ping

2. Validate the syntax: $ php-fpm7 -t

3. Reload the php-fpm service.

4. In the Nginx Server Block (virtual host) configuration file, add (see template's Readme.md for an expanded example with comments):
location ~ ^/(status\|ping)$ {
access_log off;
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
fastcgi_index index.php;
include fastcgi_params;
fastcgi_pass 127.0.0.1:9000;
}

5. Check the syntax: $ nginx -t

6. Reload Nginx

7. Verify: curl -L 127.0.0.1/status
RabbitMQ cluster by Zabbix agent {$RABBITMQ.API.CLUSTER_HOST} - the hostname or IP address of RabbitMQ cluster API endpoint (default:127.0.0.1)
{$RABBITMQ.API.USER}, {$RABBITMQ.API.PASSWORD} - RabbitMQ login credentials (default username: zbx_monitor, password: zabbix)
Enable RabbitMQ management plugin (see RabbitMQ documentation).

To create a RabbitMQ user with necessary permissions for monitoring, run:
'' rabbitmqctl add_user zbx_monitor <PASSWORD> ''
rabbitmqctl set_permissions -p / zbx_monitor %% "" "" ".*"%%
rabbitmqctl set_user_tags zbx_monitor monitoring

If the cluster consists of several nodes, it is recommended to assign the cluster template to a separate balancing host. In case of a single-node installation, the cluster template can be assigned to the host with a node template.
MySQL by Zabbix agent {$MYSQL.HOST} - the hostname or IP address of MySQL host or container (default: 127.0.0.1 (since 6.0.8)/localhost (before 6.0.8))
{$MYSQL.PORT} - the database service port (default: 3306)
1. If necessary, add the path to the mysql and mysqladmin utilities to the global environment variable PATH.

2. Copy the template_db_mysql.conf file from templates directory of Zabbix into folder with Zabbix agent configuration (/etc/zabbix/zabbix_agentd.d/ by default) and restart Zabbix agent.

3. Create MySQL user zbx_monitor. To grant required privileges to the user, run:
GRANT USAGE,REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON %% *.* TO '<username>'@'%';%%
(see MYSQL documentation for details).

4. Create .my.cnf in the home directory of Zabbix agent for Linux (/var/lib/zabbix by default ) or my.cnf in c:\ for Windows. The file must have three strings:
[client]
''user='zbx_monitor' ''
''password='<password>' ''
PostgreSQL {$PG.DB} - the database name to connect to the server (default: postgres)
{$PG.HOST} - the database server host or socket directory (default:127.0.0.1)
{$PG.PORT} - the database server port (default: 5432)
{$PG.USER} - the database username (default: zbx_monitor)
1. Create a read-only user zbx_monitor with proper access to PostgreSQL server. For PostgreSQL 10 and newer, run:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;
GRANT pg_monitor TO zbx_monitor;
For older PostgreSQL versions, run:
CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>';
GRANT SELECT ON pg_stat_database TO zbx_monitor;

2. Copy postgresql/ to Zabbix agent home directory (/var/lib/zabbix/).

3. Copy template_db_postgresql.conf from templates directory of Zabbix to Zabbix agent configuration directory (/etc/zabbix/zabbix_agentd.d/) and restart Zabbix agent.

4. Edit pg_hba.conf to allow connections from Zabbix agent (see PostgreSQL documentation for details).
Row examples:
host all zbx_monitor 127.0.0.1/32 trust
host all zbx_monitor 0.0.0.0/0 md5
host all zbx_monitor ::0/0 md5

5. To monitor a remote server, create a .pgpass file in Zabbix agent home directory (/var/lib/zabbix/) and add rows with the instance, port, database, user and password information (see PostgreSQL documentation for details).
Row examples:
<REMOTE_HOST1>:5432:postgres:zbx_monitor:<PASSWORD>
*:5432:postgres:zbx_monitor:<PASSWORD>