脚本对象

以下对象与 脚本 API直接相关。

脚本

脚本对象有以下参数。 属性 类型 描述
scriptid string (只读) 脚本ID。
name
(必需)
string 脚本名称。
type
(必需)
integer 脚本类型。

可能的值:
0 - 脚本;
1 - IPMI;
2 - SSH;
3 - Telnet;
5 - (默认) Webhook。
command
(必需)
string 运行的命令。
scope integer 脚本范围。

可能的值:
1 - 默认 动作操作;
2 - 手动主机动作;
4 - 手动事件动作。
execute_on integer 在哪里运行脚本。
type0时使用 (脚本)。

可能的值:
0 - 在 Zabbix agent上运行;
1 - 在 Zabbix server上运行;
2 - (默认) 在 Zabbix server (proxy)上运行。
menu_path string 当点击主机或事件时,由斜杠分隔的文件夹所组成的类似于前端导航的菜单。
scope24时使用。
authtype integer SSH脚本类型使用的身份验证方法。
type2时使用。

可能的值:
0 - 密码;
1 - 公钥。
username string 身份验证使用的用户名
type23时需要。
password string 通过密码进行身份验证的SSH脚本和Telnet脚本使用的密码。
type2authtype0type3时使用。
publickey string 通过公钥进行身份验证的SSH脚本使用的公钥文件名。
type2authtype1时需要。
privatekey string 通过公钥进行身份验证的SSH脚本使用的私钥文件名。
type2authtype1时需要。
port string SSH 和 Telnet 脚本使用的端口号。
type23时使用。
groupid string 可以运行脚本的主机群组ID。如果设置为 0, 脚本将可以在所有主机群组运行。

默认值: 0。
usrgrpid string 允许运行脚本的用户群组ID。如果设置为 0, 脚本将可以在所有用户群组运行。
scope24时使用。

默认值: 0.
host_access integer 运行脚本所需的主机权限。
scope24时使用。

可能的值:
2 - (默认) 读;
3 - 写.
confirmation string 弹出窗口的确认文本。如果尝试在zabbix前端运行脚本,将会弹出窗口。
scope24时使用。
timeout string Webhook脚本执行超时秒数。 支持时间后缀, 例如 30s,1m。
type5时需要。

可能的值:
1-60s

默认值:
30s
parameters array [webhook入参数组](/manual/api/reference/script/object#Webhook parameters).
type5时使用。
description string 脚本描述。
url string 用户定义的URL.

Property behavior:
- required if type is set to "URL"
new_window integer 在新窗口中打开URL。.

可能的值:
0 - No比可用;
1 - (default默认) Yes.可用

Property behavior:
- supported if type is set to "URL"
manualinput integer Indicates whether the script accepts user-provided input.指示脚本是否接受用户提供的输入。

Possible values:参考值
0 - (default默认) Disabledvu直至;
1 - Enabled;支持

Property behavior:
- supported if scope is set to "manual host action" or "manual event action"
manualinput_prompt string Manual input prompt text.手动输入提示文本。

Property behavior:
- required if manualinput is set to "Enabled"
manualinput_validator string A character string field used to validate the user provided input. The string consists of either a regular expression or a set of values separated by commas.用于验证用户提供的输入的字符串字段。该字符串由一个正则表达式或一组用逗号分隔的值组成。

Property behavior:
- required if manualinput is set to "Enabled"
manualinput_validator_type integer Determines the type of user input expected.确定所需的用户输入类型。

Possible values:
0 - (default) String. Indicates that manualinput_validator is to be treated as a regular expression;(默认)字符串。表示manualinput_validator将被视为正则表达式;
1 - List. Indicates that manualinput_validator is to be treated as a comma-separated list of possible input values.1-列表。指示manualinput_validator将被视为可能输入值的逗号分隔列表。

Property behavior:
- supported if manualinput is set to "Enabled"
manualinput_default_value string Default value for auto-filling user input.自动填充用户输入的默认值。

Property behavior:
- supported if manualinput_validator_type is set to "String"

Webhook参数

webhook脚本运行时被传入的参数有如下属性。 属性 类型 描述
name
(必需)
string 参数名称
value string 参数值。 支持

调试

运行的webhook脚本的调试信息。调试对象有如下属性。 属性 类型 描述
logs array [日志条目]数组(/manual/api/reference/script/object#日志条目)。
ms string 脚本运行毫秒数。

日志条目

日志条目对象有如下属性 属性 类型 描述
level integer 日志等级。
ms string 从脚本开始运行到添加日志条目前经过时间(毫秒)。
message string 日志信息。