From 99b2e7111bce03844f6d1f189092c5220039a567 Mon Sep 17 00:00:00 2001 From: Sam H Date: Tue, 5 Jul 2022 22:07:22 -0400 Subject: [PATCH 1/7] Update zabbixAPIConnector.ts --- .../connectors/zabbix_api/zabbixAPIConnector.ts | 12 ++++++++++++ 1 file changed, 12 insertions(+) diff --git a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts index ebb894d43..4f83e0af1 100644 --- a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts +++ b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts @@ -133,6 +133,9 @@ export class ZabbixAPIConnector { } getGroups() { + if (!this.version) { + this.initVersion(); + } if (semver.gte(this.version, '6.2.0')) { const params = { @@ -501,6 +504,9 @@ export class ZabbixAPIConnector { } getTriggersByIds(triggerids: string[]) { + if (!this.version) { + this.initVersion(); + } if (semver.gte(this.version, '6.2.0')) { const params: any = { @@ -544,6 +550,9 @@ export class ZabbixAPIConnector { getTriggers(groupids, hostids, applicationids, options) { const { showTriggers, maintenance, timeFrom, timeTo } = options; + if (!this.version) { + this.initVersion(); + } if (semver.gte(this.version, '6.2.0')) { const params: any = { @@ -735,6 +744,9 @@ export class ZabbixAPIConnector { getHostAlerts(hostids, applicationids, options) { const { minSeverity, acknowledged, count, timeFrom, timeTo } = options; + if (!this.version) { + this.initVersion(); + } if (semver.gte(this.version, '6.2.0')) { const params: any = { From 1fcec6f3e707795a75b9a3dc2302a0c70b8cfc66 Mon Sep 17 00:00:00 2001 From: Sam H Date: Tue, 5 Jul 2022 22:58:53 -0400 Subject: [PATCH 2/7] Update zabbixAPIConnector.ts --- .../zabbix/connectors/zabbix_api/zabbixAPIConnector.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts index 4f83e0af1..9e4183a4f 100644 --- a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts +++ b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts @@ -134,7 +134,7 @@ export class ZabbixAPIConnector { getGroups() { if (!this.version) { - this.initVersion(); + this.initVersion().done((result) => {}); } if (semver.gte(this.version, '6.2.0')) { @@ -505,7 +505,7 @@ export class ZabbixAPIConnector { getTriggersByIds(triggerids: string[]) { if (!this.version) { - this.initVersion(); + this.initVersion().done((result) => {}); } if (semver.gte(this.version, '6.2.0')) { @@ -551,7 +551,7 @@ export class ZabbixAPIConnector { getTriggers(groupids, hostids, applicationids, options) { const { showTriggers, maintenance, timeFrom, timeTo } = options; if (!this.version) { - this.initVersion(); + this.initVersion().done((result) => {}); } if (semver.gte(this.version, '6.2.0')) { @@ -745,7 +745,7 @@ export class ZabbixAPIConnector { getHostAlerts(hostids, applicationids, options) { const { minSeverity, acknowledged, count, timeFrom, timeTo } = options; if (!this.version) { - this.initVersion(); + this.initVersion().done((result) => {}); } if (semver.gte(this.version, '6.2.0')) { From d5bd585c851bddc7befd1de6ff3f887f6a256fd8 Mon Sep 17 00:00:00 2001 From: Sam H Date: Tue, 5 Jul 2022 23:08:09 -0400 Subject: [PATCH 3/7] Update zabbixAPIConnector.ts --- .../zabbix/connectors/zabbix_api/zabbixAPIConnector.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts index 9e4183a4f..854399366 100644 --- a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts +++ b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts @@ -134,7 +134,7 @@ export class ZabbixAPIConnector { getGroups() { if (!this.version) { - this.initVersion().done((result) => {}); + await this.getVersionPromise; } if (semver.gte(this.version, '6.2.0')) { @@ -505,7 +505,7 @@ export class ZabbixAPIConnector { getTriggersByIds(triggerids: string[]) { if (!this.version) { - this.initVersion().done((result) => {}); + await this.getVersionPromise; } if (semver.gte(this.version, '6.2.0')) { @@ -551,7 +551,7 @@ export class ZabbixAPIConnector { getTriggers(groupids, hostids, applicationids, options) { const { showTriggers, maintenance, timeFrom, timeTo } = options; if (!this.version) { - this.initVersion().done((result) => {}); + await this.getVersionPromise; } if (semver.gte(this.version, '6.2.0')) { @@ -745,7 +745,7 @@ export class ZabbixAPIConnector { getHostAlerts(hostids, applicationids, options) { const { minSeverity, acknowledged, count, timeFrom, timeTo } = options; if (!this.version) { - this.initVersion().done((result) => {}); + await this.getVersionPromise; } if (semver.gte(this.version, '6.2.0')) { From fcc4a9a060f57810950c99d83f3edaf703c93f4a Mon Sep 17 00:00:00 2001 From: Sam H Date: Tue, 5 Jul 2022 23:13:32 -0400 Subject: [PATCH 4/7] Update zabbixAPIConnector.ts --- .../zabbix/connectors/zabbix_api/zabbixAPIConnector.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts index 854399366..020c7c33a 100644 --- a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts +++ b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts @@ -134,7 +134,7 @@ export class ZabbixAPIConnector { getGroups() { if (!this.version) { - await this.getVersionPromise; + await this.initVersion(); } if (semver.gte(this.version, '6.2.0')) { @@ -505,7 +505,7 @@ export class ZabbixAPIConnector { getTriggersByIds(triggerids: string[]) { if (!this.version) { - await this.getVersionPromise; + await this.initVersion(); } if (semver.gte(this.version, '6.2.0')) { @@ -551,7 +551,7 @@ export class ZabbixAPIConnector { getTriggers(groupids, hostids, applicationids, options) { const { showTriggers, maintenance, timeFrom, timeTo } = options; if (!this.version) { - await this.getVersionPromise; + await this.initVersion(); } if (semver.gte(this.version, '6.2.0')) { @@ -745,7 +745,7 @@ export class ZabbixAPIConnector { getHostAlerts(hostids, applicationids, options) { const { minSeverity, acknowledged, count, timeFrom, timeTo } = options; if (!this.version) { - await this.getVersionPromise; + await this.initVersion(); } if (semver.gte(this.version, '6.2.0')) { From 6fe5d3071d8b13fbf84fd9785d2cd7112357047e Mon Sep 17 00:00:00 2001 From: Sam H Date: Tue, 5 Jul 2022 23:27:41 -0400 Subject: [PATCH 5/7] Update zabbixAPIConnector.ts --- .../zabbix/connectors/zabbix_api/zabbixAPIConnector.ts | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts index 020c7c33a..c53d0457d 100644 --- a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts +++ b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts @@ -134,7 +134,7 @@ export class ZabbixAPIConnector { getGroups() { if (!this.version) { - await this.initVersion(); + this.initVersion().then((result) => { console.log(`Zabbix init version detected: ${result}`);}); } if (semver.gte(this.version, '6.2.0')) { @@ -505,7 +505,7 @@ export class ZabbixAPIConnector { getTriggersByIds(triggerids: string[]) { if (!this.version) { - await this.initVersion(); + this.initVersion().then((result) => { console.log(`Zabbix init version detected: ${result}`);}); } if (semver.gte(this.version, '6.2.0')) { @@ -551,7 +551,7 @@ export class ZabbixAPIConnector { getTriggers(groupids, hostids, applicationids, options) { const { showTriggers, maintenance, timeFrom, timeTo } = options; if (!this.version) { - await this.initVersion(); + this.initVersion().then((result) => { console.log(`Zabbix init version detected: ${result}`);}); } if (semver.gte(this.version, '6.2.0')) { @@ -745,7 +745,7 @@ export class ZabbixAPIConnector { getHostAlerts(hostids, applicationids, options) { const { minSeverity, acknowledged, count, timeFrom, timeTo } = options; if (!this.version) { - await this.initVersion(); + this.initVersion().then((result) => { console.log(`Zabbix init version detected: ${result}`);}); } if (semver.gte(this.version, '6.2.0')) { From e36c0f50dc2c13c117ae646476a494887a50fbcc Mon Sep 17 00:00:00 2001 From: Sam H Date: Tue, 5 Jul 2022 23:47:41 -0400 Subject: [PATCH 6/7] Update zabbixAPIConnector.ts --- .../zabbix_api/zabbixAPIConnector.ts | 32 +++++++++---------- 1 file changed, 15 insertions(+), 17 deletions(-) diff --git a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts index c53d0457d..dad350dee 100644 --- a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts +++ b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts @@ -133,10 +133,9 @@ export class ZabbixAPIConnector { } getGroups() { - if (!this.version) { - this.initVersion().then((result) => { console.log(`Zabbix init version detected: ${result}`);}); - } - if (semver.gte(this.version, '6.2.0')) + this.initVersion().then((result) => { + + if (semver.gte(result, '6.2.0')) { const params = { output: ['name'], @@ -156,7 +155,7 @@ export class ZabbixAPIConnector { return this.request('hostgroup.get', params); } - +}); getHosts(groupids) { const params: any = { output: ['name', 'host'], @@ -504,9 +503,8 @@ export class ZabbixAPIConnector { } getTriggersByIds(triggerids: string[]) { - if (!this.version) { - this.initVersion().then((result) => { console.log(`Zabbix init version detected: ${result}`);}); - } + this.initVersion().then((result) => { + if (semver.gte(this.version, '6.2.0')) { const params: any = { @@ -547,12 +545,12 @@ export class ZabbixAPIConnector { return this.request('trigger.get', params).then(utils.mustArray); } - +}); getTriggers(groupids, hostids, applicationids, options) { const { showTriggers, maintenance, timeFrom, timeTo } = options; - if (!this.version) { - this.initVersion().then((result) => { console.log(`Zabbix init version detected: ${result}`);}); - } + + this.initVersion().then((result) => { + if (semver.gte(this.version, '6.2.0')) { const params: any = { @@ -616,7 +614,7 @@ export class ZabbixAPIConnector { return this.request('trigger.get', params); } - +}); getEvents(objectids, timeFrom, timeTo, showEvents, limit) { const params: any = { output: 'extend', @@ -744,9 +742,9 @@ export class ZabbixAPIConnector { getHostAlerts(hostids, applicationids, options) { const { minSeverity, acknowledged, count, timeFrom, timeTo } = options; - if (!this.version) { - this.initVersion().then((result) => { console.log(`Zabbix init version detected: ${result}`);}); - } + + this.initVersion().then((result) => { + if (semver.gte(this.version, '6.2.0')) { const params: any = { @@ -805,7 +803,7 @@ export class ZabbixAPIConnector { return triggers; }); } - +}); getProxies() { const params = { output: ['proxyid', 'host'], From 62661376455a75024f8c1d05a6ba33b202c94ec2 Mon Sep 17 00:00:00 2001 From: Sam H Date: Tue, 5 Jul 2022 23:57:39 -0400 Subject: [PATCH 7/7] Update zabbixAPIConnector.ts --- .../zabbix_api/zabbixAPIConnector.ts | 40 ++++++++++--------- 1 file changed, 21 insertions(+), 19 deletions(-) diff --git a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts index dad350dee..86600c0c9 100644 --- a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts +++ b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts @@ -132,10 +132,11 @@ export class ZabbixAPIConnector { return this.request('event.acknowledge', params); } - getGroups() { - this.initVersion().then((result) => { - - if (semver.gte(result, '6.2.0')) + async getGroups() { + if (!this.version) { + await this.initVersion(); + } + if (semver.gte(this.version, '6.2.0')) { const params = { output: ['name'], @@ -155,7 +156,7 @@ export class ZabbixAPIConnector { return this.request('hostgroup.get', params); } -}); + getHosts(groupids) { const params: any = { output: ['name', 'host'], @@ -502,9 +503,10 @@ export class ZabbixAPIConnector { return this.request('problem.get', params).then(utils.mustArray); } - getTriggersByIds(triggerids: string[]) { - this.initVersion().then((result) => { - + async getTriggersByIds(triggerids: string[]) { + if (!this.version) { + await this.initVersion(); + } if (semver.gte(this.version, '6.2.0')) { const params: any = { @@ -545,12 +547,12 @@ export class ZabbixAPIConnector { return this.request('trigger.get', params).then(utils.mustArray); } -}); - getTriggers(groupids, hostids, applicationids, options) { + + async getTriggers(groupids, hostids, applicationids, options) { const { showTriggers, maintenance, timeFrom, timeTo } = options; - - this.initVersion().then((result) => { - + if (!this.version) { + await this.initVersion(); + } if (semver.gte(this.version, '6.2.0')) { const params: any = { @@ -614,7 +616,7 @@ export class ZabbixAPIConnector { return this.request('trigger.get', params); } -}); + getEvents(objectids, timeFrom, timeTo, showEvents, limit) { const params: any = { output: 'extend', @@ -740,11 +742,11 @@ export class ZabbixAPIConnector { return this.request('trigger.get', params); } - getHostAlerts(hostids, applicationids, options) { + async getHostAlerts(hostids, applicationids, options) { const { minSeverity, acknowledged, count, timeFrom, timeTo } = options; - - this.initVersion().then((result) => { - + if (!this.version) { + await this.initVersion(); + } if (semver.gte(this.version, '6.2.0')) { const params: any = { @@ -803,7 +805,7 @@ export class ZabbixAPIConnector { return triggers; }); } -}); + getProxies() { const params = { output: ['proxyid', 'host'],