From 13b0a2db787d763c53ace8876d7aca7ee9bae5bc Mon Sep 17 00:00:00 2001 From: Alexander Zobnin Date: Fri, 22 May 2020 12:51:39 +0300 Subject: [PATCH] Problems: push only existing triggers to the problems list, #954 --- src/datasource-zabbix/problemsHandler.ts | 58 +++++++++++++----------- 1 file changed, 31 insertions(+), 27 deletions(-) diff --git a/src/datasource-zabbix/problemsHandler.ts b/src/datasource-zabbix/problemsHandler.ts index 7123d26..c6c1c24 100644 --- a/src/datasource-zabbix/problemsHandler.ts +++ b/src/datasource-zabbix/problemsHandler.ts @@ -9,34 +9,38 @@ export function joinTriggersWithProblems(problems: ZBXProblem[], triggers: ZBXTr const p = problems[i]; const triggerId = Number(p.objectid); const t = triggers[triggerId]; - const problemDTO: ProblemDTO = { - timestamp: Number(p.clock), - triggerid: p.objectid, - eventid: p.eventid, - name: p.name, - severity: p.severity, - acknowledged: p.acknowledged, - acknowledges: p.acknowledges, - tags: p.tags, - suppressed: p.suppressed, - suppression_data: p.suppression_data, - description: t.description, - comments: t.comments, - value: t.value, - groups: t.groups, - hosts: t.hosts, - items: t.items, - alerts: t.alerts, - url: t.url, - expression: t.expression, - correlation_mode: t.correlation_mode, - correlation_tag: t.correlation_tag, - manual_close: t.manual_close, - state: t.state, - error: t.error, - }; - problemDTOList.push(problemDTO); + if (t) { + const problemDTO: ProblemDTO = { + timestamp: Number(p.clock), + triggerid: p.objectid, + eventid: p.eventid, + name: p.name, + severity: p.severity, + acknowledged: p.acknowledged, + acknowledges: p.acknowledges, + tags: p.tags, + suppressed: p.suppressed, + suppression_data: p.suppression_data, + description: t.description, + comments: t.comments, + value: t.value, + groups: t.groups, + hosts: t.hosts, + items: t.items, + alerts: t.alerts, + url: t.url, + expression: t.expression, + correlation_mode: t.correlation_mode, + correlation_tag: t.correlation_tag, + manual_close: t.manual_close, + state: t.state, + error: t.error, + }; + + problemDTOList.push(problemDTO); + } + } return problemDTOList;