Zabbix模板触发表达式引用来自另一个模板的项目

发布于 2025-01-25 16:23:19 字数 1530 浏览 2 评论 0原文

我在思考和实施以下方法方面遇到困难:

我有一个SystemD监视模板,该模板具有2个主要触发器,用于任何给定的发现的服务。 “服务已重新启动”或“服务未运行”。当给定主机重新启动时,每个服务触发器都会以警报开头,说“服务已经重新启动”。这是有道理的,主机重新开始,服务也是如此。

我的目标是防止如果主机正常运行时间少于10分钟(“主机重新启动”触发器的默认计时器),服务触发警报被生成。 换句话说,仅当主机正常运行时间超过10分钟时,才应生成“服务已重新启动”触发器。

因此,我最初的想法是使用触发依赖性,但是这些依赖性仅在另一个触发器上产生依赖性。因此,如果“主机已经重新启动”触发器也被激活(这与我想要的相反),我不希望我的“服务已重新启动”触发器激活激活。据我所知,触发依赖性没有内置的“否定”或“非”功能/操作员。因此,我不能说这样的话:“只有当其他触发器不活跃的情况下,这个触发器才能激活。”

因此,我的下一个想法是编辑模板发现触发原型表达式并从以下内容进行更改:last(/systemd by zabbix agent 2/systemd.service.uptime.uptime [“ {#unit.name}”])< 10m to last(System.uptime)> 10m和last(/Systemd by Zabbix Agent 2/Systemd.Service.uptime [“ {#unit.name}”])< 10m; lt; lt; lt; /代码>。这不是确切的语法,只是我在想什么的粗略想法。

问题是当我尝试执行表达式编辑器并从另一个模板中包含项目时,错误是:

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

我认为它不会让我将原型触发器与另一个模板项目链接起来吗?

我正在使用默认的“ Zabbix Agent的Linux Generic”模板,以及SystemD的以下模板: https:https:// git。 zabbix.com/projects/zbx/repos/zabbix/zabbix/browse/templates/app/systemd?at=release/6.0

总的来说,我绝对不想到每个主机上四处寻找每个主机并为每个主机创建自定义触发器将主机正常运行时间与SystemD服务正常运行时间进行比较的单个服务。也许我可以将系统移动。Euttime模板项目从“通用Linux模板”到SystemD模板,但这相当残酷。

有人对在这里做什么有想法吗? 有什么更好的方法来解决我的问题吗?

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?

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(1

樱花坊 2025-02-01 16:23:19

您可以使用另一个模板中的触发器中不同模板中的项目。但是项目模板需要链接到触发模板。

因此,在您的情况下,您应该执行:

  • 创建一个新的,空的XYZ Template
  • 链接通用Linux模板和SystemD模板到XYZ模板
  • 现在可以在XYZ模板中创建触发器,该模板在XYZ模板中使用通用Linux模板和SystemD模板中使用项目

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
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文