获取event
Payload:
{
"jsonrpc": "2.0",
"method": "event.get",
"params": {
"output": "extend",
"select_acknowledges": "extend",
"selectTags": "extend",
"sortfield": ["clock", "eventid"],
"sortorder": "DESC",
"limit": "5"
},
"auth": "54ec7f0d103f635ada0a76147d8a93a5",
"id": 1
}
Response:
{
"jsonrpc": "2.0",
"result": [
{
"eventid": "100",
"source": "0",
"object": "0",
"objectid": "13502",
"clock": "1523846313",
"value": "0",
"acknowledged": "0",
"ns": "874521724",
"r_eventid": "0",
"c_eventid": "0",
"correlationid": "0",
"userid": "0",
"acknowledges": [],
"tags": []
},
{
"eventid": "99",
"source": "0",
"object": "0",
"objectid": "13502",
"clock": "1523845713",
"value": "1",
"acknowledged": "0",
"ns": "594840544",
"r_eventid": "100",
"c_eventid": "0",
"correlationid": "0",
"userid": "0",
"acknowledges": [],
"tags": []
},
{
"eventid": "94",
"source": "0",
"object": "0",
"objectid": "13491",
"clock": "1523845395",
"value": "0",
"acknowledged": "0",
"ns": "857948163",
"r_eventid": "0",
"c_eventid": "0",
"correlationid": "0",
"userid": "0",
"acknowledges": [],
"tags": []
},
{
"eventid": "86",
"source": "0",
"object": "0",
"objectid": "13491",
"clock": "1523843220",
"value": "1",
"acknowledged": "0",
"ns": "136163804",
"r_eventid": "94",
"c_eventid": "0",
"correlationid": "0",
"userid": "0",
"acknowledges": [],
"tags": []
},
{
"eventid": "84",
"source": "0",
"object": "0",
"objectid": "15405",
"clock": "1523268042",
"value": "1",
"acknowledged": "0",
"ns": "971929873",
"r_eventid": "0",
"c_eventid": "0",
"correlationid": "0",
"userid": "0",
"acknowledges": [],
"tags": []
}
],
"id": 1
}
acknowledged: 0 为未处理 1为已处理
记录下这里的objectid
做为triggerid 查询规则
Request:
{
"jsonrpc": "2.0",
"method": "trigger.get",
"params": {
"triggerids": "15405",
"output": "extend",
"selectFunctions": "extend",
"selectItems": "extend"
},
"auth": "54ec7f0d103f635ada0a76147d8a93a5",
"id": 1
}
Response:
{
"jsonrpc": "2.0",
"result": [
{
"triggerid": "15405",
"expression": "{16942}<4G",
"description": "Total memory is lower than 4G at host: jfgitlab (中文测试)",
"url": "",
"status": "1",
"value": "1",
"priority": "1",
"lastchange": "1523268042",
"comments": "",
"error": "",
"templateid": "0",
"type": "0",
"state": "0",
"flags": "0",
"recovery_mode": "0",
"recovery_expression": "",
"correlation_mode": "0",
"correlation_tag": "",
"manual_close": "0",
"functions": [
{
"functionid": "16942",
"itemid": "28272",
"triggerid": "15405",
"function": "avg",
"parameter": "1m"
}
],
"items": [
{
"itemid": "28272",
"type": "0",
"snmp_community": "",
"snmp_oid": "",
"hostid": "10254",
"name": "Total memory",
"key_": "vm.memory.size[total]",
"delay": "1h",
"history": "1w",
"trends": "365d",
"status": "0",
"value_type": "3",
"trapper_hosts": "",
"units": "B",
"snmpv3_securityname": "",
"snmpv3_securitylevel": "0",
"snmpv3_authpassphrase": "",
"snmpv3_privpassphrase": "",
"formula": "",
"error": "",
"lastlogsize": "0",
"logtimefmt": "",
"templateid": "28315",
"valuemapid": "0",
"params": "",
"ipmi_sensor": "",
"authtype": "0",
"username": "",
"password": "",
"publickey": "",
"privatekey": "",
"mtime": "0",
"flags": "0",
"interfaceid": "2",
"port": "",
"description": "",
"inventory_link": "0",
"lifetime": "30d",
"snmpv3_authprotocol": "0",
"snmpv3_privprotocol": "0",
"state": "0",
"snmpv3_contextname": "",
"evaltype": "0",
"jmx_endpoint": "",
"master_itemid": "0",
"lastclock": "1523857872",
"lastns": "57420995",
"lastvalue": "3958050816",
"prevvalue": "3958050816"
}
]
}
],
"id": 1
}
主机名: hostid
故障类型: name
发生时间: lastchange
规则名称: expression
状态: status 0 enabled, 1 disabled