Zabbix Agent Auto Registration - Zabbix Server

2.9k Views Asked by At

I am trying to register Zabbix agent to Zabbix server UI automatically but seems i am missing something but when i am trying to do it via UI(Manually) it is working. can someone help me to do it.

My configurations -

/etc/zabbix/zabbix_agentd.conf

Server=127.0.0.1,{zabbix-server-ip}
ServerActive=DNS Name
HostMetadata=ubuntu (string why which i am doing configuration in UI)

any though on this would be appreciated.

3

There are 3 best solutions below

0
On BEST ANSWER

first, you need to set Server and ServerActive both IP or DNS of zabbix server.

For auto discovery, you need to set rules in zabbix UI/frontend with HostMetadata under Configuration → Actions.

Check if link will help you.

https://www.zabbix.com/documentation/4.2/manual/discovery/auto_registration

0
On

You are configuring Server and ServerActive wrong: both need to be set to the IP/DNS of the Zabbix Proxy/Server, no the local IP/DNS.

1
On

Wrote a script for auto-registration of the Zabbix agent to Zabbix server.

For auto discovery, you need to set rules in Zabbix UI/frontend with HostMetadata under Configuration → Actions. Follow This

Then you can move ahead with script execution on agent

#Note - This script takes zabbixserverip metadatastring as input at runtime sh script.sh internal-dns-name free-string
#!/bin/bash
zabbixserverip=$1
metadatastring=$2
apt update -y
apt install zabbix-agent
sed -i -- 's/Server=127.0.0.1/Server='$zabbixserverip'/g' /etc/zabbix/zabbix_agentd.conf
echo "ServerActive=$zabbixserverip" >> /etc/zabbix/zabbix_agentd.conf
echo "HostMetadata=$metadatastring" >> /etc/zabbix/zabbix_agentd.conf
systemctl restart zabbix-agent
systemctl status zabbix-agent