zabbix monitoring deployment (four)

zabbix add nail alarm notification

In the previous article, by Zabbix host disk, CPU and memory monitoring, surveillance and create a graphic on the home page in the Dashboard, but only when we log on to Zabbix to see the problem (Problem) monitored, so in this article, the use of the trigger (trigger), and media (Media) and other configuration items to achieve when the trigger is triggered through different media, such as: nails, send ** action (action) **, achieve Real-time alarm notification function.

Due to the use of the media to the script alarm, an alarm is triggered by invoking article Python script, so you need to install pip and related modules on Zabbix Server host.

1, the media type disposed Alarm

  # Create Media Type

 

 

   # Configure

 

 

    

 

 2, followed by the new Python script, Zabbix Server configuration file can be configured to alert script path, the default is / usr / lib / zabbix / alertscripts

# View the alarm script path
# cat zabbix_server.conf | grep AlertScriptsPath
# Script written warning
# cd /usr/lib/zabbix/alertscripts
# vim pythonScript.py
#!/usr/bin/env python
#coding:utf-8

import requests,json,sys,os,datetime

# Nails robot address 
WebHook = " https://oapi.dingtalk.com/robot/send?access_token=your_dingding_robot_access_token "

# Corresponds {ALERT.SENDTO}, Zabbix media warning second parameter configuration interface 
User = the sys.argv [2 ]

# Corresponds {ALERT.MESSAGE}, Zabbix media alarm first parameter configuration interface 
text the sys.argv = [. 1 ]
data={
    "msgtype": "text",
    "text": {
        "content": text
    },
    "at": {
        "atMobiles": [
            user
        ],
        "isAtAll": False
    }
}
headers = {'Content-Type': 'application/json'}
x=requests.post(url=webhook,data=json.dumps(data),headers=headers)
# Gives scripts executable permissions
# chmod a+x /usr/lib/zabbix/alertscripts/pythonScript.py

3, the test

 

 

 

Guess you like

Origin www.cnblogs.com/douh/p/12575259.html