integer/array script.get(object parameters)
The method allows to retrieve scripts according to the given parameters该方法允许根据给定的参数检索脚本.
(object) Parameters defining the desired output定义所需输出的参数.
The method supports the following parameters该方法支持以下参数.
| Parameter参数 T | pe类型 Des | ription说明 |
|---|---|---|
| groupids | string/array | Return only scripts that can be run on the given host groups只返回可以在指定主机组上运行的脚本. |
| hostids | string/array | Return only scripts that can be run on the given hosts只返回可以在指定主机上运行的脚本. |
| scriptids | string/array | Return only scripts with the given IDs只返回具有指定ID的脚本. |
| usrgrpids | string/array | Return only scripts that can be run by users in the given user groups只返回指定用户组中的用户可以运行的脚本. |
| selectGroups | query | Return host groups that the script can be run on in the groups property返回在groups属性中可运行脚本的主机组. |
| selectHosts | query | Return hosts that the script can be run on in the hosts property返回在hosts属性中可运行脚本的主机. |
| sortfield | string/array | Sort the result by the given properties按指定的属性对结果分类. Possible values are可能的值为: scriptid and和 name. |
| countOutput | flag | These parameters being common for all get methods are described in detail in the reference commentary. 在reference commentary中详细描述了所有“get”方法的这些参数。 |
| editable | boolean | |
| excludeSearch | flag | |
| filter | object | |
| limit | integer | |
| output | query | |
| preservekeys | flag | |
| search | object | |
| searchByAny | boolean | |
| searchWildcardsEnabled | boolean | |
| sortorder | string/array | |
| startSearch | flag |
(integer/array) Returns either返回两者其中任一:
countOutput parameter has been used如果已经使用了countOutput参数,则检索对象的计数.Retrieve all configured scripts检索所有已配置的脚本.
Request请求:
{ "jsonrpc": "2.0", "method": "script.get", "params": { "output": "extend" }, "auth": "038e1d7b1735c6a5436ee9eae095879e", "id": 1 }Response响应:
{ "jsonrpc": "2.0", "result": [ { "scriptid": "1", "name": "Ping", "command": "/bin/ping -c 3 {HOST.CONN} 2>&1", "host_access": "2", "usrgrpid": "0", "groupid": "0", "description": "", "confirmation": "", "type": "0", "execute_on": "1" }, { "scriptid": "2", "name": "Traceroute", "command": "/usr/bin/traceroute {HOST.CONN} 2>&1", "host_access": "2", "usrgrpid": "0", "groupid": "0", "description": "", "confirmation": "", "type": "0", "execute_on": "1" }, { "scriptid": "3", "name": "Detect operating system", "command": "sudo /usr/bin/nmap -O {HOST.CONN} 2>&1", "host_access": "2", "usrgrpid": "7", "groupid": "0", "description": "", "confirmation": "", "type": "0", "execute_on": "1" } ], "id": 1 }CScript::get() in frontends/php/include/classes/api/services/CScript.php.