获取

Description 说明

integer/array triggerprototype.get(object parameters)

The method allows to retrieve trigger prototypes according to the given parameters. 此方法允许根据指定的参数检索触发器原型。

Parameters 参数

(object) Parameters defining the desired output. (object)定义需要输出的参数。 The method supports the following parameters. 该方法支持以下参数。

Parameter 参数 Tpe 类型 Desription 说明
activeflag 标记 Rturn only enabled trigger prototypes that belong to monitored hosts. 仅返回所属被监控主机的已启用触发器原型。
applicationidsstring/array 字符串/数组 Retun only trigger prototypes that contain items from the given applications. 仅返回来自指定应用集中包含监控项的触发器原型。
discoveryidsstring/array 字符串/数组 Retun only trigger prototypes that belong to the given LLD rules. 仅返回所属指定低级别发现规则的触发器原型。
functionsstring/array 字符串/数组 Retun only triggers that use the given functions. 仅返回使用指定函数的触发器。

Refer to the supported trigger functions page for a list of supported functions. 有关支持的功能列表,请参阅supported trigger functions 页面。
groupstring 字符串 Reurn only trigger prototypes that belong to hosts from the host groups with the given name. 仅返回来自指定名称的主机组中所属主机的触发器原型。
groupidsstring/array 字符串/数组 Retun only trigger prototypes that belong to hosts from the given host groups. 仅返回来自指定主机组中所属主机的触发器原型。
hoststring 字符串 Reurn only trigger prototypes that belong to hosts with the given name. 仅返回指定名称的所属主机的触发器原型。
hostidsstring/array 字符串/数组 Retun only trigger prototypes that belong to the given hosts. 仅返回指定主机所属的触发器原型。
inheritedboolean 布尔值 Ifset to true return only trigger prototypes inherited from a template. 仅返回从模板继承的触发器原型,如果设置为true
maintenanceboolean 布尔值 Ifset to true return only enabled trigger prototypes that belong to hosts in maintenance. 仅返回在维护中所属主机的已启用触发器原型,如果设置为true
min_severityinteger 整数型 Reurn only trigger prototypes with severity greater or equal than the given severity. 仅返回严重级别大于或等于指定严重级别的触发器原型。
monitoredflag 标记 Rturn only enabled trigger prototypes that belong to monitored hosts and contain only enabled items. 仅返回所属被监控主机的已启用触发器原型,并包含已启用的监控项。
templatedboolean 布尔值 Ifset to true return only trigger prototypes that belong to templates. 仅返回所属模板的触发器原型,如果设置为true
templateidsstring/array 字符串/数组 Retun only trigger prototypes that belong to the given templates. 仅返回指定模板所属的触发器原型。
triggeridsstring/array 字符串/数组 Retun only trigger prototypes with the given IDs. 仅返回指定ID的触发器原型。
expandExpressionflag 标记 Epand functions and macros in the trigger expression. 展开在触发器原型表达式中的函数和宏。
selectDiscoveryRulequery 查询 Rturn the LLD rule that the trigger prototype belongs to. 返回触发器原型所属的低级别发现规则。
selectFunctionsquery 查询 Rturn functions used in the trigger prototype in the functions property. 返回在functions属性中在触发器中使用的函数。

The function objects represents the functions used in the trigger expression and has the following properties: 函数对象代表使用在触发器表达式中的函数,并具有以下属性:
functionid - (string 字符串) ID of the function; 函数的ID;
itemid - (string 字符串) ID of the item used in the function; 使用在函数中的监控项ID;
function - (string 字符串) name of the function; 函数的名称;
parameter - (string 字符串) parameter passed to the function. 传递给函数的参数。
selectGroupsquery 查询 Rturn the host groups that the trigger prototype belongs to in the groups property. 返回在groups属性中触发器原型所属的主机组。
selectHostsquery 查询 Rturn the hosts that the trigger prototype belongs to in the hosts property. 返回在hosts属性中触发器所属的主机。
selectItemsquery 查询 Rturn items and item prototypes used the trigger prototype in the items property. 返回在items属性中触发器所包含的监控项。
selectDependenciesquery 查询 Rturn trigger prototypes and triggers that the trigger prototype depends on in the dependencies property. 返回在dependencies属性中依赖触发器原型的触发器原型和触发器。
selectTagsquery 查询 Rturn the trigger prototype tags in tags property. 返回在tags属性中触发器原型标签。
filterobject 对象 Rturn only those results that exactly match the given filter. 仅返回与指定筛选完全匹配的结果。

