# Zabbix agent template operation

Steps to ensure correct operation of templates that collect metrics with
[Zabbix agent](/manual/concepts/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](/manual/appendix/config/zabbix_agentd).
2. [Link](/manual/config/templates/linking#linking-a-template) 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](/manual/config/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.

::: notetip
 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](https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/app/apache_agent/README.md?at=refs%2Fheads%2Frelease%2F5.2)|**{$APACHE.STATUS.HOST}** - the hostname or IP address of Apache status page (default: 127.0.0.1)<br>**{$APACHE.STATUS.PATH}** - the URL path (default: server-status?auto)<br>**{$APACHE.STATUS.PORT}** - the port of Apache status page (default: 80)|Apache module mod\_status should be set (see Apache [documentation](https://httpd.apache.org/docs/current/mod/mod_status.html) for details).<br>To check availability, run:<br>`httpd -M 2>/dev/null \| grep status_module`<br><br>Apache configuration example:<br>`<Location "/server-status">`<br>`SetHandler server-status`<br>`Require host example.com`<br>`</Location>`|
|[HAProxy by Zabbix agent](https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/app/haproxy_agent/README.md?at=refs%2Fheads%2Frelease%2F5.2)|**{$HAPROXY.STATS.PATH}** - the path of HAProxy Stats page (default: stats)<br>**{$HAPROXY.STATS.PORT}** - the port of HAProxy Stats host or container (default: 8404)<br>**{$HAPROXY.STATS.SCHEME}** - the scheme of HAProxy Stats page. Supported: http (default), https|HAProxy Stats page should be set up (see HAProxy [blog post](https://www.haproxy.com/blog/exploring-the-haproxy-stats-page/) for details or template's Readme.md for configuration example).|
|[IIS by Zabbix agent](https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/app/iis_agent) / [IIS by Zabbix agent active](https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/app/iis_agent_active/README.md?at=refs%2Fheads%2Frelease%2F5.2)|**{$IIS.PORT}** - the port IIS Server listens on (default: 80)<br>**{$IIS.SERVICE}** - the service for port check (default: http). See [net.tcp.service](/manual/config/items/itemtypes/simple_checks) section for details.|The server should have the following roles:<br>[Web Server](https://docs.microsoft.com/en-us/iis/web-hosting/web-server-for-shared-hosting/installing-the-web-server-role)<br>[IIS Management Scripts and Tools](https://docs.microsoft.com/en-us/iis/manage/scripting/managing-applications-and-application-pools-on-iis-with-wmi)<br><br>See IIS documentation for details.|
|[Microsoft Exchange Server 2016 by Zabbix agent](https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/app/exchange/README.md?at=refs%2Fheads%2Frelease%2F5.2)/[Microsoft Exchange Server 2016 by Zabbix agent active](https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/app/exchange_active/README.md)|<|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](https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/app/nginx_agent/README.md?at=refs%2Fheads%2Frelease%2F5.2)|**{$NGINX.STUB\_STATUS.HOST}** - the hostname or IP address of Nginx stub\_status host or container (default: localhost)<br>**{$NGINX.STUB\_STATUS.PATH}** - the path of Nginx stub\_status page (default: basic\_status)<br>**{$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](https://nginx.org/en/docs/http/ngx_http_stub_status_module.html) for details or template's Readme.md for configuration example).<br>To check availability, run:<br>`nginx -V 2>&1 \| grep -o with-http_stub_status_module`|
|[PHP-FPM by Zabbix agent](https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/app/php-fpm_agent/README.md?at=refs%2Fheads%2Frelease%2F5.2)|**{$PHP\_FPM.HOST}** - a hostname or an IP of PHP-FPM status host or container (default: `localhost`)<br>**{$PHP\_FPM.PING.PAGE}** - PHP-FPM ping page path (default:`ping`)<br>**{$PHP\_FPM.PORT}** - the port of PHP-FPM status host or container (default: `80`)<br>**{$PHP\_FPM.PROCESS\_NAME}** - PHP-FPM process name (default:`php-fpm`)<br>**{$PHP\_FPM.STATUS.PAGE}** - PHP-FPM status page path (default:`status`)|1\. Open the php-fpm configuration file and enable the status page:<br>`pm.status_path = /status`<br>`ping.path = /ping`<br><br>2. Validate the syntax: `$ php-fpm7 -t`<br><br>3. Reload the php-fpm service.<br><br>4. In the Nginx Server Block (virtual host) configuration file, add (see template's *Readme.md* for an expanded example with comments):<br>`location ~ ^/(status\|ping)$ {`<br>`access_log off;`<br>`fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;`<br>`fastcgi_index index.php;`<br>`include fastcgi_params;`<br>`fastcgi_pass 127.0.0.1:9000;`<br>`}`<br><br>5. Check the syntax: `$ nginx -t`<br><br>6. Reload Nginx<br><br>7. Verify: `curl -L 127.0.0.1/status`|
|[RabbitMQ cluster by Zabbix agent](https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/app/rabbitmq_agent)|**{$RABBITMQ.API.CLUSTER\_HOST}** - the hostname or IP address of RabbitMQ cluster API endpoint (default:`127.0.0.1`)<br>**{$RABBITMQ.API.USER}**, **{$RABBITMQ.API.PASSWORD}** - RabbitMQ login credentials (default username: zbx\_monitor, password: zabbix)|Enable RabbitMQ management plugin (see [RabbitMQ documentation](https://www.rabbitmq.com/management.html)).<br><br>To create a RabbitMQ user with necessary permissions for monitoring, run:<br>'' rabbitmqctl add\_user zbx\_monitor <PASSWORD> ''<br>`rabbitmqctl set_permissions -p / zbx_monitor %% "" "" ".*"%%`<br>`rabbitmqctl set_user_tags zbx_monitor monitoring`<br><br>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](https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/mysql_agent/README.md?at=refs%2Fheads%2Frelease%2F5.2)|**{$MYSQL.HOST}** - the hostname or IP address of MySQL host or container (default: localhost)<br>**{$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.<br><br>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.<br><br>3. Create MySQL user `zbx_monitor`. To grant required privileges to the user, run:<br>`GRANT USAGE,REPLICATION CLIENT,PROCESS,SHOW DATABASES,SHOW VIEW ON %% *.* TO '<username>'@'%';%%`<br>(see [MYSQL documentation](https://dev.mysql.com/doc/refman/8.0/en/grant.html) for details).<br><br>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:<br>`[client]`<br>''user='zbx\_monitor' ''<br>''password='<password>' ''|
|[PostgreSQL](https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/db/postgresql/README.md?at=refs%2Fheads%2Frelease%2F5.2)|**{$PG.DB}** - the database name to connect to the server (default: postgres)<br>**{$PG.HOST}** - the database server host or socket directory (default:127.0.0.1)<br>**{$PG.PORT}** - the database server port (default: 5432)<br>**{$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:<br>`CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>' INHERIT;`<br>`GRANT pg_monitor TO zbx_monitor;`<br>For older PostgreSQL versions, run:<br>`CREATE USER zbx_monitor WITH PASSWORD '<PASSWORD>';`<br>`GRANT SELECT ON pg_stat_database TO zbx_monitor;`<br><br>2. Copy `postgresql/` to Zabbix agent home directory (/var/lib/zabbix/).<br><br>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.<br><br>4. Edit `pg_hba.conf` to allow connections from Zabbix agent (see [PostgreSQL documentation](https://www.postgresql.org/docs/current/auth-pg-hba-conf.html) for details).<br>Row examples:<br>`host all zbx_monitor 127.0.0.1/32 trust`<br>`host all zbx_monitor 0.0.0.0/0 md5`<br>`host all zbx_monitor ::0/0 md5`<br><br>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](https://www.postgresql.org/docs/current/libpq-pgpass.html) for details).<br>Row examples:<br>`<REMOTE_HOST1>:5432:postgres:zbx_monitor:<PASSWORD>`<br>`*:5432:postgres:zbx_monitor:<PASSWORD>`|
