[comment]: # aside: 1

[comment]: # translation:outdated

[comment]: # ({43284bfe-8b1700c1})
# 脚本对象

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

[comment]: # ({/43284bfe-8b1700c1})

[comment]: # ({9a539156-9c6db006})
### 脚本
脚本对象有以下参数。
|属性|[类型](/manual/api/reference_commentary#数据_类型)|描述|
|--------|---------------------------------------------------|-----------|
|scriptid|string|*(只读)* 脚本ID。|
|**name**<br>(必需)|string|脚本名称。|
|**type**<br>(必需)|integer|脚本类型。<br><br>可能的值：<br>0 - 脚本；<br>1 - IPMI；<br>2 - SSH；<br>3 - Telnet；<br>5 - *(默认)* Webhook。|
|**command**<br>(必需)|string|运行的命令。|
|scope|integer|脚本范围。<br><br>可能的值：<br>1 - *默认* 动作操作；<br>2 - 手动主机动作；<br>4 - 手动事件动作。|
|execute\_on|integer|在哪里运行脚本。<br>当 `type` 为 `0`时使用 （脚本）。<br><br>可能的值：<br>0 - 在 Zabbix agent上运行；<br>1 - 在 Zabbix server上运行;<br>2 - *(默认)* 在 Zabbix server (proxy)上运行。|
|menu\_path|string|当点击主机或事件时，由斜杠分隔的文件夹所组成的类似于前端导航的菜单。<br>当 `scope` 为 `2` 或 `4`时使用。|
|authtype|integer|SSH脚本类型使用的身份验证方法。<br>当 `type` 为 `2`时使用。<br><br>可能的值：<br>0 - 密码；<br>1 - 公钥。|
|username|string|身份验证使用的用户名<br>当 `type` 为 `2` 或 `3`时需要。|
|password|string|通过密码进行身份验证的SSH脚本和Telnet脚本使用的密码。<br>当`type` 为 `2` 且 `authtype` 为 `0` 或 `type` 为 `3`时使用。|
|publickey|string|通过公钥进行身份验证的SSH脚本使用的公钥文件名。<br>当`type` 为 `2` 且 `authtype` 为 `1`时需要。|
|privatekey|string|通过公钥进行身份验证的SSH脚本使用的私钥文件名。<br>当`type` 为 `2` 且 `authtype` 为 `1`时需要。|
|port|string|SSH 和 Telnet 脚本使用的端口号。<br>当`type` 为 `2` 或 `3`时使用。|
|groupid|string|可以运行脚本的主机群组ID。如果设置为 0， 脚本将可以在所有主机群组运行。<br><br>默认值： 0。|
|usrgrpid|string|允许运行脚本的用户群组ID。如果设置为 0, 脚本将可以在所有用户群组运行。<br>当`scope` 为 `2` 或 `4`时使用。<br><br>默认值: 0.|
|host\_access|integer|运行脚本所需的主机权限。<br>当`scope`为 `2` 或 `4`时使用。<br><br>可能的值：<br>2 - *(默认)* 读;<br>3 - 写.|
|confirmation|string|弹出窗口的确认文本。如果尝试在zabbix前端运行脚本，将会弹出窗口。<br>当`scope` 为 `2` 或 `4`时使用。|
|timeout|string|Webhook脚本执行超时秒数。 支持时间后缀, 例如 30s，1m。<br>当`type` 为 `5`时需要。<br><br>可能的值：<br>1-60s<br><br>默认值：<br>30s|
|parameters|array|[webhook入参数组](/manual/api/reference/script/object#Webhook parameters).<br>当`type` 为 `5`时使用。|
|description|string|脚本描述。|
|url|string|用户定义的URL.<br><br>[Property behavior](/manual/api/reference_commentary#property-behavior):<br>- *required* if `type` is set to "URL"|
|new_window|integer|在新窗口中打开URL。.<br><br>可能的值：<br>0 - No比可用;<br>1 - *(default默认)* Yes.可用<br><br>[Property behavior](/manual/api/reference_commentary#property-behavior):<br>- *supported* if `type` is set to "URL"|
|manualinput|integer|Indicates whether the script accepts user-provided input.指示脚本是否接受用户提供的输入。<br><br>Possible values:参考值<br>0 - *(default默认)* Disabledvu直至;<br>1 - Enabled;支持<br><br>[Property behavior](/manual/api/reference_commentary#property-behavior):<br>- *supported* if `scope` is set to "manual host action" or "manual event action"|
|manualinput_prompt|string|Manual input prompt text.手动输入提示文本。<br><br>[Property behavior](/manual/api/reference_commentary#property-behavior):<br>- *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.用于验证用户提供的输入的字符串字段。该字符串由一个正则表达式或一组用逗号分隔的值组成。<br><br>[Property behavior](/manual/api/reference_commentary#property-behavior):<br>- *required* if `manualinput` is set to "Enabled"|
|manualinput_validator_type|integer|Determines the type of user input expected.确定所需的用户输入类型。<br><br>Possible values:<br>0 - *(default)* String. Indicates that manualinput_validator is to be treated as a regular expression;（默认）字符串。表示manualinput_validator将被视为正则表达式；<br>1 - List. Indicates that manualinput_validator is to be treated as a comma-separated list of possible input values.1-列表。指示manualinput_validator将被视为可能输入值的逗号分隔列表。<br><br>[Property behavior](/manual/api/reference_commentary#property-behavior):<br>- *supported* if `manualinput` is set to "Enabled"|
|manualinput_default_value|string|Default value for auto-filling user input.自动填充用户输入的默认值。<br><br>[Property behavior](/manual/api/reference_commentary#property-behavior):<br>- *supported* if `manualinput_validator_type` is set to "String"|

[comment]: # ({/9a539156-9c6db006})

[comment]: # ({24e86350-05b0e37d})
### Webhook参数
webhook脚本运行时被传入的参数有如下属性。
|属性|[类型](/manual/api/reference_commentary#数据_类型)|描述|
|--------|---------------------------------------------------|-----------|
|**name**<br>(必需)|string|参数名称|
|value|string|参数值。 支持[宏](/manual/appendix/macros/supported_by_location)|

[comment]: # ({/24e86350-05b0e37d})

[comment]: # ({5ab53a02-587d2fd0})
### 调试

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

[comment]: # ({/5ab53a02-587d2fd0})

[comment]: # ({63401e0b-8ea23127})
### 日志条目
日志条目对象有如下属性
|属性|[类型](/manual/api/reference_commentary#数据_类型)|描述|
|--------|---------------------------------------------------|-----------|
|level|integer|日志等级。|
|ms|string|从脚本开始运行到添加日志条目前经过时间（毫秒）。|
|message|string|日志信息。|

[comment]: # ({/63401e0b-8ea23127})
