获取

描述

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

此方法允许检索符合所给参数的脚本。

参数

(object) 定义所需输出的参数。

此方法支持以下参数。

ParameterTypeDescription
groupidsstring/array仅能运行在所给主机组的脚本。
hostidsstring/array仅能运行在所给主机的脚本。
scriptidsstring/array仅返回所给ID的脚本。
usrgrpidsstring/array仅返回所给用户组可以运行的脚本。
selectGroupsquery返回可以在groups属性中运行脚本的主机组。
selectHostsquery返回可以在hosts属性中运行脚本的主机组。
sortfieldstring/array根据所给参数对参数进行排序

可能的值:scriptidname
countOutputboolean这些参数对于所有“get”方法都是通用的,在reference commentary 中有详细描述。
editableboolean
excludeSearchboolean
filterobject
limitinteger
outputquery
preservekeysboolean
searchobject
searchByAnyboolean
searchWildcardsEnabledboolean
sortorderstring/array
startSearchboolean

返回值

(integer/array) Returns either:

  • 一个数组对象。

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

示例如下

检索所有脚本

检索所有的已确认的脚本

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. }

猜你想看

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