Zabbix釘釘報警設置

                                      Zabbix釘釘報警設置【轉載】

1.安裝好zabbix後設置/usr/local/etc/zabbix_server.conf

[root@pre-release ~]# cat  /usr/local/etc/zabbix_server.conf

2.創建報警腳本(腳本轉載自https://www.jianshu.com/p/6317121da5a4

[root@pre-release ~]# cat /usr/local/share/zabbix/alertscripts/dingalert.py

#!/usr/bin/env python

import json
import requests
import sys

def send_msg(url, remiders, msg):
    headers = {'Content-Type': 'application/json; charset=utf-8'}
    data = {
        "msgtype": "text",
        "at": {
            "atMobiles": remiders,
            "isAtAll": False,
        },
        "text": {
            "content": msg,
        }
    }
    r = requests.post(url, data=json.dumps(data), headers=headers)
    return r.text

if __name__ == '__main__':
    msg = sys.argv[1]
    remiders = []
    url = '釘釘機器人的URL'
    print(send_msg(url, remiders, msg))

[root@pre-release ~]# chmod +x /usr/local/share/zabbix/alertscripts/dingalert.py
[root@pre-release ~]# chown -R  zabbix.zabbix  /usr/local/share/zabbix/alertscripts/dingalert.py

注意: url = '釘釘機器人的URL',填寫參照鏈接:https://www.jianshu.com/p/a3c62eb71ae3 【凱茜的老爸】

3.添加報警媒介

4.添加用戶可以使用腳本報警,注意收件人填釘釘對應的手機號

5.配置觸發動作

 

 

6.觸發報警條件,如,本例中/boot分區空間不足20%將會發生報警。

[root@pre-release ~]# dd if=/dev/zero of=/boot/t.img bs=10M count=800
[root@pre-release ~]# df -h /boot/
文件系統        容量  已用  可用 已用% 掛載點
/dev/vda1      10140M  9610M   540M   92% /boot

7.查看動作日誌及釘釘消息

ps : https://blog.51cto.com/m51cto/2051945 

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章