媒介类型对象

以下对象与 mediatype API 直接相关。

媒体类型

媒体类型对象具有以下属性。

Property Type Description
mediatypeid ID 媒体类型的 ID。

Property behavior:
- 只读
- 更新操作时必需
name string 媒体类型名称。

Property behavior:
- 创建操作时必需
type integer 媒体类型使用的传输方式。

可能的值:
0 - Email;
1 - Script;
2 - SMS;
4 - Webhook。

Property behavior:
- 创建操作时必需
exec_path string 脚本文件名(例如 notification.sh),位于 AlertScriptsPath 服务器配置参数指定的目录中。

Property behavior:
- 当 type 设置为 "Script" 时必需
gsm_modem string GSM 调制解调器的串行设备名称。

Property behavior:
- 当 type 设置为 "SMS" 时必需
passwd string 认证密码。

Property behavior:
- 当 smtp_authentication 设置为 "Normal password" 时支持
provider integer 电子邮件提供商。

可能的值:
0 - (默认) 通用 SMTP;
1 - Gmail;
2 - Gmail relay;
3 - Office365;
4 - Office365 relay。
smtp_email string 发送通知所使用的电子邮件地址。

Property behavior:
- 当 type 设置为 "Email" 时必需
smtp_helo string SMTP HELO。

Property behavior:
- 当 type 设置为 "Email" 时支持
smtp_server string SMTP 服务器。

Property behavior:
- 当 type 设置为 "Email" 时必需
smtp_port integer 要连接的 SMTP 服务器端口。

默认值:25。

Property behavior:
- 当 type 设置为 "Email" 时支持
smtp_security integer 要使用的 SMTP 连接安全级别。

可能的值:
0 - (默认) 无;
1 - STARTTLS;
2 - SSL/TLS。

Property behavior:
- 当 type 设置为 "Email" 时支持
smtp_verify_host integer SMTP 的 SSL 主机验证。

可能的值:
0 - (默认) 否;
1 - 是。

Property behavior:
- 当 smtp_security 设置为 "STARTTLS" 或 "SSL/TLS" 时支持
smtp_verify_peer integer SMTP 的 SSL 对等方验证。

可能的值:
0 - (默认) 否;
1 - 是。

Property behavior:
- 当 smtp_security 设置为 "STARTTLS" 或 "SSL/TLS" 时支持
smtp_authentication integer 要使用的 SMTP 认证方式。

可能的值:
0 - (默认) 无;
1 - Normal password;
2 - OAuth token。
Office365 relay 电子邮件提供商不允许使用 OAuth 认证。

Property behavior:
- 当 type 设置为 "Email" 时支持
redirection_url string 用于重定向回 OAuth 授权的 Zabbix 前端 URL。

默认值:
API 设置属性 url 的值,附加 zabbix.php?action=oauth.authorize 部分

Property behavior:
- 当 smtp_authentication 设置为 "OAuth token" 时必需
client_id string 在 OAuth 授权服务器中注册的客户端标识符。

Property behavior:
- 当 smtp_authentication 设置为 "OAuth token" 时必需
client_secret string 在 OAuth 授权服务器中注册的客户端密钥。仅 Super Admin 类型用户可访问。

Property behavior:
- 当 smtp_authentication 设置为 "OAuth token" 时必需
authorization_url string 用于获取访问令牌和刷新令牌的 OAuth URL,带参数。

Property behavior:
- 当 smtp_authentication 设置为 "OAuth token" 时必需
token_url string 用于将授权令牌交换为访问令牌和刷新令牌的 OAuth URL。
服务器也会使用此 URL 刷新无效的访问令牌。

Property behavior:
- 当 smtp_authentication 设置为 "OAuth token" 时必需
tokens_status integer 令牌状态的位掩码。

可能的值:
0 - (默认) 两个令牌都包含无效值
1 - 访问令牌包含有效值
2 - 刷新令牌包含有效值
3 - 两个令牌都包含有效值。

Property behavior:
- 当 smtp_authentication 设置为 "OAuth token" 时支持
access_token string OAuth 访问令牌值。

