- 2 Agent
- Supported platforms
- Agent on UNIX-like systems
- Agent on Windows systems
- Other agent options
- Agent process types
- Process user
- Configuration file
- Locale
- Exit code
- 1. Monitor Linux with Zabbix agent
- Install Zabbix agent
- Configure Zabbix for monitoring
- Passive checks
- Zabbix frontend
- Zabbix agent
- Active checks
- Zabbix frontend
- Zabbix agent
- View collected metrics
- Set up problem alerts
- Test your configuration
2 Agent
Zabbix agent is deployed on a monitoring target to actively monitor local resources and applications (hard drives, memory, processor statistics, etc.).
The agent gathers operational information locally and reports data to Zabbix server for further processing. In case of failures (such as a hard disk running full or a crashed service process), Zabbix server can actively alert the administrators of the particular machine that reported the failure.
Zabbix agents are extremely efficient because of use of native system calls for gathering statistical information.
Passive and active checks
Zabbix agents can perform passive and active checks.
In a passive check the agent responds to a data request. Zabbix server (or proxy) asks for data, for example, CPU load, and Zabbix agent sends back the result.
Active checks require more complex processing. The agent must first retrieve a list of items from Zabbix server for independent processing. Then it will periodically send new values to the server.
Whether to perform passive or active checks is configured by selecting the respective monitoring item type. Zabbix agent processes items of type ‘Zabbix agent’ or ‘Zabbix agent (active)’.
Supported platforms
Zabbix agent is supported on the following platforms:
- Windows (all desktop and server versions since XP)
- Linux (also available in NetBSD and HP-UX, and those are compatible with current Zabbix server/proxy version.
Agent on UNIX-like systems
Installation
See the package installation section for instructions on how to install Zabbix agent as package. Alternatively see instructions for manual installation if you do not want to use packages.
If installed as package
shell> service zabbix-agent start
shell> /etc/init.d/zabbix-agent start
shell> service zabbix-agent stop shell> service zabbix-agent restart shell> service zabbix-agent status
Start up manually
If the above does not work you have to start it manually. Find the path to the zabbix_agentd binary and execute:
Agent on Windows systems
Preparation
Zabbix agent is distributed as a zip archive. After you download the archive you need to unpack it. Choose any folder to store Zabbix agent and the configuration file, e. g.
Copy bin\zabbix_agentd.exe and conf\zabbix_agentd.conf files to c:\zabbix. Edit the c:\zabbix\zabbix_agentd.conf file to your needs, making sure to specify a correct «Hostname» parameter.
Installation
C:\> c:\zabbix\zabbix_agentd.exe -c c:\zabbix\zabbix_agentd.conf -i
Now you should be able to configure «Zabbix agent» service normally as any other Windows service. See more details on installing and running Zabbix agent on Windows.
Other agent options
It is possible to run multiple instances of the agent on a host. A single instance can use the default configuration file or a configuration file specified in the command line. In case of multiple instances each agent instance must have its own configuration file (one of the instances can use the default configuration file). The following command line parameters can be used with Zabbix agent:
Parameter | Description |
---|---|
UNIX and Windows agent | |
-c —config | Path to the configuration file. You may use this option to specify a configuration file that is not the default one. On UNIX, default is /usr/local/etc/zabbix_agentd.conf or as set by compile-time variables —sysconfdir or —prefix On Windows, default is c:\zabbix_agentd.conf |
-p —print | Print known items and exit. Note: To return user parameter results as well, you must specify the configuration file (if it is not in the default location). |
-t —test | Test specified item and exit. Note: To return user parameter results as well, you must specify the configuration file (if it is not in the default location). |
-h —help | Display help information |
-V —version | Display version number |
UNIX agent only | |
-R —runtime-control | Perform administrative functions. See runtime control. |
Windows agent only | |
-m —multiple-agents | Use multiple agent instances (with -i,-d,-s,-x functions). To distinguish service names of instances, each service name will include the Hostname value from the specified configuration file. |
Windows agent only (functions) | |
-i —install | Install Zabbix Windows agent as service |
-d —uninstall | Uninstall Zabbix Windows agent service |
-s —start | Start Zabbix Windows agent service |
-x —stop | Stop Zabbix Windows agent service |
- printing all built-in agent items with values
- testing a user parameter with «mysql.ping» key defined in the specified configuration file
- installing a «Zabbix Agent» service for Windows using the default path to configuration file c:\zabbix_agentd.conf
- installing a «Zabbix Agent [Hostname]» service for Windows using the configuration file zabbix_agentd.conf located in the same folder as agent executable and make the service name unique by extending it by Hostname value from the config file
shell> zabbix_agentd --print shell> zabbix_agentd -t "mysql.ping" -c /etc/zabbix/zabbix_agentd.conf shell> zabbix_agentd.exe -i shell> zabbix_agentd.exe -i -m -c zabbix_agentd.conf
Runtime control
With runtime control options you may change the log level of agent processes.
Option | Description | Target |
---|---|---|
log_level_increase[=] | Increase log level. If target is not specified, all processes are affected. | Target can be specified as: process type — all processes of specified type (e.g., listener) See all agent process types. process type,N — process type and number (e.g., listener,3) pid — process identifier (1 to 65535). For larger values specify target as ‘process-type,N’. |
log_level_decrease[=] | Decrease log level. If target is not specified, all processes are affected. | |
userparameter_reload | Reload values of the UserParameter and Include options from the current configuration file. |
- increasing log level of all processes
- increasing log level of the third listener process
- increasing log level of process with PID 1234
- decreasing log level of all active check processes
shell> zabbix_agentd -R log_level_increase shell> zabbix_agentd -R log_level_increase=listener,3 shell> zabbix_agentd -R log_level_increase=1234 shell> zabbix_agentd -R log_level_decrease="active checks"
Runtime control is not supported on OpenBSD, NetBSD and Windows.
Agent process types
- active checks — process for performing active checks
- collector — process for data collection
- listener — process for listening to passive checks
The agent log file can be used to observe these process types.
Process user
Zabbix agent on UNIX is designed to run as a non-root user. It will run as whatever non-root user it is started as. So you can run agent as any non-root user without any issues.
If you will try to run it as ‘root’, it will switch to a hardcoded ‘zabbix’ user, which must be present on your system. You can only run agent as ‘root’ if you modify the ‘AllowRoot’ parameter in the agent configuration file accordingly.
Configuration file
For details on configuring Zabbix agent see the configuration file options for zabbix_agentd or Windows agent.
Locale
Note that the agent requires a UTF-8 locale so that some textual agent items can return the expected content. Most modern Unix-like systems have a UTF-8 locale as default, however, there are some systems where that may need to be set specifically.
Exit code
Before version 2.2 Zabbix agent returned 0 in case of successful exit and 255 in case of failure. Starting from version 2.2 and higher Zabbix agent returns 0 in case of successful exit and 1 in case of failure.
1. Monitor Linux with Zabbix agent
This page walks you through the steps required to start basic monitoring of Linux machines with Zabbix. The steps described in this tutorial can be applied to any Linux-based operating system.
Who this guide is for
This guide is designed for new Zabbix users and contains the minimum set of steps required to enable basic monitoring of your Linux machine. If you are looking for deep customization options or require more advanced configuration, see Configuration section of Zabbix manual.
Prerequisites
Before proceeding with this installation guide, you must download and install Zabbix server and Zabbix frontend according to instructions for your OS.
Install Zabbix agent
Zabbix agent is the process responsible for gathering data.
Check your Zabbix server version:
Install Zabbix agent of the same version (recommended) on the Linux machine that you want to monitor. Based on your monitoring needs, it may be the same machine, where Zabbix server is installed, or a completely different machine.
Choose the most suitable installation method:
- Run as a Docker container — see the list of available images in Zabbix Docker repository.
- Install from Zabbix packages (available for Alma Linux, CentOS, Debian, Oracle Linux, Raspberry Pi OS, RHEL, Rocky Linux, SUSE Linux Enterprise Server, Ubuntu).
- Compile from sources.
Configure Zabbix for monitoring
Zabbix agent can collect metrics in active or passive mode (simultaneously).
A passive check is a simple data request. Zabbix server or proxy asks for some data (for example, CPU load) and Zabbix agent sends back the result to the server. Active checks require more complex processing. The agent must first retrieve from the server(s) a list of items for independent processing and then bulk send the data back. See Passive and active agent checks for more info.
Monitoring templates provided by Zabbix usually offer two alternatives — a template for Zabbix agent and a template for Zabbix agent (active). With the first option, the agent will collect metrics in passive mode. Such templates will deliver identical monitoring results, but using different communication protocols.
Further Zabbix configuration depends on whether you select a template for active or passive Zabbix agent checks.
Passive checks
Zabbix frontend
1. Log into Zabbix frontend.
2. Create a host in Zabbix web interface.
This host will represent your Linux machine.
3. In the Interfaces parameter, add Agent interface and specify the IP address or DNS name of the Linux machine where the agent is installed.
4. In the Templates parameter, type or select Linux by Zabbix agent.
Zabbix agent
Open Zabbix agent configuration file (by default, the path is /usr/local/etc/zabbix_agentd.conf):
sudo vi /usr/local/etc/zabbix_agentd.conf
Add the IP address or DNS name of your Zabbix server to the Server parameter.
Active checks
Zabbix frontend
1. Log in to Zabbix frontend.
2. Create a host in Zabbix web interface.
This host will represent your Linux machine.
3. In the Templates parameter, type or select Linux by Zabbix agent active.
Zabbix agent
Open Zabbix agent configuration file (by default, the path is /usr/local/etc/zabbix_agentd.conf):
sudo vi /usr/local/etc/zabbix_agentd.conf
- The name of the host you created in Zabbix web interface to the Hostname parameter.
- The IP address or DNS name of your Zabbix server to the ServerActive parameter.
ServerActive= 192.0.2.22 Hostname=Linux server
View collected metrics
Congratulations! At this point, Zabbix is already monitoring your Linux machine.
To view collected metrics, open the Monitoring->Hosts menu section and click on the Latest data next to the host.
This action will open a list of all the latest metrics collected from Linux server host.
Set up problem alerts
Zabbix can notify you about a problem with your infrastructure using a variety of methods. This guide provides configuration steps for sending email alerts.
1. Go to the User settings -> Profile, switch to the tab Media and add your email.
Next time, when Zabbix detects a problem you should receive an alert via email.
Test your configuration
On Linux, you can simulate high CPU load and as a result receive a problem alert by running:
You may need to run several md5sum processes for CPU load to exceed the threshold.
When Zabbix detects the problem, it will appear in the Monitoring->Problems section.
If the alerts are configured, you will also receive the problem notification.
- Creating an item — how to start monitoring additional metrics (custom monitoring without templates).
- Zabbix agent items, Zabbix agent items for Windows — full list of metrics you can monitor using Zabbix agent on Windows.
- Problem escalations — how to create multi-step alert scenarios (e.g., first send message to the system administrator, then, if a problem is not resolved in 45 minutes, send message to the data center manager).