user19019822
user19019822

Reputation:

Zabbix template trigger expression referencing a item from another template

I'm having trouble thinking and implementing a way to do the following:

I have a systemd monitoring template which has 2 main triggers for any given discovered service. "The service has restarted" or "The service is not running". When a given host restarts, every single service trigger kicks off with an alert saying "service has restarted". This makes sense, the host restarts, so do the services.

My goal is to prevent the service trigger alerts from being generated if the host uptime is less than 10 minutes (the default timer for the "host restarted" trigger). In other words, "Service has restarted" trigger should only be generated when the host uptime is more than 10 minutes.

So my initial thoughts were to use trigger dependencies, but those only create a dependency off another trigger. So I wouldn't want my "service has restarted" trigger to activate if the "host has restarted" trigger was also activated (thats the opposite of what I want). And as far as I am aware, the trigger dependencies do not have a "negate" or "not" function/operator built into them. So I couldn't say something like: "This trigger can only activate if this other trigger is currently inactive."

So my next thought was to edit the template discovery trigger prototype expression and change it from the following: last(/Systemd by Zabbix agent 2/systemd.service.uptime["{#UNIT.NAME}"])<10m to something like last(system.uptime)>10m AND last(/Systemd by Zabbix agent 2/systemd.service.uptime["{#UNIT.NAME}"])<10m. This isn't exact syntax, just the rough idea of what I was thinking of.

The problem is when I try to do the expression editor and include the item from another template, is errors out with:

Trigger prototype "{#UNIT.NAME}: has been restarted" belongs to templates with different linkages.

I assume that it wont let me link a prototype trigger with another templates item?

I am using the default "Linux Generic by Zabbix Agent" Template, and the following template for systemd: https://git.zabbix.com/projects/ZBX/repos/zabbix/browse/templates/app/systemd?at=release/6.0

Overall, I definitely don't want to be going around to every host and creating custom triggers for every single service that compares the host uptime with the systemd service uptime. Maybe I could move the system.uptime template item from the "Generic Linux Template" to the Systemd template, but thats rather brute force.

Anyone got an ideas for what to do here? Any better ways to solve my problem?

Upvotes: 0

Views: 3394

Answers (1)

user19768783
user19768783

Reputation: 1

You may use items from different templates in triggers that are in another template. BUT the item templates need to be linked to the trigger template.

So in your case, you should do:

  • create a new, empty XYZ Template
  • link Generic Linux Template and Systemd Template to your XYZ template
  • now you can create triggers in your XYZ template that utilizes items from Generic Linux Template and Systemd Template

Upvotes: 0

Related Questions