1. Zabbix Active Agent Mode
To use active agent mode, you need to create a custom template. Search for the existing Linux template, click into it, and select Full clone. Rename the clone (e.g., Linux Active) and add it.

Then, search for the newly created template, select all items, and use Mass update. Change the Type to Zabbix agent (active) and update.

If you need a more specific active template, clone the main OS template:
- Click the template (e.g.,
Template OS Linux) - Choose Full clone
- Rename to include
active - Search for
activein the cloned template, go to Items, select all, and use Mass update to change the type toZabbix agent (active).

Next, search for active in the template list, select the one you just created (e.g., Template OS Linux Active). Go to Linked templates, click Unlink and clear to remove the old items. Then search for the agent active template you created earlier and link it.
Modify the Agent Configuration
On the monitored host (e.g., node2), edit the Zabbix agent configuration file:
vim /etc/zabbix/zabbix_agentd.conf
Set StartAgents=0 (disable passive checks) and configure active mode. Example configuration:
PidFile=/var/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
StartAgents=0
ServerActive=192.168.1.105
HostnameItem=system.hostname
Include=/etc/zabbix/zabbix_agentd.d/*.conf
Create the Host
Create a new host in Zabbix (e.g., node2). The hostname must match exactly the hostname reported by the agent, otherwise issues may occur. Add the host to a group (e.g., Linux servers) and link the active template.
Also, modify the host's Discovery rules: change the type to Zabbix agent (active).

Note: To refresh the configuration cache on the Zabbix server (use with caution in production):
zabbix_server -R config_cache_reload
2. Network Auto-Discovery
Go to Configuration -> Discovery -> enable the discovery rule. Then go to Actions, select Event source: Discovery, create an action with conditions (e.g., service type = Zabbix agent). In the Operations step, set Type to Link to templates and select the active template. Add and update.

On the agent machine, edit /etc/zabbix/zabbix_agentd.conf to set metadata for finer control (optional):
HostMetadata=web
Server=192.168.1.105
StartAgents=3
systemctl restart zabbix-agent.service
After a while, the host should be automatically discovered and linked to the template.
Active Registration Process
To simplify, you can create a host group and a template, then configure an Action in Zabbix to automatically link hosts based on conditions. After updating the action, new agents will register and be linked automatically.

3. Low-Level Discovery (LLD) for MySQL Multi-Instance
This example demonstrates LLD for multiple MySQL instances running on different ports (3306, 3307, 3308).
Prepare MySQL Instances
On the agent host (e.g., node2):
-
Create a new configuration file for port 3307:
cp /etc/my.cnf /etc/my3307.confEdit
/etc/my3307.confto change the datadir, socket, and port:[mysqld] datadir=/data/3307 socket=/data/3307/mysql.sock symbolic-links=0 port=3307 [mysqld_safe] log-error=/data/3307/mariadb.log pid-file=/data/3307/mariadb.pid -
Initialize the data directory:
mysql_install_db --user=mysql --defaults-file=/etc/my3307.cnf -
Start the new instance:
mysqld_safe --defaults-file=/etc/my3307.cnf & -
Set passwords:
mysqladmin -h 127.0.0.1 -uroot password '123456' -P 3306 mysqladmin -h 127.0.0.1 -uroot password '123456' -P 3307 mysqladmin -h 127.0.0.1 -uroot password '123456' -P 3308
Discovery Script
Create a script that outputs JSON with discovered port numbers:
vim /etc/zabbix/zabbix_agentd.d/discovery_mysql.sh
Content:
#!/bin/bash
# MySQL low-level discovery
res=$(netstat -lntp | grep mysqld | awk -F '[: ]+' '{print $5}')
ports=($res)
printf '{"data":[
'
for key in "${!ports[@]}"
do
if [[ "${#ports[@]}" -gt 1 && "${key}" -ne "$((${#ports[@]}-1))" ]]; then
printf '{"{#MYSQLPORT}":"%s"},' "${ports[${key}]}"
else
printf '{"{#MYSQLPORT}":"%s"}' "${ports[${key}]}"
fi
done
printf ']}'
Make it executable and test:
chmod +x /etc/zabbix/zabbix_agentd.d/discovery_mysql.sh
sh /etc/zabbix/zabbix_agentd.d/discovery_mysql.sh | python -m json.tool
User Parameter Configuration
Create a configuration file for the agent user parameters:
vim /etc/zabbix/zabbix_agentd.d/discovery_mysql.conf
Add the following line:
UserParameter=discovery_mysql,sh /etc/zabbix/zabbix_agentd.d/discovery_mysql.sh
Also, add a parameter for fetching MySQL status values:
vim /etc/zabbix/zabbix_agentd.d/userparameter_mysql.conf
Content:
UserParameter=mysql.status[*],echo "show global status where Variable_name='$2';" | HOME=/var/lib/zabbix mysql -uroot -p123456 -h 127.0.0.1 -P $1 -N | awk '{print $$2}'
Grant the netstat command permission for the Zabbix agent:
chmod u+s $(which netstat)
Restart the Zabbix agent:
systemctl restart zabbix-agent.service
Create Discovery Rule in Zabbix
-
Go to the host in Zabbix (e.g., node2)
-
Click on Discovery -> Create discovery rule
-
Set Name, Key to
discovery_mysql, keep Type asZabbix agent -
Save
-
Then click on Item prototypes -> Create item prototype

Create a prototype that uses
mysql.status[{#MYSQLPORT}, ...]as the key. Clone this prototype for each MySQL status you want to monitor (e.g., Threads_connected, Queries, etc.). -
You can also clone the item prototype and modify the key and name accordingly.
Example item prototype key: mysql.status[3306, Threads_connected] → with {#MYSQLPORT} as the port macro.
After this, the LLD will create items for each discovered port automatically.