triggerprototype.get

说明

integer/array triggerprototype.get(object parameters)

该方法用于根据规定的参数获取触发器原型。

参数

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

该方法提供以下参数。

参数 类型 说明
active flag Return only enabled trigger prototypes that belong to monitored hosts.只返回所属被监控主机的已启用触发器原型。
applicationids string/array Return only trigger prototypes that contain items from the given applications.只返回指定应用集包含监控项所属的触发器原型。
discoveryids string/array Return only trigger prototypes that belong to the given LLD rules.只返回所属被给定 LLD 规则的触发器原型。
functions string/array Return only triggers that use the given functions.只返回指定函数所属的触发器。 Refer to the supported trigger functions page for a list of supported functions.有关支持的功能列表,请参阅supported trigger functions 页面。
group string Return only trigger prototypes that belong to hosts from the host groups with the given name. 只返回指定名称的主机组中属于主机的触发器原型。
groupids string/array Return only trigger prototypes that belong to hosts from the given host groups.只返回指定主机组所属主机的触发器原型。
host string Return only trigger prototypes that belong to hosts with the given name.只返回指定名称的主机的触发器原型。
hostids string/array Return only trigger prototypes that belong to the given hosts.只返回指定主机所属的触发器原型。
inherited boolean If set to true return only trigger prototypes inherited from a template.如果设置为 true ,则只返回从模板继承的触发器原型。
maintenance boolean If set to true return only enabled trigger prototypes that belong to hosts in maintenance.如果设置为 true ,则则只返回所属维护中主机的已启用触发器原型。
minseverity integer Return only trigger prototypes with severity greater or equal than the given severity.只返回严重级别大于或等于给定严重性的触发器原型。
monitored flag Return only enabled trigger prototypes that belong to monitored hosts and contain only enabled items.只返回所属被监控主机启用触发器原型,且包含已启用的监控项。
templated boolean If set to true return only trigger prototypes that belong to templates.如果设置为 true ,则只返回所属模板的触发器原型。
templateids string/array Return only trigger prototypes that belong to the given templates.只返回指定模板的触发器原型。
triggerids string/array Return only trigger prototypes with the given IDs.只返回指定 ID 的触发器原型。
expandExpression flag Expand functions and macros in the trigger expression.扩展触发器表达式中的函数和宏。
selectDiscoveryRule query Return the LLD rule that the trigger prototype belongs to.返回所属触发器原型的 LLD 规格。
selectFunctions query Return 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.参数传递给函数。
selectGroups query Return the host groups that the trigger prototype belongs to in the groups property.在 groups 属性中返回触发器原型所属的主机组。
selectHosts query Return the hosts that the trigger prototype belongs to in the hosts property.在 hosts 属性中返回触发器原型所属的主机。
selectItems query Return items and item prototypes used the trigger prototype in the items property.在 items 属性中返回触发器原型所包含的监控项和项目原型。
selectDependencies query Return trigger prototypes and triggers that the trigger prototype depends on in the dependencies property.返回触发器原型依赖于 dependencies 属性的触发器和触发器原型。
selectTags query Return the trigger prototype tags in tags property.在 tags 属性中返回触发器原型标签。
filter object Return 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.接受一个数组,其中keys是属性名称,并且值是单个值或要匹配值的数组。 Supports additional filters:支持新增的过滤器: host - technical name of the host that the trigger prototype belongs to; host - 触发器原型所属主机的技术性名称; hostid - ID of the host that the trigger prototype belongs to. hostid - 触发器原型所属主机的 ID。
limitSelects integer Limits the number of records returned by subselects.限制子选择返回的记录数。 Applies to the following subselects:适用于以下子选择: selectHosts - results will be sorted by host. selectHosts - 结果将按 host分类。
sortfield string/array 使用规定的属性将结果分类。 可能的值: triggerid, description, statuspriority
countOutput flagreference commentary 中详细描述了所有 get 方法的相关参数。
editable boolean
excludeSearch flag
limit integer
output query
preservekeys flag
search object
searchByAny boolean
searchWildcardsEnabled boolean
sortorder string/array
startSearch flag

Return values

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

  • an array of objects;一组对象

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

例如

从一条 LLD 规则检索触发器原型

从一条 LLD 规则检索所有的触发器原型和函数。

请求:

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

响应:

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

根据标签检索一个特定的触发器原型

请求:

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

响应:

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

参见

来源

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