Accepts an array, where the keys are property names, and the values are either a single value or an array of values to match against. 接受一个数组,其中键为属性名称,值为单个值或要匹配值的数组。

Supports additional filters: 支持额外的筛选:
host - technical name of the host that the trigger prototype belongs to; 触发器原型所属主机的正式名称。
hostid - ID of the host that the trigger prototype belongs to. 触发器原型所属主机的ID。
limitSelectsinteger 整数型 Liits the number of records returned by subselects. 限制子查询返回的记录数量。

Applies to the following subselects: 适用于以下子查询:
selectHosts - results will be sorted by host. 以host分类结果。
sortfieldstring/array 字符串/数组 Sortthe result by the given properties. 由指定属性分类结果。

Possible values are: triggerid, description, status and priority. 许可值为:triggerid, description, statuspriority
countOutputboolean 布尔值 Thse parameters being common for all get methods are described in detail in the reference commentary. 这些参数十分普遍,适用于所有get方法,详情可参考reference commentary
editableboolean 布尔值 ::
excludeSearchboolean 布尔值 ::
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 trigger prototypes from an LLD rule 从低级别发现规则中检索触发器原型

Retrieve all trigger prototypes and their functions from an LLD rule. 从低级别发现规则中检索所有的触发器原型和相关函数。

Request 请求:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "triggerprototype.get",
  4. "params": {
  5. "output": "extend",
  6. "selectFunctions": "extend",
  7. "discoveryids": "22450"
  8. },
  9. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  10. "id": 1
  11. }

Response 响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "functions": [
  6. {
  7. "functionid": "12598",
  8. "itemid": "22454",
  9. "function": "last",
  10. "parameter": "0"
  11. }
  12. ],
  13. "triggerid": "13272",
  14. "expression": "{12598}<20",
  15. "description": "Free inodes is less than 20% on volume {#FSNAME}",
  16. "url": "",
  17. "status": "0",
  18. "priority": "2",
  19. "comments": "",
  20. "templateid": "0",
  21. "type": "0",
  22. "flags": "2",
  23. "recovery_mode": "0",
  24. "recovery_expression": "",
  25. "correlation_mode": "0",
  26. "correlation_tag": "",
  27. "manual_close": "0"
  28. },
  29. {
  30. "functions": [
  31. {
  32. "functionid": "13500",
  33. "itemid": "22686",
  34. "function": "last",
  35. "parameter": "0"
  36. }
  37. ],
  38. "triggerid": "13266",
  39. "expression": "{13500}<201",
  40. "description": "Free disk space is less than 20% on volume {#FSNAME}",
  41. "url": "",
  42. "status": "0",
  43. "priority": "2",
  44. "comments": "",
  45. "templateid": "0",
  46. "type": "0",
  47. "flags": "2",
  48. "recovery_mode": "0",
  49. "recovery_expression": "",
  50. "correlation_mode": "0",
  51. "correlation_tag": "",
  52. "manual_close": "0"
  53. }
  54. ],
  55. "id": 1
  56. }

Retrieving a specific trigger prototype with tags 根据标签检索特定的触发器原型

Request 请求:

  1. {
  2. "jsonrpc": "2.0",
  3. "method": "triggerprototype.get",
  4. "params": {
  5. "output": [
  6. "triggerid",
  7. "description"
  8. ]
  9. "selectTags": "extend",
  10. "triggerids": [
  11. "17373"
  12. ]
  13. },
  14. "auth": "038e1d7b1735c6a5436ee9eae095879e",
  15. "id": 1
  16. }

Response 响应:

  1. {
  2. "jsonrpc": "2.0",
  3. "result": [
  4. {
  5. "triggerid": "17373",
  6. "description": "Free disk space is less than 20% on volume {#FSNAME}",
  7. "tags": [
  8. {
  9. "tag": "volume",
  10. "value": "{#FSNAME}"
  11. },
  12. {
  13. "tag": "type",
  14. "value": "{#FSTYPE}"
  15. }
  16. ]
  17. }
  18. ],
  19. "id": 1
  20. }

See also 参考

Source 源码

CTriggerPrototype::get() in frontends/php/include/classes/api/services/CTriggerPrototype.php. CTriggerPrototype::get()方法可在frontends/php/include/classes/api/services/CTriggerPrototype.php中参考。