โ˜• XOPSSCHOOL โ€” LEARNING MADE AFFORDABLE
Build the Skills Your Next Career Move Demands.
For the Price of One Coffee a Month.
Why spend hundreds on individual courses? Unlock an entire year of technical learning with one Coffee Pass.
US$4.90 /month
US$58.80/year
โ‚น499 + GST/month
โ‚น5,988 + GST/year
โ‚ฌ4.90 /month
โ‚ฌ58.80/year
12 Months of Access • Billed Annually • No Automatic Renewal
DevOps • Cloud • SRE • Kubernetes • Terraform • DevSecOps • AI • AIOps • MLOps • LLMOps • FinOps • GitOps • Platform Engineering & Much More
192
Premium Courses
1,085
Video Sessions
99
Ops Disciplines
86
Tool Courses
340
Assignments
227
Quizzes
โœ“ QR-Verifiable Certificates   โœ“ Learn at Your Own Pace   โœ“ Hands-on Learning   โœ“ New Courses Included
Learn from real-world, instructor-led video sessions by
Rajesh Kumar
Principal Architect • Trainer • Mentor • 15+ Years of Industry Experience
โ˜• Get My Coffee Pass โ€” Start Learning Today →
One Payment. Every Premium Course. One Full Year.
The best investment you can make is in the person you are becoming.

Understanding Zabbix Agent Configuration

The Zabbix agent configuration file controls which Zabbix servers may query the agent, where it sends active checks, how it identifies itself, and which custom checks and security rules it uses. This page explains the parameters that matter most in zabbix_agentd.conf and zabbix_agent2.conf, then adds a working minimal configuration, testing commands, PSK encryption and fixes for common agent errors.


Location of Zabbix Agent Configuration file

  • Linux – Zabbix Agent Version 1 – /etc/zabbix/zabbix_agentd.conf
  • Linux – Zabbix Agent Version 2 – /etc/zabbix/zabbix_agent2.conf
  • Windows – Zabbix Agent Version 1 – zabbix_agent.conf
  • Windows – Zabbix Agent Version 2 – zabbix_agent2.win.conf

Zabbix Agent Config Parameters Details

Example of Zabbix Agent Configuration file


Corrected file locations and how to reload changes

The Linux paths above are correct for official Zabbix packages. The Windows names need fixing. zabbix_agentd.win.conf and zabbix_agent2.win.conf are the names of the sample files in the Zabbix source tree. When you install with the MSI package, the file on disk has a different name.

AgentOSDefault config file (package/MSI install)Service name
Zabbix agentLinux/etc/zabbix/zabbix_agentd.confzabbix-agent
Zabbix agent 2Linux/etc/zabbix/zabbix_agent2.confzabbix-agent2
Zabbix agentWindowsC:\Program Files\Zabbix Agent\zabbix_agentd.confZabbix Agent
Zabbix agent 2WindowsC:\Program Files\Zabbix Agent 2\zabbix_agent2.confZabbix Agent 2

The agent reads its configuration only when it starts. Restart it after every change:

# Linux
sudo systemctl restart zabbix-agent      # agent 1
sudo systemctl restart zabbix-agent2     # agent 2
sudo systemctl status zabbix-agent --no-pager

# Windows (PowerShell as Administrator)
Restart-Service "Zabbix Agent"
Restart-Service "Zabbix Agent 2"Code language: PHP (php)

Passive and active checks: the parameters that matter most

Most of the file above is commented-out defaults. Only a handful of lines decide whether monitoring works, and they belong to two modes:

  • Passive checks: the server or proxy connects to the agent on TCP 10050 and asks for a value. This is controlled by Server, ListenPort, ListenIP and StartAgents.
  • Active checks: the agent connects to the server or proxy on TCP 10051, downloads its list of items and pushes the results. This is controlled by ServerActive, Hostname, RefreshActiveChecks, BufferSend and BufferSize.
