script.get

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定义所需输出的参数.

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

Parameter参数 Type类型 Description说明
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 flagThese 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

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.