> 脚本 object

以下objects与script API直接相关.

脚本

脚本object具有以下属性.

属性 数据类型 描述
scriptid string (只读) 脚本的ID.
name
(required)
string 脚本名称.
type
(required)
integer 脚本类型.

可选值:
0 - 脚本;
1 - IPMI;
2 - SSH;
3 - Telnet;
5 - (默认) Webhook.
command
(required)
string 要run执行的命令.
scope integer 脚本作用域.

可选值:
1 - 默认 动作操作;
2 - 手动主机操作;
4 - 手动事件操作.
execute_on integer Where to run the script.
Used if type is 0 (script).

Possible values:
0 - run on Zabbix agent;
1 - run on Zabbix server;
2 - (default) run on Zabbix server (proxy).
menu_path string Folders separated by slash that form a menu like navigation in frontend when clicked on host or event.
Used if scope is 2 or 4.
authtype integer Authentication method used for SSH script type.
Used if type is 2.

Possible values:
0 - password;
1 - public key.
username string User name used for authentication.
Required if type is 2 or 3.
password string Password used for SSH scripts with password authentication and Telnet scripts.
Used if type is 2 and authtype is 0 or type is 3.
publickey string Name of the public key file used for SSH scripts with public key authentication.
Required if type is 2 and authtype is 1.
privatekey string Name of the private key file used for SSH scripts with public key authentication.
Required if type is 2 and authtype is 1.
port string Port number used for SSH and Telnet scripts.
Used if type is 2 or 3.
groupid string ID of the host group that the script can be run on. If set to 0, the script will be available on all host groups.

Default: 0.
usrgrpid string ID of the user group that will be allowed to run the script. If set to 0, the script will be available for all user groups.
Used if scope is 2 or 4.

Default: 0.
host_access integer 主机执行脚本run所需的权限.
scope24时使用.

可选值:
2 - (默认) 读;
3 - 写.
confirmation string 确认弹窗文本. 当从Zabbix前端尝试run脚本时会显示该弹窗.
scope24时使用.
timeout string Webhook脚本执行超时时间(秒). 支持时间后缀, 例如30s, 1m.
type5时必须设置.

可选值:
1-60s

默认值:
30s
parameters array webhook输入参数的array.
type5时使用.
description string 脚本描述.

注意对于某些方法(update, delete), 所需/可选参数组合会有所不同.

Webhook 参数

当调用webhook脚本时传递的参数具有以下属性。

属性 数据类型 描述
name
(required)
string 参数名称。
value string 参数值。支持macros

调试

已执行的webhook脚本调试信息。该调试object具有以下属性。

属性 数据类型 描述
logs array 日志条目的array。
ms string 脚本执行时长(毫秒)。

日志条目

日志条目object具有以下属性。

属性 数据类型 描述
level integer 日志级别。
ms string 自脚本run后到添加日志条目为止经过的毫秒数。
message string 日志消息。