application.get

说明

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

该方法用于根据规定的参数获取应用集。

参数

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

该方法提供以下参数。

ParameterTypeDescription
applicationidsstring/array只返回指定 ID 的应用集。
groupidsstring/array只返回指定主机组所属主机的应用集。
hostidsstring/array只返回指定主机所属的应用集。
inheritedboolean如果设定为true,只返回继承该模板的应用集。
itemidsstring/array只返回包含特定监控项的应用集。
templatedboolean如果设定为true,只返回属于该模板的应用集。
templateidsstring/array只返回指定模板的应用集。
selectHostquery返回值中会包括应用集所属的主机名属性。
selectItemsquery返回值中会应用集包含的监控项属性。
selectDiscoveryRulequery返回值中会包括应用集的底层自动发现规则属性。
selectApplicationDiscoveryquery返回值中会包括应用集发现的对象属性。
sortfieldstring/array使用规定的属性将结果分类。

可能的值:applicationidname
countOutputbooleanreference commentary 中详细描述了所有“get”方法的相关参数.
editableboolean
excludeSearchboolean
filterobject
limitinteger
outputquery
preservekeysboolean
searchobject
searchByAnyboolean
searchWildcardsEnabledboolean
sortorderstring/array
startSearchboolean

返回值

(integer/array) 返回两者其中之一:

  • an array of objects;

  • 如果已经使用了“countOutput”参数,则检索对象的计数.

范例

从主机中检索应用集

从主机中根据名称排序检索所有的应用集。

请求:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "application.get",
  4. "params": {
  5. "output": "extend",
  6. "hostids": "10001",
  7. "sortfield": "name"
  8. },
  9. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  10. "id": 1
  11. }

响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "applicationid": "13",
  6. "hostid": "10001",
  7. "name": "CPU",
  8. "templateids": []
  9. },
  10. {
  11. "applicationid": "5",
  12. "hostid": "10001",
  13. "name": "Filesystems",
  14. "templateids": []
  15. },
  16. {
  17. "applicationid": "21",
  18. "hostid": "10001",
  19. "name": "General",
  20. "templateids": []
  21. },
  22. {
  23. "applicationid": "15",
  24. "hostid": "10001",
  25. "name": "Memory",
  26. "templateids": []
  27. },
  28. ],
  29. "id": 1
  30. }

See also

Source

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

Description

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

The method allows to retrieve applications according to the given parameters.

Parameters

(object) Parameters defining the desired output.

The method supports the following parameters.

ParameterTypeDescription
applicationidsstring/arrayReturn only applications with the given IDs.
groupidsstring/arrayReturn only applications that belong to hosts from the given host groups.
hostidsstring/arrayReturn only applications that belong to the given hosts.
inheritedbooleanIf set to true return only applications inherited from a template.
itemidsstring/arrayReturn only applications that contain the given items.
templatedbooleanIf set to true return only applications that belong to templates.
templateidsstring/arrayReturn only applications that belong to the given templates.
selectHostqueryReturn the host that the application belongs to in the host property.
selectItemsqueryReturn the items contained in the application in the items property.
selectDiscoveryRulequeryReturn the LLD rule that created the application in the discoveryRule property.
selectApplicationDiscoveryqueryReturn the application discovery object in the applicationDiscovery property.
sortfieldstring/arraySort the result by the given properties.

Possible values are: applicationid and name.
countOutputbooleanThese parameters being common for all get methods are described in detail in the reference commentary page.
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

Retrieving applications from a host

Retrieve all applications from a host sorted by name.

Request:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "application.get",
  4. "params": {
  5. "output": "extend",
  6. "hostids": "10001",
  7. "sortfield": "name"
  8. },
  9. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  10. "id": 1
  11. }

Response:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "applicationid": "13",
  6. "hostid": "10001",
  7. "name": "CPU",
  8. "templateids": []
  9. },
  10. {
  11. "applicationid": "5",
  12. "hostid": "10001",
  13. "name": "Filesystems",
  14. "templateids": []
  15. },
  16. {
  17. "applicationid": "21",
  18. "hostid": "10001",
  19. "name": "General",
  20. "templateids": []
  21. },
  22. {
  23. "applicationid": "15",
  24. "hostid": "10001",
  25. "name": "Memory",
  26. "templateids": []
  27. },
  28. ],
  29. "id": 1
  30. }

See also

Source

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