Multiple servers for active agent? Sure!

Zabbix agent currently supports only one server in active mode – the first host from the Server configuration parameter is used. While for most users that is enough, some installations require a more advanced approach with the agent being able to report to multiple servers in the active mode.

Current situation

Currently, Zabbix active agent can report to a single server only. There is just one process that works with active checks.

Only one server or proxy can work with active checks

Multiple server support in 1.8.12 already

The chosen approach was simple enough to be implemented in Zabbix 1.8.12 already. From the user perspective, if they only want to use a single active server (or none at all), nothing changes. Note that agent doesn’t really know whether it is talking to a server or proxy, so multiple proxies or any combination of servers and proxies is supported as well. Everywhere further down when a “server” is mentioned, that also includes Zabbix proxies. Now, if a user wants to use more than one server for the active checks, things change a bit. First, there is a new configuration parameter – ServerActive. How it works:

  • If ServerActive is specified, Server is not used for active checks, only for passive checks
  • If ServerActive is not specified, Server is used same as before, that is, first host is used for active checks

If you were using the first host from the Server parameter for active checks and you add a ServerActive parameter, you must list the same host in the new parameter as well, otherwise it will be ignored for active checks. Of course, to achieve our goal of having multiple servers used, this parameter allows to specify multiple hosts here – comma separated. For example, it could list:

ServerActive=zabbixserver,zabbixproxy1,10.1.13.13

But what if a proxy on one of them is running on a non-standard port? Custom port can be specified for each host after a colon.

ServerActive=zabbixserver,zabbixproxy1:20051,10.1.13.13

Of course, IPv6 is supported as well… but wait, IPv6 addresses contain colons. How about specifying non-default port then? If IPv6 host must have port specified, IP address should be enclosed in square brackets (square brackets are optional if no port is used with IPv6) address, for example:

 ServerActive=zabbixproxy1:20051,[::1]:30051,::1,[::1]

For all hosts that don’t have a port specified here, port in ServerPort is used. If ServerPort is not specified, default port (10051) is used.

Different implementation in 2.0

The solution for 1.8 is great as it does not require any changes for users, upgrading to 1.8.12 or later from previous agent versions. It is not great as the behaviour is a bit cryptic and confusing – if this parameter is specified, we ignore something from that parameter, ports can be overridden in two ways… Given that 2.0 is a major upgrade it was decided to implement a simpler solution. A minor drawback is that some users will have to modify their agent daemon configuration files when upgrading agents to 2.0. So, 2.0 works exactly as 1.8 implementation, but with these differences:

  • Hosts in the Server parameter are never used for active checks, only for passive checks – even if ServerActive is not specified
  • ServerPort parameter is removed

Upgrading agent to Zabbix 2.0

For those users who are not using active checks, upgrade to 2.0 will not require any changes – unless they were specifying ServerPort (for some reason – it is not used for anything else besides active checks). For those users who moved to using ServerActive with 1.8, upgrade to 2.0 will not require any changes – unless they were specifying ServerPort.

  • All users who used ServerPort will have to remove this parameter from their configuration files
  • All users who used active checks in 1.8 without ServerActive parameter will have to add their server/proxy in ServerActive parameter. If they used ServerPort, that will also have to be added to corresponding hosts in the ServerActive parameter

How it works

Before this development, only one agent internal process was possible that would be responsible for active items. Now, for each host, specified in ServerActive, a new active item process will be created. Each process will work with one server only in an independent fashion. So these processes work totally in parallel, without any communication between them.

Each active item process works with one server or proxy exclusively

Item values are sent back to whichever server sent configuration data for them. If one server sends active item configuration data and another has no active items configured, only the first server will receive the values for those items. All the configuration data, received from servers, is handled separately by each internal process, so you should be careful with that – for example, if there is a script that should not be run in multiple copies simultaneously, you should never send item data from multiple servers that references this script. If you do, multiple active item processes will definitely attempt to run the script at the same time.

Error reporting

The new parameter syntax is a bit more complex than for the old Server parameter, so typos and other mistakes might be a bit more likely. Because of this (and because Zabbix becomes a bit more user-friendly lately 🙂 ), error reporting should be fairly helpful. If Zabbix agent can’t parse some part of the addresses (there’s something totally wrong there), it will refuse to start up with a message error in ServerActive option at position <pos>, printing out the character position where the problematic content starts. If an address is specified twice in ServerActive, agent will refuse to start up with an additional message part address “host:port” specified more than once.

Where is it?

This functionality is available in 1.8.12rc1, and will be in the final release of 1.8.12. If you are interested in it, make sure to test 1.8.12rc1 as soon as possible.

Special thanks

Special thanks for help and support with this feature goes to:

  • Takanori Suzuki for the initial idea and proof-of-concept patch
  • Intelligence Business Solutions, Ltd. (Zabbix certified partner) for financing the complete development

5 thoughts on “Multiple servers for active agent? Sure!”

  1. I like that starting from agent 2.0 the list of active checks will not be requested from a server until the “ServerActive” will not be properly defined for agent. In other words the list will not be requested by default.

    At the moment in many environments in the zabbix_server.log I saw a huge flow of records like:
    “Sending list of active checks to [10.216.1.7] failed: host [h78gh55q] not found”
    and that was annoying because all zabbix agents were not used for active checks but they requested list of active checks from the server.

    So, this change is great !

    1. yes, so it resulted in a large amount of network connections and log entries both on agents and the server.
      actually, there was another issue – if one had lots of agents like that, each connection would also result in an auto-registration event, which could spam the events table a lot… that’s actually a large problem that might warrant a blog post of it’s own 🙂

  2. Thank you for the great post regarding the Active Agent capability to connect with multiple Zabbix Servers. We are using Zabbix 2.0.4 for our system deployments and we use active checks for some of our monitored servers.
    The post shows how to configure the agent with multiple Zabbix Servers but what about the “Hostname” parameter in the zabbix_agentd.conf, can we have multiple Hosts for that entry!
    Example Hostname=Server1, Server 2 in case we have defined multiple hosts for the same monitored server (or machine, VM)

    or we are only limited to 1 hostname per agent?
    Thanks

Leave a Reply