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 , status 和 priority 。 |
countOutput | flag | 在reference 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 规则检索所有的触发器原型和函数。
请求:
- {
- "jsonrpc": "2.0",
- "method": "triggerprototype.get",
- "params": {
- "output": "extend",
- "selectFunctions": "extend",
- "discoveryids": "22450"
- },
- "auth": "038e1d7b1735c6a5436ee9eae095879e",
- "id": 1
- }
响应:
- {
- "jsonrpc": "2.0",
- "result": [
- {
- "functions": [
- {
- "functionid": "12598",
- "itemid": "22454",
- "function": "last",
- "parameter": "0"
- }
- ],
- "triggerid": "13272",
- "expression": "{12598}<20",
- "description": "Free inodes is less than 20% on volume {#FSNAME}",
- "url": "",
- "status": "0",
- "priority": "2",
- "comments": "",
- "templateid": "0",
- "type": "0",
- "flags": "2",
- "recovery_mode": "0",
- "recovery_expression": "",
- "correlation_mode": "0",
- "correlation_tag": "",
- "manual_close": "0"
- },
- {
- "functions": [
- {
- "functionid": "13500",
- "itemid": "22686",
- "function": "last",
- "parameter": "0"
- }
- ],
- "triggerid": "13266",
- "expression": "{13500}<201",
- "description": "Free disk space is less than 20% on volume {#FSNAME}",
- "url": "",
- "status": "0",
- "priority": "2",
- "comments": "",
- "templateid": "0",
- "type": "0",
- "flags": "2",
- "recovery_mode": "0",
- "recovery_expression": "",
- "correlation_mode": "0",
- "correlation_tag": "",
- "manual_close": "0"
- }
- ],
- "id": 1
- }
根据标签检索一个特定的触发器原型
请求:
- {
- "jsonrpc": "2.0",
- "method": "triggerprototype.get",
- "params": {
- "output": [
- "triggerid",
- "description"
- ]
- "selectTags": "extend",
- "triggerids": [
- "17373"
- ]
- },
- "auth": "038e1d7b1735c6a5436ee9eae095879e",
- "id": 1
- }
响应:
- {
- "jsonrpc": "2.0",
- "result": [
- {
- "triggerid": "17373",
- "description": "Free disk space is less than 20% on volume {#FSNAME}",
- "tags": [
- {
- "tag": "volume",
- "value": "{#FSNAME}"
- },
- {
- "tag": "type",
- "value": "{#FSTYPE}"
- }
- ]
- }
- ],
- "id": 1
- }
参见
来源
CTriggerPrototype::get() in frontends/php/include/classes/api/services/CTriggerPrototype.php.