ParameterWhat it doesTypical value
ServerIPs, CIDRs or DNS names allowed to connect for passive checks. Connections from anywhere else are rejected.192.168.1.5
ServerActiveServer or proxy address the agent connects to for active checks. If empty, active checks are disabled.192.168.1.5 or zbx.example.com:10051
HostnameMust match the Host name in the frontend exactly (case-sensitive). Needed for active checks and auto-registration.web01
HostMetadataFree text the server uses in auto-registration action conditions.Linux web
TimeoutMaximum seconds the agent spends on one check.3 to 10
IncludeLoads extra .conf files, usually user parameters./etc/zabbix/zabbix_agentd.d/*.conf
LogFileSizeBuilt-in log rotation in MB. 0 turns it off.0 with logrotate, otherwise 10
DebugLevelLog detail from 0 to 5. Use 4 only while troubleshooting.3

Note: The example file above ships with Server=127.0.0.1, ServerActive=127.0.0.1 and Hostname=Zabbix server. Those values are only right for the agent installed on the Zabbix server itself. On every other host, change all three, or the agent will reject the server and active checks will fail.

A minimal working configuration for a monitored Linux host

You don't need to edit hundreds of lines. Keep the packaged file and make sure these lines are set and not commented out. In this example the Zabbix server is 192.168.1.5 and the host is called web01 in the frontend.

PidFile=/run/zabbix/zabbix_agentd.pid
LogFile=/var/log/zabbix/zabbix_agentd.log
LogFileSize=0
Server=192.168.1.5
ServerActive=192.168.1.5
Hostname=web01
HostMetadata=Linux
Timeout=5
Include=/etc/zabbix/zabbix_agentd.d/*.confCode language: JavaScript (javascript)

If a proxy monitors the host, put the proxy's address in Server and ServerActive, not the server's. You can list more than one entry, separated by commas, for example Server=192.168.1.5,192.168.1.6. Packaged installs set LogFileSize=0 because logrotate handles rotation. Set it to 10 or similar if logrotate is not set up for the agent log.

Open the firewall for passive checks, then restart the agent:

# firewalld (RHEL, Rocky, Alma)
sudo firewall-cmd --permanent --add-port=10050/tcp
sudo firewall-cmd --reload

# ufw (Ubuntu)
sudo ufw allow from 192.168.1.5 to any port 10050 proto tcp

sudo systemctl restart zabbix-agentCode language: PHP (php)

Active checks only need outbound access from the agent to port 10051 on the server or proxy.

Testing the configuration

Check the agent locally first, then from the server. On recent versions, -T validates the config file without starting the agent. -t tests a single item key, and -p prints every built-in key with its current value.

# On the agent host
sudo zabbix_agentd -T -c /etc/zabbix/zabbix_agentd.conf   # validate syntax
zabbix_agentd -t agent.ping
zabbix_agentd -t system.cpu.load[all,avg1]

# Expected output
agent.ping                                    [u|1]
system.cpu.load[all,avg1]                     [d|0.120000]

# On the Zabbix server or proxy (package zabbix-get)
zabbix_get -s 192.168.1.20 -p 10050 -k agent.ping
1Code language: PHP (php)

If zabbix_get returns 1, passive checks work end to end. For agent 2, use zabbix_agent2 -t <key> in the same way. Then confirm active checks in the agent log with sudo tail -f /var/log/zabbix/zabbix_agentd.log.

Adding custom metrics with UserParameter

Put custom checks in their own files under the Include directory rather than editing the main file. Package upgrades then won't overwrite them, and tools such as Ansible can manage them easily.

# /etc/zabbix/zabbix_agentd.d/custom.conf

# Simple key: number of nginx processes
UserParameter=custom.nginx.procs,pgrep -c nginx

# Flexible key: count processes for any name, e.g. custom.proc.count[sshd]
UserParameter=custom.proc.count[*],pgrep -c "$1"Code language: PHP (php)
sudo systemctl restart zabbix-agent
zabbix_agentd -t custom.proc.count[sshd]
# custom.proc.count[sshd]                     [t|2]Code language: CSS (css)
  • Commands run as the zabbix user, so that user must be able to run them and read any files they use.
  • In flexible ([*]) keys, $1 to $9 are the key arguments. Write $$ when you need a literal $ in the command, for example in awk.
  • Keep UnsafeUserParameters=0 unless you really need special characters in arguments. Enabling it lets callers pass shell metacharacters into your commands.
  • Keep each command under the Timeout value. For slow commands, cache the result with a cron job and read the file with vfs.file.contents.

Securing the agent

Restrict remote commands. system.run[*] is denied by default. If you need it, allow only specific commands. Rules are checked in the order they appear and the first match wins, so put the specific AllowKey before the broad DenyKey. EnableRemoteCommands is deprecated, as the comment above says. Use AllowKey and DenyKey instead.

AllowKey=system.run[/usr/bin/uptime]
DenyKey=system.run[*]
LogRemoteCommands=1Code language: JavaScript (javascript)

Encrypt traffic with a pre-shared key (PSK). By default, agent traffic is plain text. Generate a key on the agent host:

openssl rand -hex 32 | sudo tee /etc/zabbix/zabbix_agentd.psk
sudo chown zabbix:zabbix /etc/zabbix/zabbix_agentd.psk
sudo chmod 600 /etc/zabbix/zabbix_agentd.psk
TLSConnect=psk
TLSAccept=psk
TLSPSKIdentity=PSK-web01
TLSPSKFile=/etc/zabbix/zabbix_agentd.pskCode language: JavaScript (javascript)

Restart the agent. Then, in the frontend, open the host, go to the Encryption tab, select PSK for connections to and from the host, and enter the same identity and key. Until both sides match, checks fail with TLS errors. To test with zabbix_get, add --tls-connect psk --tls-psk-identity PSK-web01 --tls-psk-file <file>.

Note: Leave AllowRoot=0 so the agent runs as the unprivileged zabbix user. On systemd hosts, the service unit decides the user, as the comment in the file says.

Zabbix agent vs agent 2 configuration

Agent 2 is written in Go and shares most core parameters with agent 1: Server, ServerActive, Hostname, HostMetadata, Timeout, Include, UserParameter, AllowKey/DenyKey and the TLS options. The main differences:

  • Agent 2 extends itself through plugins configured with Plugins.<Name>.* parameters, for example for PostgreSQL, MySQL, Redis or Docker. It has no LoadModule.
  • Agent 2 doesn't pre-fork worker processes the way StartAgents does in agent 1.
  • Agent 2 has a ControlSocket for runtime commands, and its include directory is /etc/zabbix/zabbix_agent2.d/.

When you move from agent 1 to agent 2, don't copy the old file across unchanged. Start from the packaged zabbix_agent2.conf and transfer your Server, ServerActive, Hostname, metadata, TLS settings and user parameters.

Common errors and fixes

SymptomCauseFix
zabbix_get returns Connection refusedAgent is not running, is listening on another IP or port, or a firewall blocks 10050Check systemctl status, ss -tlnp | grep 10050, ListenIP and firewall rules
Agent log shows connection from "x" rejected, allowed hosts: "127.0.0.1"The server or proxy IP is missing from ServerAdd the real source IP of the server or proxy to Server, then restart
Log shows no active checks on server ... host [web01] not foundHostname does not match the frontend host nameMake them identical, including case
Item shows Timeout while executing a shell scriptA UserParameter or check runs longer than TimeoutSpeed up the command or raise Timeout (maximum 30)
Host interface shows a TLS or PSK errorPSK identity or key differs between agent and frontend, or the key file can't be readCompare both values and check that the file is owned by zabbix

Note: For more detail while troubleshooting, set DebugLevel=4 temporarily, or run zabbix_agentd -R log_level_increase on a running agent 1. Set it back afterwards, because level 4 fills the log quickly.

Frequently asked questions

Where is the Zabbix agent configuration file on Linux?

With official packages, agent 1 uses /etc/zabbix/zabbix_agentd.conf and agent 2 uses /etc/zabbix/zabbix_agent2.conf. Extra files are loaded from /etc/zabbix/zabbix_agentd.d/ or /etc/zabbix/zabbix_agent2.d/ through the Include parameter.

What is the difference between Server and ServerActive in zabbix_agentd.conf?

Server lists the hosts allowed to connect to the agent for passive checks on port 10050. ServerActive is the address the agent connects to on port 10051 to fetch and send active checks.

Do I need to restart the Zabbix agent after changing the configuration?

Yes. The agent reads its configuration only at startup, so restart the service after any change. On recent versions you can reload user parameters with zabbix_agentd -R userparameter_reload.

Why does my host show active checks as unavailable?

Usually Hostname in the agent config doesn't exactly match the host name in the frontend, or ServerActive points to the wrong address. It can also be a firewall blocking outbound traffic to port 10051.

How do I test a Zabbix agent from the server?

Install the zabbix-get package on the server or proxy and run zabbix_get -s <agent-ip> -k agent.ping. A result of 1 means the agent accepts passive checks from that server.

Related tutorials

Find Trusted Cardiac Hospitals

Compare heart hospitals by city and services โ€” all in one place.

Explore Hospitals

Related Posts

Zabbix Tutorials: Example of zabbix_proxy.conf

The example above is the full, commented sample zabbix_proxy.conf shipped with Zabbix 7.0. It includes 7.0-only options such as ProxyBufferMode, ProxyMemoryBufferSize and the asynchronous agent, HTTP and…

Read More

Zabbix Tutorials: Example of zabbix_agentd.conf

zabbix_agentd.conf is the configuration file for the classic Zabbix agent on Linux and Unix. It sets which Zabbix servers may poll the agent, where it sends active…

Read More

Zabbix Tutorials: Example of zabbix_agentd.win.conf

zabbix_agentd.win.conf is the sample configuration file that comes with the classic Zabbix agent for Windows. The file above is the stock sample from a recent release, but…

Read More

Zabbix Tutorials: Example of zabbix_agent2.win.conf

The example above is the stock zabbix_agent2.win.conf that ships with Zabbix agent 2 for Windows. Nearly every line is a comment that documents a default value. Only…

Read More

Step by Step Guide to Monitor PostGreSQL using Zabbix Agent

To monitor PostgreSQL with the classic Zabbix agent, you install the agent on the database host, create a read-only monitoring role, and deploy the user parameters and…

Read More

Ansible Playbook for Zabbix Agent Deployment

This page shows an Ansible playbook that installs and configures Zabbix agent 6.0 on CentOS and RHEL hosts. Below the original playbook you will find a corrected,…

Read More
Subscribe
Notify of
guest
0 Comments
Newest
Oldest Most Voted
0
Would love your thoughts, please comment.x
()
x