Property behavior:
- 当 smtp_authentication 设置为 "OAuth token" 时必需
access_token_updated timestamp 服务器在使用 refresh_token 刷新时,或 API 在令牌变更时,对 access_token 进行最后修改的时间戳。

Property behavior:
- 当 smtp_authentication 设置为 "OAuth token" 时支持
access_expires_in integer access_token 失效并需要向 refresh_url 发起请求前的剩余秒数。
由 Zabbix 服务器在 access_token 刷新时或由 API 在令牌变更时设置。

时间戳通过加上 access_token_updated 的值计算得出。

Property behavior:
- 当 smtp_authentication 设置为 "OAuth token" 时支持
refresh_token string OAuth 刷新令牌值。

Property behavior:
- 当 smtp_authentication 设置为 "OAuth token" 时必需
status integer 媒体类型是否启用。

可能的值:
0 - (默认) 已启用;
1 - 已禁用。
username string 用户名。

Property behavior:
- 当 smtp_authentication 设置为 "Normal password" 时支持
maxsessions integer 可并行处理的告警最大数量。

type 设置为 "SMS" 时,可能的值:1。

type 设置为 "Email"、"Script" 或 "Webhook" 时,可能的值:0-100。

默认值:1。
maxattempts integer 发送告警的最大尝试次数。

可能的值:1-100。

默认值:3。
attempt_interval string 重试尝试之间的间隔。
接受秒数以及带后缀的时间单位。

可能的值:0-1h。

默认值:10s。
message_format integer 消息格式。

可能的值:
0 - 纯文本;
1 - (默认) HTML。

Property behavior:
- 当 type 设置为 "Email" 时支持
script text Webhook 脚本主体(JavaScript)。

Property behavior:
- 当 type 设置为 "Webhook" 时必需
timeout string Webhook 脚本超时。
接受秒数以及带后缀的时间单位。

可能的值:1-60s。

默认值:30s。

Property behavior:
- 当 type 设置为 "Webhook" 时支持
process_tags integer 将 Webhook 脚本响应中的 JSON 属性值作为标签处理。这些标签会添加到任何现有的问题标签中。

可能的值:
0 - (默认) 忽略 webhook 脚本响应;
1 - 将 webhook 脚本响应作为标签处理。

Property behavior:
- 当 type 设置为 "Webhook" 时支持
show_event_menu integer 事件菜单 中包含一个链接到自定义 URL 的条目。还会将 urls 属性添加到 problem.getevent.get 的输出中。

可能的值:
0 - (默认) 不包含事件菜单条目或 urls 属性;
1 - 包含事件菜单条目和 urls 属性。

Property behavior:
- 当 type 设置为 "Webhook" 时支持
event_menu_url string 用于 事件菜单 条目以及 problem.getevent.get 返回的 urls 属性中的 URL。

Property behavior:
- 当 show_event_menu 设置为 "Include event menu entry and urls property" 时支持
event_menu_name string 用于 事件菜单 条目以及 problem.getevent.get 返回的 urls 属性中的名称。

Property behavior:
- 当 show_event_menu 设置为 "Include event menu entry and urls property" 时支持
parameters array Webhookscript 参数。

Property behavior:
- 当 type 设置为 "Webhook" 或 "Script" 时支持
description text 媒体类型描述。

webhook 参数

webhook 参数具有以下属性。

属性 Type 说明
name string 参数名称。

属性行为
- 必填
value string 参数值,支持宏。
支持的宏请参见支持的宏页面。

脚本参数

脚本参数具有以下属性。

属性 类型 说明
sortorder integer 参数值将作为命令行参数传递给脚本时的顺序,从 0 开始,0 为第一个。

属性行为:
- 必填
value string 参数值,支持宏。
支持的宏请参见支持的宏页面。

消息模板

消息模板对象定义了一个模板,该模板将用作动作操作发送通知时的默认消息。它具有以下属性。

属性 类型 描述
eventsource integer 事件源。

可能的值:
0 - 触发器;
1 - 发现;
2 - 自动注册;
3 - 内部;
4 - 服务。

属性行为
- 必需
recovery integer 操作模式。

可能的值:
0 - 操作;
1 - 恢复操作;
2 - 更新操作。

属性行为
- 必需
subject string 消息主题。
message string 消息文本。