2022 Zabbix中国峰会
2022 Zabbix中国峰会

script.update

Description说明

object script.update(object/array scripts)

This method allows to update existing scripts此方法允许更新现有脚本.

Parameters参数

(object/array) Script properties to be updated被更新.

The scriptid property must be defined for each script, all other properties are optional. Only the passed properties will be updated, all others will remain unchanged. 必须为每个脚本定义scriptid属性,所有其他属性都是可选的。只有通过的属性将被更新,所有其他属性将保持不变。

Return values返回值

(object) Returns an object containing the IDs of the updated scripts under the scriptids property. (object)返回一个包含scriptids属性下更新脚本的ID的对象。

Examples范例

Change script command更改脚本命令

Change the command of the script to "/bin/ping -c 10 {HOST.CONN} 2>&1".将脚本的命令更改为"/bin/ping -c 10 {HOST.CONN} 2>&1".

Request请求:

{
           "jsonrpc": "2.0",
           "method": "script.update",
           "params": {
               "scriptid": "1",
               "command": "/bin/ping -c 10 {HOST.CONN} 2>&1"
           },
           "auth": "038e1d7b1735c6a5436ee9eae095879e",
           "id": 1
       }

Response响应:

{
           "jsonrpc": "2.0",
           "result": {
               "scriptids": [
                   "1"
               ]
           },
           "id": 1
       }

Source源码

CScript::update() in frontends/php/include/classes/api/services/CScript.php.