Zabbix – Allowing per host overrides

If you use Zabbix as a monitoring tool you may be faced with some issues where you are using a template with a predefined value, that does not fit your deployment.

You could:

  1. Create a custom template based on an existing one.
  2. Disable the monitored element on the host and recreate it at the host level.
  3. Modify the source template to use a {$USER_MACRO}

We suggest using option 3, as it allows you to maintain existing data collected, does not alter any hosts using the template, and, lets you override the value at a per-host level.

You can read more here about user macros.

One common area where this is useful is the trigger “Too many processes on {HOST.NAME}” which is hard coded to 300. Depending on your server and deployment, this may be far to low of a value.

Let’s change that!

For this example, we will be modifying the built-in “Template OS Linux”.

Navigate to Configuration / Templates / Template OS Linux

Select the Macros tab. Select the Add link and fill in the MACRO value with the name you want to use, and assign it a default value. Here we have defined the macro name as {$MAX_PROCESSES_RUNNING} with the default value of 300 (the same as the hardcoded value)

Zabbix Template OS Linux
Adding user_macro to override default template settings.

The next thing you need to do is modify any existing triggers that might use this value. So let us modify the trigger “Too many processes on {HOST.NAME}”.

Modify Trigger Expression to utilize {$USER_MACRO}

The text box may show wrapping of your text, this is okay, just be sure to not press enter after the > or else your rule will not be processed.

Be sure to press the Update button at the bottom of the screen to save your template.

You are almost done! Right now all your existing Hosts using this template will continue to operate as normal because we applied the default value to our user_macro. But what about those pesky hosts that need more room?

Easy! Navigate to your host in question and go to the Macros tab. Add the defined user_macro and set the new value like so.

Adding a {$USER_MACRO} to a Zabbix Host

Now this host will use the {$MAX_PROCESSES_RUNNING} value (475) instead of the default 300.

And that is it. You can use this process for any existing template, or for when you create a new custom template.

Happy Monitoring.

Leave a Reply