Zabbix中的python自定义警报订阅不工作

发布于 2025-01-26 05:59:01 字数 957 浏览 1 评论 0原文

我想通过Python脚本设置发送Webhooks,但是我对此有一个问题。我正在尝试根据本手册 httpps:httpps://wwwww。 zabbix.com/documentation/current/en/manual/config/notifications/media/script 。脚本正在执行,但没有发送我想要的值。这是我的脚本:

#!/usr/bin/python
import sys
import requests
hostname = sys.argv[1]
eventname = sys.argv[2]
severity = sys.argv[3]
payload = '{{"text": "{0},{1},{2}"}}'.format(hostname,eventname,severity)
headers = {'Content-type': 'application/json'}
endpoint = "https://example.com/asdf"
requests.post(endpoint, headers=headers, data=payload, verify=False)

在Zabbix设置中,我添加了这些包表器:

{HOST.NAME}
{EVENT.NAME}
{EVENT.SEVERITY}

已从Zabbix发送的通知不仅包含值参数名称。通知看起来像这样:

{HOST.NAME},{EVENT.NAME},{EVENT.SEVERITY}

有人可以帮助我,问题在哪里?先感谢您。

I would like to set sending webhooks by python script, but I have one problem with this. I am trying according this manual https://www.zabbix.com/documentation/current/en/manual/config/notifications/media/script . The script is executing but it doesn't send values which I want. This is my script:

#!/usr/bin/python
import sys
import requests
hostname = sys.argv[1]
eventname = sys.argv[2]
severity = sys.argv[3]
payload = '{{"text": "{0},{1},{2}"}}'.format(hostname,eventname,severity)
headers = {'Content-type': 'application/json'}
endpoint = "https://example.com/asdf"
requests.post(endpoint, headers=headers, data=payload, verify=False)

In zabbix settings I have added these parmeters:

{HOST.NAME}
{EVENT.NAME}
{EVENT.SEVERITY}

Notificiation which has been sent from zabbix doesn't contain values only parameter names. Notificiation looks like this:

{HOST.NAME},{EVENT.NAME},{EVENT.SEVERITY}

Could someone help me, where is the problem? Thank you in advance.

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

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

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。
列表为空,暂无数据
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文