zabbix添加飞书告警(@个人)

环境:
OS:Centos 7
zabbix:4.0.5

1.确认脚本存放路径
在zabbix服务器上执行
[root@localhost ~]# cat /etc/zabbix/zabbix_server.conf|grep AlertScriptsPath
### Option: AlertScriptsPath
# AlertScriptsPath=${datadir}/zabbix/alertscripts
AlertScriptsPath=/usr/lib/zabbix/alertscripts

 

2.把告警脚本上传到zabbix服务器如下目录
/usr/lib/zabbix/alertscripts

 

[root@localhost alertscripts]# pwd
/usr/lib/zabbix/alertscripts
[root@localhost alertscripts]# ls
feishu-alert.py

复制代码
[root@localhost alertscripts]# more feishu-alert.py 
#!/usr/bin/python

import requests
import json
import sys
import os
import datetime

url = "https://open.feishu.cn/open-apis/bot/v2/hook/xxxxxxxxxxxxxxxxxxxxxxxxxxxxxx"

user_id = "\"用户id\""


def send_message(message):

    message_text = "%s <at user_id = %s></at> " % (message, user_id)

    payload_message = {
        "msg_type": "text",
        "content": {
            "text": message_text
        }
    }
    headers = {
        'Content-Type': 'application/json'
    }

    response = requests.request("POST", url, headers=headers, data=json.dumps(payload_message))
    return response


if __name__ == '__main__':
    text = sys.argv[1]
    send_message(text)
复制代码

 

 

 

 

3.添加报警媒介类型
管理->报警媒介类型

 

 

 

 

posted @   slnngk  阅读(94)  评论(0编辑  收藏  举报
相关博文:
阅读排行:
· 全程不用写代码,我用AI程序员写了一个飞机大战
· DeepSeek 开源周回顾「GitHub 热点速览」
· 记一次.NET内存居高不下排查解决与启示
· 物流快递公司核心技术能力-地址解析分单基础技术分享
· .NET10 - 预览版1新功能体验(一)
历史上的今天:
2023-12-20 duplicate克隆数据库脚本例子
2023-12-20 oracle文档手册地址
2023-12-20 shell里查询oracle里v$视图需要转义
2022-12-20 pgpool_II节点状态问题(pgpool_status)
2021-12-20 tgtadm配置
2021-12-20 戴尔R940ax安装
点击右上角即可分享
微信分享提示