# 10.3 zabbix添加报警媒介

进入zabbix-web，点击Administrator-->Media types-->Create Media type

## 添加Email报警

![](/files/-Lyb53j2Syepb05aSrBy)

## 添加钉钉报警

![image-20200115103302741](/files/-Lyb3uvwKxHt8ayDLSpm)

图中Script内容如下

```javascript
try {
    Zabbix.Log(4, 'dingding webhook script value='+value)

    var result = {
        'tags': {
            'endpoint': 'ding'
        }
    },
    params = JSON.parse(value),
    req = new CurlHttpRequest(),
    fields = {},
    resp;

    req.AddHeader('Content-Type: application/json');

    fields.msgtype = params.msgtype;
    fields.text = {
      "content":params.content
    };
    resp = req.Post('https://oapi.dingtalk.com/robot/send?access_token=1163d78d7b8a324d2f5b284414da8e93560008689744495ab4ad3eae14bdd642',
        JSON.stringify(fields)
    );

    if (req.Status() != 201) {
        throw 'Response code: '+req.Status();
    }

    resp = JSON.parse(resp);
    result.tags.issue_id = resp.id;
    result.tags.issue_key = resp.key;
} catch (error) {
    Zabbix.Log(4, 'jira issue creation failed json : '+JSON.stringify({"fields": fields}));
    Zabbix.Log(4, 'jira issue creation failed : '+error);

    result = {};
}

return JSON.stringify(result);
```

这个webhook添加钉钉报警，多亏了我的对象，香香大人，谢谢她！

> 参考官方文档：<https://www.zabbix.com/documentation/current/manual/config/notifications/media/webhook>

添加完告警媒介，就可以给用户Administrator用户，添加这两个报警媒介了。


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://wiki.clay-wangzhi.com/10-zabbix/10.3-zabbix-tian-jia-bao-jing-mei-jie.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
