zabbix 5.0对接飞书机器人告警
#把机器人webhook粘贴到脚本里
cat > /usr/lib/zabbix/alertscripts/feishu.py << 'EOF'
#!/usr/bin/python2.7
#coding:utf-8
#zabbix飞书报警
import requests,json,sys,os,datetime
url="https://open.feishu.cn/open-apis/bot/v2/hook/b3a65fadxxxxxxxxxxx"
def send_message(message):
    payload_message = {
    
        "msg_type": "text",
        "content": {
    
            "text": message
        }
    }
    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)
EOF
测试脚本是否能发送消息,该脚本只能传参一个
chmod +x /usr/lib/zabbix/alertscripts/feishu.py
wget https://bootstrap.pypa.io/pip/2.7/get-pip.py
curl https://bootstrap.pypa.io/pip/2.7/get-pip.py -o get-pip.py
python get-pip.py
pip install requests
./feishu.py test