From 65a110da9529e9404ea2d6b195a7969c56fc5be7 Mon Sep 17 00:00:00 2001 From: Leonardo Amaral Date: Tue, 5 Jul 2022 22:21:10 -0300 Subject: [PATCH 01/15] Allow Build of zabbix-6.2 --- .github/workflows/node.js.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 0c31a5750..6e4a6f051 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -5,9 +5,9 @@ name: Node.js CI on: push: - branches: [ master ] + branches: [ zabbix-6.2 ] pull_request: - branches: [ master ] + branches: [ zabbix-6.2 ] jobs: build: From f1185ed159768968caabd2375b35927e0c0d48c7 Mon Sep 17 00:00:00 2001 From: Leonardo Amaral Date: Tue, 5 Jul 2022 22:50:40 -0300 Subject: [PATCH 02/15] * Sign --- .github/workflows/node.js.yml | 3 +++ go.mod | 2 +- 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 6e4a6f051..59df087ed 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -33,6 +33,9 @@ jobs: with: node-version: ${{ matrix.node-version }} #cache: 'npm' + - run: make + - run: export GRAFANA_API_KEY=${{ secrets.GRAFANA_API_KEY }} + - run: npx @grafana/toolkit plugin:sign --rootUrls https://sage-antiddos-mon.sagenetworks.com.br/ - run: make install - run: make dist - name: Upload a Build Artifact diff --git a/go.mod b/go.mod index e50ee7235..11547b77e 100644 --- a/go.mod +++ b/go.mod @@ -1,4 +1,4 @@ -module github.com/alexanderzobnin/grafana-zabbix +module github.com/leleobhz/grafana-zabbix go 1.15 From ce7c459ad9e05e98cbc5cef63516cc94b2ad6b11 Mon Sep 17 00:00:00 2001 From: Leonardo Amaral Date: Tue, 5 Jul 2022 23:23:42 -0300 Subject: [PATCH 03/15] * Attempt of repo change #1 --- package.json | 4 ++-- pkg/datasource/datasource.go | 10 +++++----- pkg/datasource/functions.go | 6 +++--- pkg/datasource/models.go | 2 +- pkg/datasource/resource_handler.go | 2 +- pkg/datasource/response_handler.go | 6 +++--- pkg/datasource/zabbix.go | 4 ++-- pkg/datasource/zabbix_test.go | 4 ++-- pkg/plugin.go | 2 +- pkg/settings/settings.go | 2 +- pkg/timeseries/models.go | 2 +- pkg/zabbix/cache.go | 2 +- pkg/zabbix/testing.go | 4 ++-- pkg/zabbix/zabbix.go | 6 +++--- pkg/zabbixapi/zabbix_api.go | 2 +- src/datasource-zabbix/plugin.json | 2 +- src/panel-triggers/module.js | 2 +- src/panel-triggers/options_tab.js | 2 +- src/panel-triggers/plugin.json | 2 +- src/plugin.json | 6 +++--- 20 files changed, 36 insertions(+), 36 deletions(-) diff --git a/package.json b/package.json index 22b7c6278..c1920790b 100644 --- a/package.json +++ b/package.json @@ -17,12 +17,12 @@ }, "repository": { "type": "git", - "url": "git+https://github.com/alexanderzobnin/grafana-zabbix.git" + "url": "git+https://github.com/leleobhz/grafana-zabbix.git" }, "author": "Alexander Zobnin", "license": "Apache-2.0", "bugs": { - "url": "https://github.com/alexanderzobnin/grafana-zabbix/issues" + "url": "https://github.com/leleobhz/grafana-zabbix/issues" }, "devDependencies": { "@babel/core": "7.7.7", diff --git a/pkg/datasource/datasource.go b/pkg/datasource/datasource.go index 92cd30823..3481fccea 100644 --- a/pkg/datasource/datasource.go +++ b/pkg/datasource/datasource.go @@ -4,11 +4,11 @@ import ( "context" "errors" - "github.com/alexanderzobnin/grafana-zabbix/pkg/httpclient" - "github.com/alexanderzobnin/grafana-zabbix/pkg/metrics" - "github.com/alexanderzobnin/grafana-zabbix/pkg/settings" - "github.com/alexanderzobnin/grafana-zabbix/pkg/zabbix" - "github.com/alexanderzobnin/grafana-zabbix/pkg/zabbixapi" + "github.com/leleobhz/grafana-zabbix/pkg/httpclient" + "github.com/leleobhz/grafana-zabbix/pkg/metrics" + "github.com/leleobhz/grafana-zabbix/pkg/settings" + "github.com/leleobhz/grafana-zabbix/pkg/zabbix" + "github.com/leleobhz/grafana-zabbix/pkg/zabbixapi" "github.com/grafana/grafana-plugin-sdk-go/backend" "github.com/grafana/grafana-plugin-sdk-go/backend/datasource" "github.com/grafana/grafana-plugin-sdk-go/backend/instancemgmt" diff --git a/pkg/datasource/functions.go b/pkg/datasource/functions.go index 17012af8f..24fe136e0 100644 --- a/pkg/datasource/functions.go +++ b/pkg/datasource/functions.go @@ -5,9 +5,9 @@ import ( "strconv" "strings" - "github.com/alexanderzobnin/grafana-zabbix/pkg/gtime" - "github.com/alexanderzobnin/grafana-zabbix/pkg/timeseries" - "github.com/alexanderzobnin/grafana-zabbix/pkg/zabbix" + "github.com/leleobhz/grafana-zabbix/pkg/gtime" + "github.com/leleobhz/grafana-zabbix/pkg/timeseries" + "github.com/leleobhz/grafana-zabbix/pkg/zabbix" ) const RANGE_VARIABLE_VALUE = "range_series" diff --git a/pkg/datasource/models.go b/pkg/datasource/models.go index 493dce64e..fd3500912 100644 --- a/pkg/datasource/models.go +++ b/pkg/datasource/models.go @@ -6,7 +6,7 @@ import ( "strconv" "time" - "github.com/alexanderzobnin/grafana-zabbix/pkg/timeseries" + "github.com/leleobhz/grafana-zabbix/pkg/timeseries" "github.com/bitly/go-simplejson" "github.com/grafana/grafana-plugin-sdk-go/backend" diff --git a/pkg/datasource/resource_handler.go b/pkg/datasource/resource_handler.go index acad9767e..22b49a207 100644 --- a/pkg/datasource/resource_handler.go +++ b/pkg/datasource/resource_handler.go @@ -6,7 +6,7 @@ import ( "net/http" "time" - "github.com/alexanderzobnin/grafana-zabbix/pkg/zabbix" + "github.com/leleobhz/grafana-zabbix/pkg/zabbix" "github.com/grafana/grafana-plugin-sdk-go/backend/resource/httpadapter" ) diff --git a/pkg/datasource/response_handler.go b/pkg/datasource/response_handler.go index c1cdc8e25..225dd313b 100644 --- a/pkg/datasource/response_handler.go +++ b/pkg/datasource/response_handler.go @@ -6,9 +6,9 @@ import ( "strconv" "time" - "github.com/alexanderzobnin/grafana-zabbix/pkg/gtime" - "github.com/alexanderzobnin/grafana-zabbix/pkg/timeseries" - "github.com/alexanderzobnin/grafana-zabbix/pkg/zabbix" + "github.com/leleobhz/grafana-zabbix/pkg/gtime" + "github.com/leleobhz/grafana-zabbix/pkg/timeseries" + "github.com/leleobhz/grafana-zabbix/pkg/zabbix" "github.com/grafana/grafana-plugin-sdk-go/data" ) diff --git a/pkg/datasource/zabbix.go b/pkg/datasource/zabbix.go index 7afb908c2..7f13c622f 100644 --- a/pkg/datasource/zabbix.go +++ b/pkg/datasource/zabbix.go @@ -4,9 +4,9 @@ import ( "strings" "time" - "github.com/alexanderzobnin/grafana-zabbix/pkg/timeseries" + "github.com/leleobhz/grafana-zabbix/pkg/timeseries" - "github.com/alexanderzobnin/grafana-zabbix/pkg/zabbix" + "github.com/leleobhz/grafana-zabbix/pkg/zabbix" "github.com/grafana/grafana-plugin-sdk-go/backend" "github.com/grafana/grafana-plugin-sdk-go/data" "golang.org/x/net/context" diff --git a/pkg/datasource/zabbix_test.go b/pkg/datasource/zabbix_test.go index bffa375dd..3b155e57a 100644 --- a/pkg/datasource/zabbix_test.go +++ b/pkg/datasource/zabbix_test.go @@ -1,8 +1,8 @@ package datasource import ( - "github.com/alexanderzobnin/grafana-zabbix/pkg/settings" - "github.com/alexanderzobnin/grafana-zabbix/pkg/zabbix" + "github.com/leleobhz/grafana-zabbix/pkg/settings" + "github.com/leleobhz/grafana-zabbix/pkg/zabbix" "github.com/grafana/grafana-plugin-sdk-go/backend" "github.com/grafana/grafana-plugin-sdk-go/backend/log" ) diff --git a/pkg/plugin.go b/pkg/plugin.go index 89b278c11..35ca48ae8 100644 --- a/pkg/plugin.go +++ b/pkg/plugin.go @@ -4,7 +4,7 @@ import ( "net/http" "os" - "github.com/alexanderzobnin/grafana-zabbix/pkg/datasource" + "github.com/leleobhz/grafana-zabbix/pkg/datasource" "github.com/grafana/grafana-plugin-sdk-go/backend" "github.com/grafana/grafana-plugin-sdk-go/backend/log" "github.com/grafana/grafana-plugin-sdk-go/backend/resource/httpadapter" diff --git a/pkg/settings/settings.go b/pkg/settings/settings.go index 5d18efabe..14658813f 100644 --- a/pkg/settings/settings.go +++ b/pkg/settings/settings.go @@ -3,7 +3,7 @@ package settings import ( "encoding/json" "errors" - "github.com/alexanderzobnin/grafana-zabbix/pkg/gtime" + "github.com/leleobhz/grafana-zabbix/pkg/gtime" "github.com/grafana/grafana-plugin-sdk-go/backend" "strconv" "time" diff --git a/pkg/timeseries/models.go b/pkg/timeseries/models.go index 0b84dd7c6..966c8e73d 100644 --- a/pkg/timeseries/models.go +++ b/pkg/timeseries/models.go @@ -4,7 +4,7 @@ import ( "encoding/json" "time" - "github.com/alexanderzobnin/grafana-zabbix/pkg/zabbix" + "github.com/leleobhz/grafana-zabbix/pkg/zabbix" ) type TimePoint struct { diff --git a/pkg/zabbix/cache.go b/pkg/zabbix/cache.go index 13f0e8c1a..653df7286 100644 --- a/pkg/zabbix/cache.go +++ b/pkg/zabbix/cache.go @@ -5,7 +5,7 @@ import ( "encoding/hex" "time" - "github.com/alexanderzobnin/grafana-zabbix/pkg/cache" + "github.com/leleobhz/grafana-zabbix/pkg/cache" ) var cachedMethods = map[string]bool{ diff --git a/pkg/zabbix/testing.go b/pkg/zabbix/testing.go index f5e0d83cb..95509fabf 100644 --- a/pkg/zabbix/testing.go +++ b/pkg/zabbix/testing.go @@ -1,8 +1,8 @@ package zabbix import ( - "github.com/alexanderzobnin/grafana-zabbix/pkg/settings" - "github.com/alexanderzobnin/grafana-zabbix/pkg/zabbixapi" + "github.com/leleobhz/grafana-zabbix/pkg/settings" + "github.com/leleobhz/grafana-zabbix/pkg/zabbixapi" "github.com/grafana/grafana-plugin-sdk-go/backend" "time" ) diff --git a/pkg/zabbix/zabbix.go b/pkg/zabbix/zabbix.go index 01632f41b..37c873b42 100644 --- a/pkg/zabbix/zabbix.go +++ b/pkg/zabbix/zabbix.go @@ -5,9 +5,9 @@ import ( "strings" "time" - "github.com/alexanderzobnin/grafana-zabbix/pkg/metrics" - "github.com/alexanderzobnin/grafana-zabbix/pkg/settings" - "github.com/alexanderzobnin/grafana-zabbix/pkg/zabbixapi" + "github.com/leleobhz/grafana-zabbix/pkg/metrics" + "github.com/leleobhz/grafana-zabbix/pkg/settings" + "github.com/leleobhz/grafana-zabbix/pkg/zabbixapi" "github.com/bitly/go-simplejson" "github.com/grafana/grafana-plugin-sdk-go/backend" "github.com/grafana/grafana-plugin-sdk-go/backend/log" diff --git a/pkg/zabbixapi/zabbix_api.go b/pkg/zabbixapi/zabbix_api.go index e2a813292..70ed07435 100644 --- a/pkg/zabbixapi/zabbix_api.go +++ b/pkg/zabbixapi/zabbix_api.go @@ -10,7 +10,7 @@ import ( "net/http" "net/url" - "github.com/alexanderzobnin/grafana-zabbix/pkg/metrics" + "github.com/leleobhz/grafana-zabbix/pkg/metrics" "github.com/bitly/go-simplejson" "github.com/grafana/grafana-plugin-sdk-go/backend/log" "golang.org/x/net/context/ctxhttp" diff --git a/src/datasource-zabbix/plugin.json b/src/datasource-zabbix/plugin.json index ffce17394..24552d320 100644 --- a/src/datasource-zabbix/plugin.json +++ b/src/datasource-zabbix/plugin.json @@ -35,7 +35,7 @@ "info": { "author": { "name": "Alexander Zobnin", - "url": "https://github.com/alexanderzobnin/grafana-zabbix" + "url": "https://github.com/leleobhz/grafana-zabbix" }, "logos": { "small": "img/icn-zabbix-datasource.svg", diff --git a/src/panel-triggers/module.js b/src/panel-triggers/module.js index a6f7f15ae..af8a29bc5 100644 --- a/src/panel-triggers/module.js +++ b/src/panel-triggers/module.js @@ -1,7 +1,7 @@ /** * Grafana-Zabbix * Zabbix plugin for Grafana. - * http://github.com/alexanderzobnin/grafana-zabbix + * http://github.com/leleobhz/grafana-zabbix * * Trigger panel. * This feature sponsored by CORE IT diff --git a/src/panel-triggers/options_tab.js b/src/panel-triggers/options_tab.js index c67521fbe..7d3c72c5d 100644 --- a/src/panel-triggers/options_tab.js +++ b/src/panel-triggers/options_tab.js @@ -1,7 +1,7 @@ /** * Grafana-Zabbix * Zabbix plugin for Grafana. - * http://github.com/alexanderzobnin/grafana-zabbix + * http://github.com/leleobhz/grafana-zabbix * * Trigger panel. * This feature sponsored by CORE IT diff --git a/src/panel-triggers/plugin.json b/src/panel-triggers/plugin.json index 68cc9a678..a407a20b9 100644 --- a/src/panel-triggers/plugin.json +++ b/src/panel-triggers/plugin.json @@ -6,7 +6,7 @@ "info": { "author": { "name": "Alexander Zobnin", - "url": "https://github.com/alexanderzobnin/grafana-zabbix" + "url": "https://github.com/leleobhz/grafana-zabbix" }, "logos": { "small": "img/icn-zabbix-problems-panel.svg", diff --git a/src/plugin.json b/src/plugin.json index 50478fcb6..602c935a1 100644 --- a/src/plugin.json +++ b/src/plugin.json @@ -6,7 +6,7 @@ "description": "Zabbix plugin for Grafana", "author": { "name": "Alexander Zobnin", - "url": "https://github.com/alexanderzobnin" + "url": "https://github.com/leleobhz" }, "keywords": [ "zabbix" @@ -18,7 +18,7 @@ "links": [ { "name": "GitHub", - "url": "https://github.com/alexanderzobnin/grafana-zabbix" + "url": "https://github.com/leleobhz/grafana-zabbix" }, { "name": "Docs", @@ -26,7 +26,7 @@ }, { "name": "License", - "url": "https://github.com/alexanderzobnin/grafana-zabbix/blob/master/LICENSE" + "url": "https://github.com/leleobhz/grafana-zabbix/blob/master/LICENSE" } ], "screenshots": [ From fb5733a687e0eb4e86f51a5b0bbb8a28af508f4f Mon Sep 17 00:00:00 2001 From: Sam H Date: Tue, 5 Jul 2022 23:57:39 -0400 Subject: [PATCH 04/15] 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'], From 7610de8ee2a7bffce892e7f51341971eaa69ddc4 Mon Sep 17 00:00:00 2001 From: Leonardo Amaral Date: Wed, 6 Jul 2022 10:43:05 -0300 Subject: [PATCH 05/15] * Changes on CI/CD --- .github/workflows/node.js.yml | 14 +++++++++----- 1 file changed, 9 insertions(+), 5 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 59df087ed..65488561f 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -16,16 +16,16 @@ jobs: strategy: matrix: - node-version: [14.x] + node-version: [17.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: - uses: actions/checkout@v3 - name: Setup Go environment uses: actions/setup-go@v3.2.0 - with: +# with: # The Go version to download (if necessary) and use. Supports semver spec and ranges. - go-version: 1.17 # optional + # go-version: 1.17 # optional # Path to the go.mod file. - name: Use Node.js ${{ matrix.node-version }} @@ -34,10 +34,14 @@ jobs: node-version: ${{ matrix.node-version }} #cache: 'npm' - run: make - - run: export GRAFANA_API_KEY=${{ secrets.GRAFANA_API_KEY }} - - run: npx @grafana/toolkit plugin:sign --rootUrls https://sage-antiddos-mon.sagenetworks.com.br/ + env: + NODE_OPTIONS: --openssl-legacy-provider - run: make install + env: + NODE_OPTIONS: --openssl-legacy-provider - run: make dist + env: + NODE_OPTIONS: --openssl-legacy-provider - name: Upload a Build Artifact uses: actions/upload-artifact@v3.1.0 with: From bef2f7f63950b8b67c394e634c4c0ed28db34291 Mon Sep 17 00:00:00 2001 From: Leonardo Amaral Date: Wed, 6 Jul 2022 10:54:05 -0300 Subject: [PATCH 06/15] * Changes on CI/CD #2 --- .github/workflows/node.js.yml | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 65488561f..ea786d4b8 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: - node-version: [17.x] + node-version: [16.x] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: @@ -34,14 +34,8 @@ jobs: node-version: ${{ matrix.node-version }} #cache: 'npm' - run: make - env: - NODE_OPTIONS: --openssl-legacy-provider - run: make install - env: - NODE_OPTIONS: --openssl-legacy-provider - run: make dist - env: - NODE_OPTIONS: --openssl-legacy-provider - name: Upload a Build Artifact uses: actions/upload-artifact@v3.1.0 with: From df6423436c2bfd22845cef6055bc94dd2afc5b92 Mon Sep 17 00:00:00 2001 From: Leonardo Amaral Date: Wed, 6 Jul 2022 11:08:05 -0300 Subject: [PATCH 07/15] * Attempt to fix param constant scope --- .../zabbix/connectors/zabbix_api/zabbixAPIConnector.ts | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts index 86600c0c9..0d0ee4c78 100644 --- a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts +++ b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts @@ -136,9 +136,12 @@ export class ZabbixAPIConnector { if (!this.version) { await this.initVersion(); } + + let paramL: any; + if (semver.gte(this.version, '6.2.0')) { - const params = { + paramL = { output: ['name'], sortfield: 'name', with_monitored_hosts: true @@ -147,13 +150,15 @@ export class ZabbixAPIConnector { else { - const params = { + paramL = { output: ['name'], sortfield: 'name', real_hosts: true }; } + const params = paramL; + return this.request('hostgroup.get', params); } From a6c59eb47ba9b5ed04889c77ce9da68191c4fa73 Mon Sep 17 00:00:00 2001 From: Leonardo Amaral Date: Wed, 6 Jul 2022 11:27:04 -0300 Subject: [PATCH 08/15] * Attempt to fix param constant scope #2 --- .../zabbix_api/zabbixAPIConnector.ts | 28 +++++++++++++++---- 1 file changed, 22 insertions(+), 6 deletions(-) diff --git a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts index 0d0ee4c78..052c973e3 100644 --- a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts +++ b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts @@ -512,9 +512,12 @@ export class ZabbixAPIConnector { if (!this.version) { await this.initVersion(); } + + let paramL: any; + if (semver.gte(this.version, '6.2.0')) { - const params: any = { + paramL : any = { output: 'extend', triggerids: triggerids, expandDescription: true, @@ -532,7 +535,7 @@ export class ZabbixAPIConnector { } else { - const params: any = { + paramL: any = { output: 'extend', triggerids: triggerids, expandDescription: true, @@ -549,6 +552,7 @@ export class ZabbixAPIConnector { }; } + const params = paramL; return this.request('trigger.get', params).then(utils.mustArray); } @@ -558,9 +562,12 @@ export class ZabbixAPIConnector { if (!this.version) { await this.initVersion(); } + + let paramL: any; + if (semver.gte(this.version, '6.2.0')) { - const params: any = { + paramL: any = { output: 'extend', groupids: groupids, hostids: hostids, @@ -583,7 +590,7 @@ export class ZabbixAPIConnector { } else { - const params: any = { + paramL: any = { output: 'extend', groupids: groupids, hostids: hostids, @@ -604,6 +611,9 @@ export class ZabbixAPIConnector { selectTags: 'extend' }; } + + const params = paramL; + if (showTriggers === ShowProblemTypes.Problems) { params.filter.value = 1; } else if (showTriggers === ShowProblemTypes.Recent || showTriggers === ShowProblemTypes.History) { @@ -752,9 +762,12 @@ export class ZabbixAPIConnector { if (!this.version) { await this.initVersion(); } + + let paramL: any; + if (semver.gte(this.version, '6.2.0')) { - const params: any = { + paramL: any = { output: 'extend', hostids: hostids, min_severity: minSeverity, @@ -771,7 +784,7 @@ export class ZabbixAPIConnector { } else { - const params: any = { + paramL: any = { output: 'extend', hostids: hostids, min_severity: minSeverity, @@ -786,6 +799,9 @@ export class ZabbixAPIConnector { selectHosts: ['host', 'name'] }; } + + const params = paramL; + if (count && acknowledged !== 0 && acknowledged !== 1) { params.countOutput = true; } From ed54ee0109abb70b4c4e89444b4d7c11c479575c Mon Sep 17 00:00:00 2001 From: Leonardo Amaral Date: Wed, 6 Jul 2022 11:35:42 -0300 Subject: [PATCH 09/15] * Change to self runner --- .github/workflows/node.js.yml | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index ea786d4b8..b2ea0c652 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -12,7 +12,8 @@ on: jobs: build: - runs-on: ubuntu-latest + #runs-on: ubuntu-latest + runs-on: [self-hosted, linux, X64] strategy: matrix: From 7b1ab924d51850cd481f85443be9f7f58e016a99 Mon Sep 17 00:00:00 2001 From: Leonardo Amaral Date: Wed, 6 Jul 2022 11:40:11 -0300 Subject: [PATCH 10/15] * Attempt to fix param constant scope #3 --- .../connectors/zabbix_api/zabbixAPIConnector.ts | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts index 052c973e3..dcb1f7f15 100644 --- a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts +++ b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts @@ -517,7 +517,7 @@ export class ZabbixAPIConnector { if (semver.gte(this.version, '6.2.0')) { - paramL : any = { + paramL = { output: 'extend', triggerids: triggerids, expandDescription: true, @@ -535,7 +535,7 @@ export class ZabbixAPIConnector { } else { - paramL: any = { + paramL = { output: 'extend', triggerids: triggerids, expandDescription: true, @@ -567,7 +567,7 @@ export class ZabbixAPIConnector { if (semver.gte(this.version, '6.2.0')) { - paramL: any = { + paramL = { output: 'extend', groupids: groupids, hostids: hostids, @@ -590,7 +590,7 @@ export class ZabbixAPIConnector { } else { - paramL: any = { + paramL = { output: 'extend', groupids: groupids, hostids: hostids, @@ -767,7 +767,7 @@ export class ZabbixAPIConnector { if (semver.gte(this.version, '6.2.0')) { - paramL: any = { + paramL = { output: 'extend', hostids: hostids, min_severity: minSeverity, @@ -784,7 +784,7 @@ export class ZabbixAPIConnector { } else { - paramL: any = { + paramL = { output: 'extend', hostids: hostids, min_severity: minSeverity, From 6d790e126a838900a6174f6c48ec767bda856d76 Mon Sep 17 00:00:00 2001 From: Leonardo Amaral Date: Wed, 6 Jul 2022 11:41:27 -0300 Subject: [PATCH 11/15] Revert "* Change to self runner" This reverts commit c07c51898c07d9a34c12ef9e6c0f5c6bc79d113a. --- .github/workflows/node.js.yml | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index b2ea0c652..ea786d4b8 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -12,8 +12,7 @@ on: jobs: build: - #runs-on: ubuntu-latest - runs-on: [self-hosted, linux, X64] + runs-on: ubuntu-latest strategy: matrix: From 31222d440a13e7bbf7508a6483307c68a6f3c632 Mon Sep 17 00:00:00 2001 From: Leonardo Amaral Date: Wed, 6 Jul 2022 11:51:25 -0300 Subject: [PATCH 12/15] * Golang CI/CD fix #1 --- .github/workflows/node.js.yml | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index ea786d4b8..228f7e542 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -22,10 +22,10 @@ jobs: steps: - uses: actions/checkout@v3 - name: Setup Go environment - uses: actions/setup-go@v3.2.0 -# with: + uses: actions/setup-go@v3 + with: # The Go version to download (if necessary) and use. Supports semver spec and ranges. - # go-version: 1.17 # optional + go-version: 1.17 # optional # Path to the go.mod file. - name: Use Node.js ${{ matrix.node-version }} From dba09247c72bcffa0337798dbcf0d0487e44b4a3 Mon Sep 17 00:00:00 2001 From: Sam H Date: Wed, 6 Jul 2022 13:00:48 -0400 Subject: [PATCH 13/15] Update zabbixAPIConnector.ts --- .../zabbix_api/zabbixAPIConnector.ts | 23 ++++++++++++++----- 1 file changed, 17 insertions(+), 6 deletions(-) diff --git a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts index dcb1f7f15..d301f3716 100644 --- a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts +++ b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts @@ -138,7 +138,7 @@ export class ZabbixAPIConnector { } let paramL: any; - + console.log("get groups"); if (semver.gte(this.version, '6.2.0')) { paramL = { @@ -146,6 +146,7 @@ export class ZabbixAPIConnector { sortfield: 'name', with_monitored_hosts: true }; + console.log("6.2.0"); } else @@ -155,6 +156,7 @@ export class ZabbixAPIConnector { sortfield: 'name', real_hosts: true }; + console.log(this.version); } const params = paramL; @@ -170,8 +172,10 @@ export class ZabbixAPIConnector { if (groupids) { params.groupids = groupids; } - - return this.request('host.get', params); + let reqret: any; + reqret = this.request('host.get', params); + console.log(reqret); + return reqret } async getApps(hostids): Promise { @@ -514,9 +518,12 @@ export class ZabbixAPIConnector { } let paramL: any; - + console.log("get triggers by id"); + console.log(this.version); + if (semver.gte(this.version, '6.2.0')) { + console.log("gte works"); paramL = { output: 'extend', triggerids: triggerids, @@ -564,9 +571,11 @@ export class ZabbixAPIConnector { } let paramL: any; - + console.log("get triggers"); + console.log(this.version); if (semver.gte(this.version, '6.2.0')) { + console.log("gte works 2"); paramL = { output: 'extend', groupids: groupids, @@ -764,9 +773,11 @@ export class ZabbixAPIConnector { } let paramL: any; - + console.log("get host alerts"); + console.log(this.version); if (semver.gte(this.version, '6.2.0')) { + console.log("gte hosts alerts works"); paramL = { output: 'extend', hostids: hostids, From a5cdb1974c45e618fb13ed106ef7153da239aba6 Mon Sep 17 00:00:00 2001 From: Sam H Date: Wed, 6 Jul 2022 14:08:57 -0400 Subject: [PATCH 14/15] Update zabbixAPIConnector.ts --- .../zabbix/connectors/zabbix_api/zabbixAPIConnector.ts | 1 + 1 file changed, 1 insertion(+) diff --git a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts index d301f3716..aa238fa20 100644 --- a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts +++ b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts @@ -173,6 +173,7 @@ export class ZabbixAPIConnector { params.groupids = groupids; } let reqret: any; + console.log(params); reqret = this.request('host.get', params); console.log(reqret); return reqret From baf66880ede089620f29d68d554e85ede4f9fa35 Mon Sep 17 00:00:00 2001 From: Leonardo Amaral Date: Thu, 7 Jul 2022 12:05:57 -0300 Subject: [PATCH 15/15] Changes to fix zabbix-6.2 * Cleanup GetAllGroups * Minor fix concerning context of constant params * Creation of isZabbix620OrHigher to comply with upstream * Debuging console.log as if there is no tomorrow --- .github/workflows/node.js.yml | 5 +- pkg/zabbix/methods.go | 21 ------ .../zabbix_api/zabbixAPIConnector.ts | 67 +++++++++++-------- 3 files changed, 40 insertions(+), 53 deletions(-) diff --git a/.github/workflows/node.js.yml b/.github/workflows/node.js.yml index 228f7e542..c7efeb908 100644 --- a/.github/workflows/node.js.yml +++ b/.github/workflows/node.js.yml @@ -16,7 +16,7 @@ jobs: strategy: matrix: - node-version: [16.x] + node-version: [16] # See supported Node.js release schedule at https://nodejs.org/en/about/releases/ steps: @@ -25,7 +25,7 @@ jobs: uses: actions/setup-go@v3 with: # The Go version to download (if necessary) and use. Supports semver spec and ranges. - go-version: 1.17 # optional + go-version: 1.18 # optional # Path to the go.mod file. - name: Use Node.js ${{ matrix.node-version }} @@ -33,7 +33,6 @@ jobs: with: node-version: ${{ matrix.node-version }} #cache: 'npm' - - run: make - run: make install - run: make dist - name: Upload a Build Artifact diff --git a/pkg/zabbix/methods.go b/pkg/zabbix/methods.go index 9ffe9a267..3b2196826 100644 --- a/pkg/zabbix/methods.go +++ b/pkg/zabbix/methods.go @@ -390,28 +390,7 @@ func (ds *Zabbix) GetAllHosts(ctx context.Context, groupids []string) ([]Host, e err = convertTo(result, &hosts) return hosts, err } -/* -func (ds *Zabbix) GetAllGroups(ctx context.Context) ([]Group, error) { - params := ZabbixAPIParams{ - "output": []string{"name"}, - "sortfield": "name", - "real_hosts": true, - } - - result, err := ds.Request(ctx, &ZabbixAPIRequest{Method: "hostgroup.get", Params: params}) - if err != nil { - return nil, err - } - - var groups []Group - err = convertTo(result, &groups) - return groups, err -} - - - -*/ func (ds *Zabbix) GetAllGroups(ctx context.Context) ([]Group, error) { params := ZabbixAPIParams{} if ds.version >= 62 { diff --git a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts index aa238fa20..44187b277 100644 --- a/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts +++ b/src/datasource-zabbix/zabbix/connectors/zabbix_api/zabbixAPIConnector.ts @@ -110,6 +110,11 @@ export class ZabbixAPIConnector { return semver.gte(this.version, '5.4.0'); } + isZabbix62OrHigher() { + return semver.gte(this.version, '6.2.0'); + } + + //////////////////////////////// // Zabbix API method wrappers // //////////////////////////////// @@ -139,14 +144,14 @@ export class ZabbixAPIConnector { let paramL: any; console.log("get groups"); - if (semver.gte(this.version, '6.2.0')) + if (this.isZabbix62OrHigher()) { paramL = { output: ['name'], sortfield: 'name', with_monitored_hosts: true }; - console.log("6.2.0"); + console.log(this.version); } else @@ -158,10 +163,13 @@ export class ZabbixAPIConnector { }; console.log(this.version); } + + console.log("getGroups request paramL"); + console.log(paramL); + console.log("getGroups request response"); + console.log(this.request('hostgroup.get', paramL)); - const params = paramL; - - return this.request('hostgroup.get', params); + return this.request('hostgroup.get', paramL); } getHosts(groupids) { @@ -169,13 +177,20 @@ export class ZabbixAPIConnector { output: ['name', 'host'], sortfield: 'name' }; - if (groupids) { + console.log("getHosts groupids"); + console.log(groupids); + + if (groupids != null) { params.groupids = groupids; } let reqret: any; - console.log(params); reqret = this.request('host.get', params); - console.log(reqret); + + console.log("getHosts request paramL"); + console.log(params); + console.log("getHosts request response"); + console.log(this.request('host.get', params)); + return reqret } @@ -522,7 +537,7 @@ export class ZabbixAPIConnector { console.log("get triggers by id"); console.log(this.version); - if (semver.gte(this.version, '6.2.0')) + if (this.isZabbix62OrHigher()) { console.log("gte works"); paramL = { @@ -560,9 +575,7 @@ export class ZabbixAPIConnector { }; } - const params = paramL; - - return this.request('trigger.get', params).then(utils.mustArray); + return this.request('trigger.get', paramL).then(utils.mustArray); } async getTriggers(groupids, hostids, applicationids, options) { @@ -574,7 +587,7 @@ export class ZabbixAPIConnector { let paramL: any; console.log("get triggers"); console.log(this.version); - if (semver.gte(this.version, '6.2.0')) + if (this.isZabbix62OrHigher()) { console.log("gte works 2"); paramL = { @@ -622,24 +635,22 @@ export class ZabbixAPIConnector { }; } - const params = paramL; - if (showTriggers === ShowProblemTypes.Problems) { - params.filter.value = 1; + paramL.filter.value = 1; } else if (showTriggers === ShowProblemTypes.Recent || showTriggers === ShowProblemTypes.History) { - params.filter.value = [0, 1]; + paramL.filter.value = [0, 1]; } if (maintenance) { - params.maintenance = true; + paramL.maintenance = true; } if (timeFrom || timeTo) { - params.lastChangeSince = timeFrom; - params.lastChangeTill = timeTo; + paramL.lastChangeSince = timeFrom; + paramL.lastChangeTill = timeTo; } - return this.request('trigger.get', params); + return this.request('trigger.get', paramL); } getEvents(objectids, timeFrom, timeTo, showEvents, limit) { @@ -776,7 +787,7 @@ export class ZabbixAPIConnector { let paramL: any; console.log("get host alerts"); console.log(this.version); - if (semver.gte(this.version, '6.2.0')) + if (this.isZabbix62OrHigher()) { console.log("gte hosts alerts works"); paramL = { @@ -812,22 +823,20 @@ export class ZabbixAPIConnector { }; } - const params = paramL; - if (count && acknowledged !== 0 && acknowledged !== 1) { - params.countOutput = true; + paramL.countOutput = true; } if (applicationids && applicationids.length) { - params.applicationids = applicationids; + paramL.applicationids = applicationids; } if (timeFrom || timeTo) { - params.lastChangeSince = timeFrom; - params.lastChangeTill = timeTo; + paramL.lastChangeSince = timeFrom; + paramL.lastChangeTill = timeTo; } - return this.request('trigger.get', params) + return this.request('trigger.get', paramL) .then((triggers) => { if (!count || acknowledged === 0 || acknowledged === 1) { triggers = filterTriggersByAcknowledge(triggers, acknowledged);