Zabbix-docking nailing robot interface
One: download the sender program
Zabbix nail alarm robot-sends an alarm message to the nail group chat (script written in go language, available with the-h view option)
Test:
. / golang-zabbix-robot-64-webhook=' https://oapi.dingtalk.com/roboxxxxxxxx'
At this point, your robot will send a message from Qiansi.com, indicating that golong is available.
Next, it's time to distinguish between the versions of your zabbix. Here are the configurations for 3.03.2 2.4.
Two: zabbix3.0 configuration
1. Deployment program
Copy the go script to the server warning directory AlertScriptspath and add execution permissions.
2. Create an alarm medium
3. Add users or groups and join the alarm media
4. Create actions and trigger sending conditions
Three: zabbix3.2 configuration
3.2is roughly the same as the 3.0configuration, except that some messages will not be delivered. Try to remove the line feeds in the above xml format and retest them.
Appendix:
Alarm message
{HOSTNAME1} {EVENT.DATE} {TRIGGER.SEVERITY} {TRIGGER.NAME} {TRIGGER.KEY1} {ITEM.LASTVALUE} {EVENT.ID} {HOST.IP} this is the link address {EVENT.AGE} {EVENT.STATUS} {EVENT.ACK.STATUS} {EVENT.ACK.HISTORY} that can be accessed by clicking on the alarm message.
Restore information
{HOSTNAME1} {EVENT.DATE} {TRIGGER.SEVERITY} {TRIGGER.NAME} {TRIGGER.KEY1} {ITEM.LASTVALUE} {EVENT.ID} {HOST.IP} FF4A934A the url here will replace the url {EVENT.AGE} {EVENT.RECOVERY.DATE} {EVENT.RECOVERY.TIME} {EVENT.RECOVERY.STATUS} of the alarm media.
Four: zabbix 2.4 configuration
Compared with version 3, 2.4 is classic but a little behind the times, and the company does not dare to upgrade hastily in order to maintain stability, so it can only configure 2.4 accordingly.
1. Deployment program
Also under the warning directory AlertScriptspath, add the script zabbix-dingding.sh
#! / bin/bash
Webhook= "https://oapi.dingtalk.com/robot/send?access_token=xxx"
/ zabbix/share/zabbix/alertscripts/golang-zabbix-robot-64-webhook=$webhook-msg= "$3"
2. Create an alarm medium
3. Create a user or group and join the alarm medium, as above
4. Create actions and trigger sending conditions in 3.2 format without line wrapping
-
Additional: general purpose robot
Sometimes we will use a custom monitoring script to monitor the status of the service, or a program, etc., how to connect to the nail?
#! / usr/bin/env python
# coding=utf-8
Import urllib
Import urllib2
Import json
Import re
F = open ('xxxxxxxxxx','r') # fetch the contents of the file and send it
Your_data = f.read ()
F.close ()
# print your_data
Headers = {'Content-Type':' application/json'}
Test_data = {
'msgtype': "text"
"text": {
'content': 's' your_data
}
"at": {
"atMobiles": [
# "you iphone"
]
"isAtAll": "false"
}
}
# requrl = "https://oapi.dingtalk.com/robot/send?access_token=xxxxxxxxxxxxxxxxxxxxxxxx"
Req = urllib2.Request (url = requrl,headers = headers,data = json.dumps (test_data))
Response = urllib2.urlopen (req)