获取

Description 描述

integer/array script.get(object **parameters**)

The method allows to retrieve scripts according to the given parameters. 此方法允许检索符合所给参数的脚本

Parameters 参数

(object) Parameters defining the desired output. (object) 定义所需输出的参数。

The method supports the following parameters. 此方法支持以下参数

ParameterTypeDescription
groupidsstring/arrayReturn only scripts that can be run on the given host groups. 仅能运行在所给主机组的脚本
hostidsstring/arrayReturn only scripts that can be run on the given hosts. 仅能运行在所给主机的脚本
scriptidsstring/arrayReturn only scripts with the given IDs. 仅返回所给IDs的脚本
usrgrpidsstring/arrayReturn only scripts that can be run by users in the given user groups. 仅返回所给用户组可以运行的脚本
selectGroupsqueryReturn host groups that the script can be run on in the groups property. 返回可以在groups属性中运行脚本的主机组。
selectHostsqueryReturn hosts that the script can be run on in the hosts property. 返回可以在hosts属性中运行脚本的主机组。
sortfieldstring/arraySort the result by the given properties.

Possible values are: scriptid and name. 根据所给参数对参数进行排序
\可能的值:scriptidname
countOutputbooleanThese parameters being common for all get methods are described in detail in the reference commentary.
editableboolean
excludeSearchboolean
filterobject
limitinteger
outputquery
preservekeysboolean
searchobject
searchByAnyboolean
searchWildcardsEnabledboolean
sortorderstring/array
startSearchboolean

Return values 返回值

(integer/array) Returns either:

  • an array of objects;

  • the count of retrieved objects, if the countOutput parameter has been used.

  • 一个数组对象

  • 检索到对象的数目,如果countOutput参数被使用

Examples 示例如下

Retrieve all scripts 检索所有脚本

Retrieve all configured scripts. 检索所有的已确认的脚本

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "script.get",
  4. "params": {
  5. "output": "extend"
  6. },
  7. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  8. "id": 1
  9. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "scriptid": "1",
  6. "name": "Ping",
  7. "command": "/bin/ping -c 3 {HOST.CONN} 2>&1",
  8. "host_access": "2",
  9. "usrgrpid": "0",
  10. "groupid": "0",
  11. "description": "",
  12. "confirmation": "",
  13. "type": "0",
  14. "execute_on": "1"
  15. },
  16. {
  17. "scriptid": "2",
  18. "name": "Traceroute",
  19. "command": "/usr/bin/traceroute {HOST.CONN} 2>&1",
  20. "host_access": "2",
  21. "usrgrpid": "0",
  22. "groupid": "0",
  23. "description": "",
  24. "confirmation": "",
  25. "type": "0",
  26. "execute_on": "1"
  27. },
  28. {
  29. "scriptid": "3",
  30. "name": "Detect operating system",
  31. "command": "sudo /usr/bin/nmap -O {HOST.CONN} 2>&1",
  32. "host_access": "2",
  33. "usrgrpid": "7",
  34. "groupid": "0",
  35. "description": "",
  36. "confirmation": "",
  37. "type": "0",
  38. "execute_on": "1"
  39. }
  40. ],
  41. "id": 1
  42. }

See also

Source

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