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.

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.
usrgrpidsstring/arrayReturn only scripts that can be run by users in the given user groups.
selectGroupsqueryReturn a groups property with host groups that the script can be run on.
selectHostsqueryReturn a hosts property with hosts that the script can be run on.
sortfieldstring/arraySort the result by the given properties.

Possible values are: scriptid and name.
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.

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 ui/include/classes/api/services/CScript.php.