Active agent autoregistration

Another way to do some automation in Zabbix is to automate the registration of active clients. It is possible to register an active Zabbix client automatically in the Zabbix server once it is detected.

Getting ready

For this recipe to work, we need our Zabbix server with administrator rights and of course a Zabbix agent that is configured to be an active agent. Make sure that the agent is set up and not added to the Zabbix server yet, as this is what we will automate in this recipe. In production, this will be an added value as we can automate in Zabbix the discovery and configuration of new hosts in our environment. For instance, when an administrator installs new servers with a golden image or with some configuration management tools, the server will automatically be detected by the Zabbix server and / or added to a group and linked with a template.

How to do it ...

  1. In the Zabbix menu, go to Configuration | Actions and select Auto registration as the Event source from the dropdown on the upper right.
  2. Press the Create action button just preceding the Event source box.
  3. In the Action box just fill in the Name.
  4. In the Condition tab, we can specify the condition. This is optional and we will skip it in this recipe. You can make use of this if you want to specify the HostMetadata or HostMetadataItem from the agents configuration file but this is optional.
  5. In the Operations tab, we will add the relevant operation in our case it will be Add host.
  6. Press the Add button to add the new rule to the Actions page.
    How to do it ...
  7. Once you update all the details, click the Update button.

How it works

The automatic agent registration works only with active agents, so we need to make sure that in the zabbix_agentd.conf file the option ServerActive= is filled in with the address of our Zabbix server (or proxy).

We have to create an action just as we do with the network discovery; however it is not needed to do any network discovery in this case.

In the Action we have defined a new name for our action and we could add a subject and a message to inform us, for example by email, once an agent has been registered.

In the Conditions tab, we have not added anything but it would be possible to filter for only certain hostnames, host metadata, or proxies.

In the Operations tab we told Zabbix to add the host to Zabbix once conditions were met. Here we have many more options. We could also send a message, add the host to a group, link it with a template, launch a remote command, and so on.

There is more…

To get information for the host metadata we have to configure this data in the zabbix_agentd.conf file. There are two lines in the agent configuration file HostMetadata and HostMetadataItem that can be used for this. This can be useful if you would like to define certain servers as, for example, web servers, database servers, and so on.

Tip

It's in general a good practice not to add and remove clients when discovered or when not discovered anymore, as a host may be unreachable or an agent can be installed on a temporary machine. It's probably wise to use a certain delay before an action is taken.

Zabbix states that an auto-registration attempt happens every time an active agent sends a request to refresh the active checks to the server. The delay between requests is specified in the RefreshActiveChecks parameter of the Zabbix agent. The first request will be sent immediately after the agent is restarted.

..................Content has been hidden....................

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