Monitoring a host through a proxy

Now that we have the proxy configured and running, we have to inform Zabbix about it somehow. To do this, perform the following steps:

  1. Open Administration | Proxies in the frontend, then click on the Create proxy button.
  2. Enter First proxy in the Proxy name field:

The proxy name we enter here must match the one configured in the zabbix_proxy.conf file, and is case-sensitive.
Zabbix 4.0 added some extra security. If we fill in Proxy address with the IP of our proxy, then only requests from this comma-delimited list of IP addresses will be accepted.
  1. Next, we need to select Another host in Configuration | Hosts and select First proxy from the Monitored by proxy drop-down menu:

  1. When done, click on Update.

The next time the proxy connects to the server, the names should match and the proxy should get the information on what it is supposed to monitor. But when will that next time be? By default, the Zabbix proxy connects to the Zabbix server once per hour. The first connection attempt happens upon proxy startup, and at one-hour intervals from then on. If you configured the frontend part soon after the proxy was started, it could take up to an hour for the proxy to get the configuration data and start working. There are two ways to force rereading of the configuration data from the Zabbix server:

  • Restart the proxy
  • Force-reload its configuration cache

The first one would be acceptable on our test proxy, but it would not be that nice on a larger production proxy that is actively collecting data already. Let's see how we can force-reload the configuration cache. First, run the following:

# zabbix_proxy --help

In the output, pay attention to the runtime-control section and the first parameter in it:

 -R --runtime-control runtime-option   Perform administrative functions
        Runtime control options:
          config_cache_reload        Reload configuration cache 

When an active proxy is told to reload its configuration cache, it connects to the server, gets the new configuration data, and then updates the local cache. Let's issue that command now:

# zabbix_proxy --runtime-control config_cache_reload  
Runtime commands depend on the PID file being properly configured. When you run the previous command, it looks for the PidFile option in the default proxy configuration file, looks up the PID from the PID file, and sends the signal to that process. If multiple active proxies are running on the system, a signal can be sent to a specific proxy by specifying its configuration file with the -c option.

The reload command should be processed successfully:

zabbix_proxy [19293]: command sent successfully  

Check the proxy log file now:

forced reloading of the configuration cache 
received configuration data from server at "192.168.56.10", datalen 6545 

First, the proxy logs that it has received an order to reload the configuration cache. Then it connects to the server and successfully retrieves the configuration data from the server.

We will discuss reloading of the configuration cache in somewhat greater detail in Appendix A, Troubleshooting.

You can verify whether the proxy can successfully connect to the server by opening Administration | Proxies again. Look at the Last seen (age) column for the new proxy. Instead of saying never, it should show some time period. If it does not, check that both the Zabbix server and proxy are running, and that you can open a connection from the proxy host to the Zabbix server, port 10051:

But if you look at the Hosts column, you'll see that it is empty now. What happened here? We clearly added Another host to be monitored by this proxy—why did it disappear? This could be a challenging task to figure out, and a situation such as that could easily arise in a production environment. The reason for the host disappearing from the proxy configuration is active-agent auto-registration. We configured it in Chapter 11, Automating Configuration, and the agent has been sort of repeatedly auto-registering ever since. But why does that affect the host assignment to proxy? When an active agent connects and auto-registration is active, it matters where it connects to. Instead of creating a new host, the Zabbix server reassigns that host to the Zabbix server or some proxy, whichever received the agent connection. It considers that agent as having migrated from the server to some proxy or vice versa, or from one proxy to another. We assigned a host to our new proxy, the agent kept on connecting to the server, and the server reassigned that host back to be monitored directly by the server. How could we solve it? We have two options:

  • Disable the active agent's auto-registration action and reconfigure the host manually
  • Configure the agent to connect to the proxy instead

Let's try the second, fancier approach. On Another host, edit zabbix_agentd.conf and change ServerActive to the proxy IP address, then restart the agent.

In the preceding screenshot, we also see a column Compression. All communications between the Zabbix server and  proxies are now unconditionally compressed in both ways. For this the zlib library is required. This compression is new in Zabbix 4.0 and Zabbix SIA claims that it can save 50% of your bandwidth between proxy and server.
If you installed the Zabbix proxy on the same system as the Zabbix server, make sure to specify the proxy port in this parameter, too. For example, 192.168.1.23:11051.
Do not set the proxy address in addition to the server address—in that case, the agent will try to work with both the server and proxy in parallel. See Chapter 3, Monitoring with Zabbix Agents and Basic Protocols, for more detail on pointing the agent at several servers or proxies.

Check the proxy list again. There should be Another host in the Hosts column now, and it should not disappear again. Let's check data for this host in Monitoring | Latest data. Unfortunately, it looks like most of the items have stopped working. While we changed the active server parameter in the agent daemon configuration file and active agent items work now, there are more item categories that could have failed:

  • Passive agent items do not work because the agent does not accept connections from the proxy
  • ICMP items likely do not work as fping is either missing or does not have proper permissions.
  • While Another host does not have items of SNMP, IPMI, and other types, those could have started to fail because appropriate support was not compiled into the proxy, or respective pollers were not started
  • If you configured the proxy on the Zabbix server system, passive items will work, as the IP address the agent gets the connections from will stay the same

Let's fix at least the passive agent items. Edit zabbix_agentd.conf on Another host and change the Server parameter. Either replace the IP address in there with the proxy address, or add the proxy address to it, then restart the agent. In a few minutes, most of the passive agent items should start receiving data again.

As for the ICMP items, refer to Chapter 3, Monitoring with Zabbix Agents and Basic Protocols, for the fping configuration. It's the same as on the server side; it's just that the changes have to be performed on the proxy system now.

In general, when a host is monitored by proxy, all connections to and from that host must and will be performed by the proxy. The agent must allow connections from the proxy for passive items and connect to the proxy for active items. Even the Zabbix sender must send data to the proxy for Zabbix trapper items, not the Zabbix server anymore.

With the host monitored by the proxy, let's check whether there is any indication of that in the frontend:

  1. Open Configuration | Hosts, make sure Linux servers is selected in the Group drop-down, and take a look at the Name column
  2. As you can see, Another host is now prefixed by the proxy name and reads First proxy: Another host:

When having multiple proxies, it is a common practice to name them by location name—for example, proxy-London or Paris-proxy.

Before it was possible to monitor hosts by proxies from under Administration | Proxies this option was removed in Zabbix and now the only place left we can do this is on host level under Configuration | Hosts.

If you decide to monitor A test host through the proxy, be very careful with its address. If the address is left at 127.0.0.1, the proxy will connect to the local agent for passive items and then report that data to the server, claiming it came from A test host. That would also be not that easy to spot, as the data would come in just fine; only it would be the wrong data.
..................Content has been hidden....................

You can't read the all page of ebook, please click here login for view all page.
Reset
3.137.185.180