diff options
author | Eriks Sneiders <eriks.sneiders@zabbix.com> | 2022-04-12 14:39:48 +0300 |
---|---|---|
committer | Eriks Sneiders <eriks.sneiders@zabbix.com> | 2022-04-12 14:39:53 +0300 |
commit | 39d7b4170fb1064aef045b77d2919024203afd9d (patch) | |
tree | 4f07065888713e16e10bd2ba6ddb1e4004fd2e36 /src/go | |
parent | ab3b3d4df1f61201f04ba6ea4cb30394eaf107cd (diff) |
...G...... [DEV-2061] moved Zabbix agent 2 plugin support packages to separate repository
Diffstat (limited to 'src/go')
275 files changed, 373 insertions, 5653 deletions
diff --git a/src/go/cmd/mock_server/mock_server.go b/src/go/cmd/mock_server/mock_server.go index e7eeaa70e8b..6f70016a3cc 100644 --- a/src/go/cmd/mock_server/mock_server.go +++ b/src/go/cmd/mock_server/mock_server.go @@ -28,8 +28,8 @@ import ( "strconv" "time" - "zabbix.com/pkg/conf" - "zabbix.com/pkg/log" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/log" "zabbix.com/pkg/zbxcomms" ) diff --git a/src/go/cmd/zabbix_agent2/config.go b/src/go/cmd/zabbix_agent2/config.go index e86c8eb1658..29416e35e6c 100644 --- a/src/go/cmd/zabbix_agent2/config.go +++ b/src/go/cmd/zabbix_agent2/config.go @@ -24,9 +24,9 @@ import ( "strings" "time" + "git.zabbix.com/ap/plugin-support/log" "zabbix.com/internal/agent" "zabbix.com/internal/agent/scheduler" - "zabbix.com/pkg/log" "zabbix.com/pkg/zbxcmd" ) diff --git a/src/go/cmd/zabbix_agent2/external.go b/src/go/cmd/zabbix_agent2/external.go index 8bedaa6bc02..5146295693a 100644 --- a/src/go/cmd/zabbix_agent2/external.go +++ b/src/go/cmd/zabbix_agent2/external.go @@ -26,10 +26,10 @@ import ( "os" "time" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/plugin/comms" "zabbix.com/internal/agent" - "zabbix.com/pkg/conf" - "zabbix.com/pkg/plugin" - "zabbix.com/pkg/plugin/comms" "zabbix.com/plugins/external" ) diff --git a/src/go/cmd/zabbix_agent2/external_nix.go b/src/go/cmd/zabbix_agent2/external_nix.go index 1e5a11ada03..5301e0b0386 100644 --- a/src/go/cmd/zabbix_agent2/external_nix.go +++ b/src/go/cmd/zabbix_agent2/external_nix.go @@ -29,8 +29,8 @@ import ( "os/signal" "syscall" - "zabbix.com/pkg/log" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/plugins/external" ) diff --git a/src/go/cmd/zabbix_agent2/service_windows.go b/src/go/cmd/zabbix_agent2/service_windows.go index c1da1708778..7e835dab555 100644 --- a/src/go/cmd/zabbix_agent2/service_windows.go +++ b/src/go/cmd/zabbix_agent2/service_windows.go @@ -28,6 +28,7 @@ import ( "sync" "time" + "git.zabbix.com/ap/plugin-support/log" "golang.org/x/sys/windows/svc" "golang.org/x/sys/windows/svc/eventlog" "golang.org/x/sys/windows/svc/mgr" @@ -35,7 +36,6 @@ import ( "zabbix.com/internal/agent/keyaccess" "zabbix.com/internal/agent/scheduler" "zabbix.com/internal/monitor" - "zabbix.com/pkg/log" ) var ( diff --git a/src/go/cmd/zabbix_agent2/zabbix_agent2.go b/src/go/cmd/zabbix_agent2/zabbix_agent2.go index 38c82642d7e..dd6d853777d 100644 --- a/src/go/cmd/zabbix_agent2/zabbix_agent2.go +++ b/src/go/cmd/zabbix_agent2/zabbix_agent2.go @@ -29,6 +29,8 @@ import ( _ "zabbix.com/plugins" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/log" "zabbix.com/internal/agent" "zabbix.com/internal/agent/keyaccess" "zabbix.com/internal/agent/remotecontrol" @@ -38,8 +40,6 @@ import ( "zabbix.com/internal/agent/serverlistener" "zabbix.com/internal/agent/statuslistener" "zabbix.com/internal/monitor" - "zabbix.com/pkg/conf" - "zabbix.com/pkg/log" "zabbix.com/pkg/pidfile" "zabbix.com/pkg/tls" "zabbix.com/pkg/version" diff --git a/src/go/cmd/zabbix_agent2/zabbix_agent2_nix.go b/src/go/cmd/zabbix_agent2/zabbix_agent2_nix.go index 60b66af6143..eddb7319a8f 100644 --- a/src/go/cmd/zabbix_agent2/zabbix_agent2_nix.go +++ b/src/go/cmd/zabbix_agent2/zabbix_agent2_nix.go @@ -27,7 +27,7 @@ import ( "os/signal" "syscall" - "zabbix.com/pkg/log" + "git.zabbix.com/ap/plugin-support/log" ) func loadOSDependentItems() error { diff --git a/src/go/cmd/zabbix_web_service/pdf_report_creator.go b/src/go/cmd/zabbix_web_service/pdf_report_creator.go index 391b58bc29b..22221a6a46e 100644 --- a/src/go/cmd/zabbix_web_service/pdf_report_creator.go +++ b/src/go/cmd/zabbix_web_service/pdf_report_creator.go @@ -31,12 +31,12 @@ import ( "strconv" "time" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/chromedp/cdproto/emulation" "github.com/chromedp/cdproto/network" "github.com/chromedp/cdproto/page" "github.com/chromedp/chromedp" - "zabbix.com/pkg/log" - "zabbix.com/pkg/zbxerr" ) type requestBody struct { diff --git a/src/go/cmd/zabbix_web_service/zabbix_web_service.go b/src/go/cmd/zabbix_web_service/zabbix_web_service.go index 21b65855c91..902f0450b54 100644 --- a/src/go/cmd/zabbix_web_service/zabbix_web_service.go +++ b/src/go/cmd/zabbix_web_service/zabbix_web_service.go @@ -31,8 +31,8 @@ import ( "os/signal" "syscall" - "zabbix.com/pkg/conf" - "zabbix.com/pkg/log" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/log" "zabbix.com/pkg/version" "zabbix.com/pkg/zbxnet" ) diff --git a/src/go/go.mod b/src/go/go.mod index ac513bf57d2..dad340ec44d 100644 --- a/src/go/go.mod +++ b/src/go/go.mod @@ -3,6 +3,7 @@ module zabbix.com go 1.16 require ( + git.zabbix.com/ap/plugin-support v0.0.1 github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69 github.com/cakturk/go-netstat v0.0.0-20200220111822-e5b49efee7a5 github.com/chromedp/cdproto v0.0.0-20210104223854-2cc87dae3ee3 @@ -25,10 +26,9 @@ require ( github.com/natefinch/npipe v0.0.0-20160621034901-c1b8fa8bdcce github.com/omeid/go-yarn v0.0.1 github.com/pkg/errors v0.9.1 // indirect - golang.org/x/sys v0.0.0-20210303074136-134d130e1a04 + golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 golang.org/x/xerrors v0.0.0-20200804184101-5ec99f83aff1 // indirect gopkg.in/asn1-ber.v1 v1.0.0-20181015200546-f715ec2f112d // indirect gopkg.in/mgo.v2 v2.0.0-20190816093944-a6b53ec6cb22 - gopkg.in/natefinch/npipe.v2 v2.0.0-20160621034901-c1b8fa8bdcce // indirect gopkg.in/yaml.v2 v2.2.8 // indirect ) diff --git a/src/go/go.sum b/src/go/go.sum index 5959d1f6cde..00576472dc1 100644 --- a/src/go/go.sum +++ b/src/go/go.sum @@ -1,3 +1,5 @@ +git.zabbix.com/ap/plugin-support v0.0.1 h1:4qMqaxi79wvAMqSB+pDwC/F+Q0tmTE1jaIRSv0MfgWo= +git.zabbix.com/ap/plugin-support v0.0.1/go.mod h1:R3QzQWgpxlA+ddJNkOhsPTcGOVtrR69WS0hXIsnBurY= github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69 h1:+tu3HOoMXB7RXEINRVIpxJCT+KdYiI7LAEAUrOw3dIU= github.com/BurntSushi/locker v0.0.0-20171006230638-a6e239ea1c69/go.mod h1:L1AbZdiDllfyYH5l5OkAaZtk7VkWe89bPJFmnDBNHxg= github.com/BurntSushi/toml v0.3.1/go.mod h1:xHWCNGjB5oqiDr8zfno3MHue2Ht5sIBksp03qcyfWMU= @@ -187,7 +189,6 @@ golang.org/x/mod v0.0.0-20190513183733-4bf6d317e70e/go.mod h1:mXi4GBBbnImb6dmsKG golang.org/x/net v0.0.0-20190311183353-d8887717615a/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190404232315-eb5bcb51f2a3/go.mod h1:t9HGtf8HONx5eT2rtn7q6eTqICYqUVnKs3thJo3Qplg= golang.org/x/net v0.0.0-20190620200207-3b0461eec859/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= -golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7 h1:fHDIZ2oxGnUZRN6WgWFCbYBjH9uqVPRCUVUDhs0wnbA= golang.org/x/net v0.0.0-20190813141303-74dc4d7220e7/go.mod h1:z5CRVTTTmAJ677TzLLGU+0bjPO0LkuOLi4/5GtJWs/s= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110 h1:qWPm9rbaAMKs8Bq/9LRpbMqxWRVUAQwMI9fVrssnTfw= golang.org/x/net v0.0.0-20210226172049-e18ecbb05110/go.mod h1:m0MpNAwzfU5UDzcl9v0D8zg8gWTRqZa9RBIspLL5mdg= @@ -206,11 +207,11 @@ golang.org/x/sys v0.0.0-20190826190057-c7b8b68b1456/go.mod h1:h1NjWce9XRLGQEsW7w golang.org/x/sys v0.0.0-20191005200804-aed5e4c7ecf9/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200116001909-b77594299b42/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20200223170610-d5e6a3e2c0ae/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210104204734-6f8348627aad h1:MCsdmFSdEd4UEa5TKS5JztCRHK/WtvNei1edOj5RSRo= -golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20201119102817-f84b799fce68/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= -golang.org/x/sys v0.0.0-20210303074136-134d130e1a04 h1:cEhElsAv9LUt9ZUUocxzWe05oFLVd+AA2nstydTeI8g= +golang.org/x/sys v0.0.0-20210104204734-6f8348627aad/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= golang.org/x/sys v0.0.0-20210303074136-134d130e1a04/go.mod h1:h1NjWce9XRLGQEsW7wpKNCjG9DtNlClVuFLEZdDNbEs= +golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5 h1:y/woIyUBFbpQGKS0u1aHF/40WUDnek3fPOyD08H5Vng= +golang.org/x/sys v0.0.0-20220310020820-b874c991c1a5/go.mod h1:oPkhp1MJrh7nUepCBck5+mAzfO9JrbApNNgaTdGDITg= golang.org/x/term v0.0.0-20201126162022-7de9c90e9dd1/go.mod h1:bj7SfCRtBDWHUb9snDiAeCFNEtKQo2Wmx5Cou7ajbmo= golang.org/x/text v0.3.0/go.mod h1:NqM8EUOU14njkJ3fqMW+pc6Ldnwhi/IjpwHt7yyuwOQ= golang.org/x/text v0.3.2/go.mod h1:bEr9sfX3Q8Zfm5fL9x+3itogRgK3+ptLWKqgva+5dAk= diff --git a/src/go/internal/agent/alias/alias_test.go b/src/go/internal/agent/alias/alias_test.go index 97f4d455e37..f68e744f92f 100644 --- a/src/go/internal/agent/alias/alias_test.go +++ b/src/go/internal/agent/alias/alias_test.go @@ -22,9 +22,9 @@ package alias import ( "testing" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/log" "zabbix.com/internal/agent" - "zabbix.com/pkg/conf" - "zabbix.com/pkg/log" ) func TestGetAlias(t *testing.T) { diff --git a/src/go/internal/agent/keyaccess/key_access_rules.go b/src/go/internal/agent/keyaccess/key_access_rules.go index da35581a864..38fe3004d73 100644 --- a/src/go/internal/agent/keyaccess/key_access_rules.go +++ b/src/go/internal/agent/keyaccess/key_access_rules.go @@ -25,9 +25,9 @@ import ( "math" "sort" - "zabbix.com/pkg/conf" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/log" "zabbix.com/pkg/itemutil" - "zabbix.com/pkg/log" "zabbix.com/pkg/wildcard" ) diff --git a/src/go/internal/agent/keyaccess/key_access_rules_test.go b/src/go/internal/agent/keyaccess/key_access_rules_test.go index 5834a377dcf..100abc6c84b 100644 --- a/src/go/internal/agent/keyaccess/key_access_rules_test.go +++ b/src/go/internal/agent/keyaccess/key_access_rules_test.go @@ -25,7 +25,7 @@ package keyaccess import ( "testing" - "zabbix.com/pkg/conf" + "git.zabbix.com/ap/plugin-support/conf" "zabbix.com/pkg/itemutil" ) diff --git a/src/go/internal/agent/options.go b/src/go/internal/agent/options.go index 399c15c4a2f..21825eb87e9 100644 --- a/src/go/internal/agent/options.go +++ b/src/go/internal/agent/options.go @@ -28,7 +28,7 @@ import ( "strings" "unicode" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/pkg/tls" ) diff --git a/src/go/internal/agent/plugin_agent.go b/src/go/internal/agent/plugin_agent.go index 2b698686ab0..0592f6e8abe 100644 --- a/src/go/internal/agent/plugin_agent.go +++ b/src/go/internal/agent/plugin_agent.go @@ -25,8 +25,8 @@ import ( "time" "unicode/utf8" - "zabbix.com/pkg/log" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/pkg/version" ) diff --git a/src/go/internal/agent/plugin_userparameter.go b/src/go/internal/agent/plugin_userparameter.go index 5b9598079c6..510f9454ae8 100644 --- a/src/go/internal/agent/plugin_userparameter.go +++ b/src/go/internal/agent/plugin_userparameter.go @@ -26,8 +26,8 @@ import ( "time" "unicode" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/pkg/itemutil" - "zabbix.com/pkg/plugin" "zabbix.com/pkg/zbxcmd" ) diff --git a/src/go/internal/agent/plugin_userparameter_test.go b/src/go/internal/agent/plugin_userparameter_test.go index 5911a4a834e..facb76357cf 100644 --- a/src/go/internal/agent/plugin_userparameter_test.go +++ b/src/go/internal/agent/plugin_userparameter_test.go @@ -3,7 +3,7 @@ package agent import ( "testing" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) type Input struct { diff --git a/src/go/internal/agent/remotecontrol/remote_nix.go b/src/go/internal/agent/remotecontrol/remote_nix.go index 9f49ad8ee05..aa41c9d6945 100644 --- a/src/go/internal/agent/remotecontrol/remote_nix.go +++ b/src/go/internal/agent/remotecontrol/remote_nix.go @@ -30,7 +30,7 @@ import ( "syscall" "time" - "zabbix.com/pkg/log" + "git.zabbix.com/ap/plugin-support/log" ) func New(path string, timeout time.Duration) (conn *Conn, err error) { diff --git a/src/go/internal/agent/remotecontrol/remote_windows.go b/src/go/internal/agent/remotecontrol/remote_windows.go index e81f218520f..cfcd8b7a6f2 100644 --- a/src/go/internal/agent/remotecontrol/remote_windows.go +++ b/src/go/internal/agent/remotecontrol/remote_windows.go @@ -26,7 +26,7 @@ import ( "os" "time" - "zabbix.com/pkg/log" + "git.zabbix.com/ap/plugin-support/log" "github.com/natefinch/npipe" ) diff --git a/src/go/internal/agent/resultcache/diskcache.go b/src/go/internal/agent/resultcache/diskcache.go index 4f13e0a125b..f1e87419368 100644 --- a/src/go/internal/agent/resultcache/diskcache.go +++ b/src/go/internal/agent/resultcache/diskcache.go @@ -28,11 +28,11 @@ import ( "sync/atomic" "time" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/internal/agent" "zabbix.com/internal/monitor" "zabbix.com/pkg/itemutil" - "zabbix.com/pkg/log" - "zabbix.com/pkg/plugin" "zabbix.com/pkg/version" _ "github.com/mattn/go-sqlite3" diff --git a/src/go/internal/agent/resultcache/memorycache.go b/src/go/internal/agent/resultcache/memorycache.go index ce8049174c1..b603b91488f 100644 --- a/src/go/internal/agent/resultcache/memorycache.go +++ b/src/go/internal/agent/resultcache/memorycache.go @@ -25,11 +25,11 @@ import ( "sync/atomic" "time" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/internal/agent" "zabbix.com/internal/monitor" "zabbix.com/pkg/itemutil" - "zabbix.com/pkg/log" - "zabbix.com/pkg/plugin" "zabbix.com/pkg/version" ) diff --git a/src/go/internal/agent/resultcache/resultcache.go b/src/go/internal/agent/resultcache/resultcache.go index 712e455cc89..e99cad7f7e0 100644 --- a/src/go/internal/agent/resultcache/resultcache.go +++ b/src/go/internal/agent/resultcache/resultcache.go @@ -49,9 +49,9 @@ import ( "os" "time" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/internal/agent" - "zabbix.com/pkg/log" - "zabbix.com/pkg/plugin" ) const ( diff --git a/src/go/internal/agent/resultcache/resultcache_test.go b/src/go/internal/agent/resultcache/resultcache_test.go index 986427f8d6e..25dbe098387 100644 --- a/src/go/internal/agent/resultcache/resultcache_test.go +++ b/src/go/internal/agent/resultcache/resultcache_test.go @@ -25,9 +25,9 @@ import ( "testing" "time" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/internal/agent" - "zabbix.com/pkg/log" - "zabbix.com/pkg/plugin" ) type mockWriter struct { diff --git a/src/go/internal/agent/scheduler/client.go b/src/go/internal/agent/scheduler/client.go index a958c237ce2..92c4641a037 100644 --- a/src/go/internal/agent/scheduler/client.go +++ b/src/go/internal/agent/scheduler/client.go @@ -27,10 +27,10 @@ import ( "time" "unsafe" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/internal/agent" "zabbix.com/pkg/glexpr" - "zabbix.com/pkg/log" - "zabbix.com/pkg/plugin" "zabbix.com/pkg/zbxlib" ) diff --git a/src/go/internal/agent/scheduler/manager.go b/src/go/internal/agent/scheduler/manager.go index 47fc7cc399e..fce6572f379 100644 --- a/src/go/internal/agent/scheduler/manager.go +++ b/src/go/internal/agent/scheduler/manager.go @@ -27,15 +27,15 @@ import ( "sort" "time" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/internal/agent" "zabbix.com/internal/agent/alias" "zabbix.com/internal/agent/keyaccess" "zabbix.com/internal/monitor" - "zabbix.com/pkg/conf" "zabbix.com/pkg/glexpr" "zabbix.com/pkg/itemutil" - "zabbix.com/pkg/log" - "zabbix.com/pkg/plugin" "zabbix.com/plugins/external" ) diff --git a/src/go/internal/agent/scheduler/manager_test.go b/src/go/internal/agent/scheduler/manager_test.go index 305876e9943..ffc3ad162ac 100644 --- a/src/go/internal/agent/scheduler/manager_test.go +++ b/src/go/internal/agent/scheduler/manager_test.go @@ -27,12 +27,12 @@ import ( "testing" "time" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/internal/agent" "zabbix.com/internal/agent/alias" - "zabbix.com/pkg/conf" "zabbix.com/pkg/itemutil" - "zabbix.com/pkg/log" - "zabbix.com/pkg/plugin" ) // getNextCheck calculates simplified nextcheck based on the specified delay string and current time diff --git a/src/go/internal/agent/scheduler/plugin.go b/src/go/internal/agent/scheduler/plugin.go index 83f99194a96..202dca8b2e5 100644 --- a/src/go/internal/agent/scheduler/plugin.go +++ b/src/go/internal/agent/scheduler/plugin.go @@ -22,7 +22,7 @@ package scheduler import ( "container/heap" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) // pluginAgent manages plugin usage diff --git a/src/go/internal/agent/scheduler/query.go b/src/go/internal/agent/scheduler/query.go index bf20d546220..935d78dcc73 100644 --- a/src/go/internal/agent/scheduler/query.go +++ b/src/go/internal/agent/scheduler/query.go @@ -25,7 +25,7 @@ import ( "sort" "strings" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/plugins/external" ) diff --git a/src/go/internal/agent/scheduler/task.go b/src/go/internal/agent/scheduler/task.go index 2c812a07a0e..b50446084bb 100644 --- a/src/go/internal/agent/scheduler/task.go +++ b/src/go/internal/agent/scheduler/task.go @@ -25,10 +25,10 @@ import ( "reflect" "time" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/internal/agent" "zabbix.com/pkg/itemutil" - "zabbix.com/pkg/log" - "zabbix.com/pkg/plugin" "zabbix.com/pkg/zbxlib" ) diff --git a/src/go/internal/agent/serverconnector/serverconnector.go b/src/go/internal/agent/serverconnector/serverconnector.go index 275605e12ff..73593e26812 100644 --- a/src/go/internal/agent/serverconnector/serverconnector.go +++ b/src/go/internal/agent/serverconnector/serverconnector.go @@ -29,13 +29,13 @@ import ( "time" "unicode/utf8" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/internal/agent" "zabbix.com/internal/agent/resultcache" "zabbix.com/internal/agent/scheduler" "zabbix.com/internal/monitor" "zabbix.com/pkg/glexpr" - "zabbix.com/pkg/log" - "zabbix.com/pkg/plugin" "zabbix.com/pkg/tls" "zabbix.com/pkg/version" "zabbix.com/pkg/zbxcomms" diff --git a/src/go/internal/agent/serverlistener/passivecheck.go b/src/go/internal/agent/serverlistener/passivecheck.go index 437d84bc799..6a8151d9c68 100644 --- a/src/go/internal/agent/serverlistener/passivecheck.go +++ b/src/go/internal/agent/serverlistener/passivecheck.go @@ -22,9 +22,9 @@ package serverlistener import ( "time" + "git.zabbix.com/ap/plugin-support/log" "zabbix.com/internal/agent" "zabbix.com/internal/agent/scheduler" - "zabbix.com/pkg/log" ) const notsupported = "ZBX_NOTSUPPORTED" diff --git a/src/go/internal/agent/serverlistener/serverlistener.go b/src/go/internal/agent/serverlistener/serverlistener.go index 739d4335215..ab6eb8c7706 100644 --- a/src/go/internal/agent/serverlistener/serverlistener.go +++ b/src/go/internal/agent/serverlistener/serverlistener.go @@ -25,10 +25,10 @@ import ( "strings" "time" + "git.zabbix.com/ap/plugin-support/log" "zabbix.com/internal/agent" "zabbix.com/internal/agent/scheduler" "zabbix.com/internal/monitor" - "zabbix.com/pkg/log" "zabbix.com/pkg/tls" "zabbix.com/pkg/zbxcomms" "zabbix.com/pkg/zbxnet" diff --git a/src/go/internal/agent/statuslistener/statuslistener.go b/src/go/internal/agent/statuslistener/statuslistener.go index 4c43469bcf4..cb5f534ae0a 100644 --- a/src/go/internal/agent/statuslistener/statuslistener.go +++ b/src/go/internal/agent/statuslistener/statuslistener.go @@ -26,10 +26,10 @@ import ( "net/http" "time" + "git.zabbix.com/ap/plugin-support/log" "zabbix.com/internal/agent" "zabbix.com/internal/agent/scheduler" "zabbix.com/internal/monitor" - "zabbix.com/pkg/log" "zabbix.com/pkg/version" ) diff --git a/src/go/pkg/conf/conf.go b/src/go/pkg/conf/conf.go deleted file mode 100644 index 5aa1a958590..00000000000 --- a/src/go/pkg/conf/conf.go +++ /dev/null @@ -1,726 +0,0 @@ -/* -** Zabbix -** Copyright (C) 2001-2022 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - -// Package conf provides .conf file loading and unmarshalling -package conf - -import ( - "bytes" - "encoding/base64" - "errors" - "fmt" - "os" - "path/filepath" - "reflect" - "runtime" - "strconv" - "strings" - "unicode/utf8" - - "zabbix.com/pkg/std" -) - -// Meta structure is used to store the 'conf' tag metadata. -type Meta struct { - name string - defaultValue *string - optional bool - min int64 - max int64 -} -type Suffix struct { - suffix string - factor int -} - -var currentConfigPath string - -// setCurrentConfigPath sets a path of the current config file. -func setCurrentConfigPath(path string) { - currentConfigPath = path -} - -// GetCurrentConfigPath returns a path of the current config file. -func GetCurrentConfigPath() string { - return currentConfigPath -} - -func validateParameterName(key []byte) (err error) { - for i, b := range key { - if ('A' > b || b > 'Z') && ('a' > b || b > 'z') && ('0' > b || b > '9') && b != '_' && b != '.' { - return fmt.Errorf("invalid character '%c' at position %d", b, i+1) - } - } - return -} - -// parseLine parses parameter configuration line and returns key,value pair. -// The line must have format: <key>[ ]=[ ]<value> where whitespace surrounding -// '=' is optional. -func parseLine(line []byte) (key []byte, value []byte, err error) { - valueStart := bytes.IndexByte(line, '=') - if valueStart == -1 { - return nil, nil, errors.New("missing assignment operator") - } - - if key = bytes.TrimSpace(line[:valueStart]); len(key) == 0 { - return nil, nil, errors.New("missing variable name") - } - - if err = validateParameterName(key); err != nil { - return - } - - return key, bytes.TrimSpace(line[valueStart+1:]), nil -} - -// getMeta returns 'conf' tag metadata. -// The metadata has format [name=<name>,][optional,][range=<range>,][default=<default value>] -// where: -// <name> - the parameter name, -// optional - set if the value is optional, -// <range> - the allowed range <min>:<max>, where <min>, <max> values are optional, -// <default value> - the default value. If specified it must always be the last tag. -func getMeta(field reflect.StructField) (meta *Meta, err error) { - m := Meta{name: "", optional: false, min: -1, max: -1} - conf := field.Tag.Get("conf") - -loop: - for conf != "" { - tags := strings.SplitN(conf, ",", 2) - fields := strings.SplitN(tags[0], "=", 2) - tag := strings.TrimSpace(fields[0]) - if len(fields) == 1 { - // boolean tag - switch tag { - case "optional": - m.optional = true - default: - return nil, fmt.Errorf("invalid conf tag '%s'", tag) - } - } else { - // value tag - switch tag { - case "default": - value := fields[1] - if len(tags) == 2 { - value += "," + tags[1] - } - m.defaultValue = &value - break loop - case "name": - m.name = strings.TrimSpace(fields[1]) - case "range": - limits := strings.Split(fields[1], ":") - if len(limits) != 2 { - return nil, errors.New("invalid range format") - } - if limits[0] != "" { - m.min, _ = strconv.ParseInt(limits[0], 10, 64) - } - if limits[1] != "" { - m.max, _ = strconv.ParseInt(limits[1], 10, 64) - } - default: - return nil, fmt.Errorf("invalid conf tag '%s'", tag) - } - } - - if len(tags) == 1 { - break - } - conf = tags[1] - } - - if m.name == "" { - m.name = field.Name - } - return &m, nil -} - -func getTimeSuffix(str string) (string, int) { - suffixes := []Suffix{ - Suffix{ - suffix: "s", - factor: 1, - }, - Suffix{ - suffix: "m", - factor: 60, - }, - Suffix{ - suffix: "h", - factor: 3600, - }, - Suffix{ - suffix: "d", - factor: 86400, - }, - Suffix{ - suffix: "w", - factor: (7 * 86400), - }, - } - - for _, s := range suffixes { - if strings.HasSuffix(str, s.suffix) == true { - str = strings.TrimSuffix(str, s.suffix) - return str, s.factor - } - } - return str, 1 - -} - -func setBasicValue(value reflect.Value, meta *Meta, str *string) (err error) { - if str == nil { - return nil - } - switch value.Type().Kind() { - case reflect.String: - value.SetString(*str) - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64: - var v int64 - var r int - *str, r = getTimeSuffix(*str) - if v, err = strconv.ParseInt(*str, 10, 64); err == nil { - v = v * int64(r) - if meta != nil { - if meta.min != -1 && v < meta.min || meta.max != -1 && v > meta.max { - return errors.New("value out of range") - } - } - value.SetInt(v) - } - case reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64: - var v uint64 - var r int - *str, r = getTimeSuffix(*str) - if v, err = strconv.ParseUint(*str, 10, 64); err == nil { - v = v * uint64(r) - if meta != nil { - if meta.min != -1 && v < uint64(meta.min) || meta.max != -1 && v > uint64(meta.max) { - return errors.New("value out of range") - } - } - value.SetUint(v) - } - case reflect.Float32, reflect.Float64: - var v float64 - if v, err = strconv.ParseFloat(*str, 64); err == nil { - if meta != nil { - if meta.min != -1 && v < float64(meta.min) || meta.max != -1 && v > float64(meta.max) { - return errors.New("value out of range") - } - } - value.SetFloat(v) - } - case reflect.Bool: - var v bool - switch *str { - case "true": - v = true - case "false": - v = false - default: - return errors.New("invalid boolean value") - } - value.SetBool(v) - case reflect.Ptr: - v := reflect.New(value.Type().Elem()) - value.Set(v) - return setBasicValue(v.Elem(), meta, str) - default: - err = fmt.Errorf("unsupported variable type %v", value.Type().Kind()) - } - return err -} - -func setStructValue(value reflect.Value, node *Node) (err error) { - rt := value.Type() - for i := 0; i < rt.NumField(); i++ { - var meta *Meta - if meta, err = getMeta(rt.Field(i)); err != nil { - return - } - child := node.get(meta.name) - if child != nil || meta.defaultValue != nil { - if err = setValue(value.Field(i), meta, child); err != nil { - return - } - } else if !meta.optional { - return fmt.Errorf("cannot find mandatory parameter %s", meta.name) - } - } - return -} - -func setMapValue(value reflect.Value, node *Node) (err error) { - m := reflect.MakeMap(reflect.MapOf(value.Type().Key(), value.Type().Elem())) - for _, v := range node.Nodes { - if child, ok := v.(*Node); ok { - k := reflect.New(value.Type().Key()) - if err = setBasicValue(k.Elem(), nil, &child.Name); err != nil { - return - } - v := reflect.New(value.Type().Elem()) - if err = setValue(v.Elem(), nil, child); err != nil { - return - } - m.SetMapIndex(k.Elem(), v.Elem()) - } - } - value.Set(m) - return -} - -func setSliceValue(value reflect.Value, node *Node) (err error) { - tmpValues := make([][]byte, 0) - for _, v := range node.Nodes { - if val, ok := v.(*Value); ok { - tmpValues = append(tmpValues, val.Value) - } - } - size := len(tmpValues) - values := reflect.MakeSlice(reflect.SliceOf(value.Type().Elem()), 0, size) - - if len(tmpValues) > 0 { - for _, data := range tmpValues { - v := reflect.New(value.Type().Elem()) - str := string(data) - if err = setBasicValue(v.Elem(), nil, &str); err != nil { - return - } - values = reflect.Append(values, v.Elem()) - } - } else { - for _, n := range node.Nodes { - if child, ok := n.(*Node); ok { - v := reflect.New(value.Type().Elem()) - if err = setValue(v.Elem(), nil, child); err != nil { - return - } - values = reflect.Append(values, v.Elem()) - } - } - } - value.Set(values) - return -} - -func setValue(value reflect.Value, meta *Meta, node *Node) (err error) { - var str *string - if node != nil { - node.used = true - } - switch value.Type().Kind() { - case reflect.Int, reflect.Int8, reflect.Int16, reflect.Int32, reflect.Int64, - reflect.Uint, reflect.Uint8, reflect.Uint16, reflect.Uint32, reflect.Uint64, - reflect.Float32, reflect.Float64, reflect.Bool, reflect.String: - if str, err = node.getValue(meta); err == nil { - if err = setBasicValue(value, meta, str); err != nil { - return node.newError("%s", err.Error()) - } - } - case reflect.Struct: - if node != nil { - return setStructValue(value, node) - } - case reflect.Map: - if node != nil { - return setMapValue(value, node) - } - case reflect.Slice: - if node != nil { - return setSliceValue(value, node) - } - case reflect.Ptr: - v := reflect.New(value.Type().Elem()) - value.Set(v) - return setValue(v.Elem(), meta, node) - case reflect.Interface: - value.Set(reflect.ValueOf(node)) - node.markUsed(true) - } - - return nil -} - -// assignValues assigns parsed nodes to the specified structure -func assignValues(v interface{}, root *Node) (err error) { - rv := reflect.ValueOf(v) - - switch rv.Type().Kind() { - case reflect.Ptr: - rv = rv.Elem() - default: - return errors.New("output variable must be a pointer to a structure") - } - - switch rv.Type().Kind() { - case reflect.Struct: - if err = setStructValue(rv, root); err != nil { - return err - } - default: - return errors.New("output variable must be a pointer to a structure") - } - return root.checkUsage() -} - -func newIncludeError(root *Node, filename *string, errmsg string) (err error) { - if root.includeFail { - return errors.New(errmsg) - } - root.includeFail = true - if filename != nil { - return fmt.Errorf(`cannot include "%s": %s`, *filename, errmsg) - } - return fmt.Errorf(`cannot load file: %s`, errmsg) -} - -func hasMeta(path string) bool { - var metaChars string - if runtime.GOOS != "windows" { - metaChars = `*?[\` - } else { - metaChars = `*?[` - } - return strings.ContainsAny(path, metaChars) -} - -func loadInclude(root *Node, path string) (err error) { - path = filepath.Clean(path) - if err := checkGlobPattern(path); err != nil { - return newIncludeError(root, &path, err.Error()) - } - - absPath, err := filepath.Abs(path) - if err != nil { - return newIncludeError(root, &path, err.Error()) - } - - // If a path is relative, pad it with a directory of the current config file - if path != absPath { - confDir := filepath.Dir(GetCurrentConfigPath()) - path = filepath.Join(confDir, path) - } - - if hasMeta(filepath.Dir(path)) { - return newIncludeError(root, &path, "glob pattern is supported only in file names") - } - if !hasMeta(path) { - var fi os.FileInfo - if fi, err = stdOs.Stat(path); err != nil { - return newIncludeError(root, &path, err.Error()) - } - if fi.IsDir() { - path = filepath.Join(path, "*") - } - } else { - var fi os.FileInfo - if fi, err = stdOs.Stat(filepath.Dir(path)); err != nil { - return newIncludeError(root, &path, err.Error()) - } - if !fi.IsDir() { - return newIncludeError(root, &path, "base path is not a directory") - } - } - - var paths []string - if hasMeta(path) { - if paths, err = filepath.Glob(path); err != nil { - return newIncludeError(root, nil, err.Error()) - } - } else { - paths = append(paths, path) - } - - for _, path := range paths { - // skip directories - var fi os.FileInfo - if fi, err = stdOs.Stat(path); err != nil { - return newIncludeError(root, &path, err.Error()) - } - if fi.IsDir() { - continue - } - - var file std.File - if file, err = stdOs.Open(path); err != nil { - return newIncludeError(root, &path, err.Error()) - } - defer file.Close() - - buf := bytes.Buffer{} - if _, err = buf.ReadFrom(file); err != nil { - return newIncludeError(root, &path, err.Error()) - } - - if err = parseConfig(root, buf.Bytes()); err != nil { - return newIncludeError(root, &path, err.Error()) - } - } - return -} - -func checkGlobPattern(path string) error { - if strings.HasPrefix(path, "*") { - return errors.New("path should be absolute") - } - - var isGlob, hasSepLeft, hasSepRight bool - - for _, p := range path { - switch p { - case '*': - isGlob = true - case filepath.Separator: - switch isGlob { - case true: - hasSepRight = true - case false: - hasSepLeft = true - } - } - } - - if (isGlob && !hasSepLeft && hasSepRight) || (isGlob && !hasSepLeft && !hasSepRight) { - return errors.New("path should be absolute") - } - - return nil -} - -func parseConfig(root *Node, data []byte) (err error) { - const maxStringLen = 2048 - var line []byte - - root.level++ - - for offset, end, num := 0, 0, 1; end != -1; offset, num = offset+end+1, num+1 { - if end = bytes.IndexByte(data[offset:], '\n'); end != -1 { - line = bytes.TrimSpace(data[offset : offset+end]) - } else { - line = bytes.TrimSpace(data[offset:]) - } - - if len(line) > maxStringLen { - return fmt.Errorf("cannot parse configuration at line %d: limit of %d bytes is exceeded", num, maxStringLen) - } - - if len(line) == 0 || line[0] == '#' { - continue - } - - if !utf8.ValidString(string(line)) { - return fmt.Errorf("cannot parse configuration at line %d: not a valid UTF-8 character found", num) - } - - var key, value []byte - if key, value, err = parseLine(line); err != nil { - return fmt.Errorf("cannot parse configuration at line %d: %s", num, err.Error()) - } - - if string(key) == "Include" { - if root.level == 10 { - return fmt.Errorf("include depth exceeded limits") - } - if err = loadInclude(root, string(value)); err != nil { - return - } - } else { - root.add(key, value, num) - } - } - root.level-- - return nil -} - -func addObject(parent *Node, v interface{}) error { - if attr, ok := v.(map[string]interface{}); ok { - if _, ok := attr["Nodes"]; ok { - node := &Node{} - if err := setObjectNode(node, attr); err != nil { - return err - } - parent.Nodes = append(parent.Nodes, node) - } else { - value := &Value{} - if err := setObjectValue(value, attr); err != nil { - return err - } - parent.Nodes = append(parent.Nodes, value) - } - } else { - return fmt.Errorf("invalid object type %T", v) - } - return nil -} - -func setObjectValue(value *Value, attr map[string]interface{}) error { - var line float64 - var ok bool - if line, ok = attr["Line"].(float64); !ok { - return fmt.Errorf("invalid line attribute type %T", attr["Line"]) - } - value.Line = int(line) - - var err error - var data string - if data, ok = attr["Value"].(string); !ok { - return fmt.Errorf("invalid value type %T", attr["Value"]) - } - - if value.Value, err = base64.StdEncoding.DecodeString(data); err != nil { - return err - } - - return nil -} - -func setObjectNode(node *Node, attr map[string]interface{}) error { - var line float64 - var ok bool - - if line, ok = attr["Line"].(float64); !ok { - return fmt.Errorf("invalid line attribute type %T", attr["Line"]) - } - node.Line = int(line) - - if node.Name, ok = attr["Name"].(string); !ok { - return fmt.Errorf("invalid node name type %T", attr["Name"]) - } - - var nodes []interface{} - if nodes, ok = attr["Nodes"].([]interface{}); !ok { - return fmt.Errorf("invalid node children type %T", attr["u"]) - } - - for _, a := range nodes { - if err := addObject(node, a); err != nil { - return err - } - } - - return nil -} - -// Unmarshal unmarshals input data into specified structure. The input data can be either -// a byte array ([]byte) with configuration file or interface{} either returned by Marshal -// or a configuration file Unmarshaled into interface{} variable before. -// The third is optional 'strict' parameter that forces strict validation of configuration -// and structure fields (enabled by default). When disabled it will unmarshal part of -// configuration into incomplete target structures. -func Unmarshal(data interface{}, v interface{}, args ...interface{}) (err error) { - rv := reflect.ValueOf(v) - if rv.Kind() != reflect.Ptr || rv.IsNil() { - return errors.New("Invalid output parameter") - } - - strict := true - if len(args) > 0 { - var ok bool - if strict, ok = args[0].(bool); !ok { - return errors.New("Invalid mode parameter") - } - } - - var root *Node - switch u := data.(type) { - case nil: - root = &Node{ - Name: "", - used: false, - Nodes: make([]interface{}, 0), - parent: nil, - Line: 0} - case []byte: - root = &Node{ - Name: "", - used: false, - Nodes: make([]interface{}, 0), - parent: nil, - Line: 0} - - if err = parseConfig(root, u); err != nil { - return fmt.Errorf("Cannot read configuration: %s", err.Error()) - } - case *Node: - root = u - root.markUsed(false) - case map[string]interface{}: // JSON unmarshaling result - root = &Node{} - if err = setObjectNode(root, u); err != nil { - return fmt.Errorf("Cannot unmarshal JSON data: %s", err) - } - default: - return fmt.Errorf("Invalid input parameter of type %T", u) - } - - if !strict { - root.markUsed(true) - } - - if err = assignValues(v, root); err != nil { - return fmt.Errorf("Cannot assign configuration: %s", err.Error()) - } - - return nil -} - -func Load(filename string, v interface{}) (err error) { - var file std.File - - if file, err = stdOs.Open(filename); err != nil { - return fmt.Errorf(`cannot open configuration file: %s`, err.Error()) - } - defer file.Close() - - buf := bytes.Buffer{} - if _, err = buf.ReadFrom(file); err != nil { - return fmt.Errorf("cannot load configuration: %s", err.Error()) - } - - setCurrentConfigPath(filename) - - return Unmarshal(buf.Bytes(), v) -} - -func LoadUserParams(v interface{}) (err error) { - var file std.File - - if file, err = stdOs.Open(currentConfigPath); err != nil { - return fmt.Errorf(`cannot open configuration file: %s`, err.Error()) - } - defer file.Close() - - buf := bytes.Buffer{} - if _, err = buf.ReadFrom(file); err != nil { - return fmt.Errorf("cannot load configuration: %s", err.Error()) - } - - return Unmarshal(buf.Bytes(), v, false) -} - -var stdOs std.Os - -func init() { - stdOs = std.NewOs() -} diff --git a/src/go/pkg/conf/conf_test.go b/src/go/pkg/conf/conf_test.go deleted file mode 100644 index aaf19e94c4b..00000000000 --- a/src/go/pkg/conf/conf_test.go +++ /dev/null @@ -1,597 +0,0 @@ -//go:build linux && amd64 -// +build linux,amd64 - -/* -** Zabbix -** Copyright (C) 2001-2022 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - -package conf - -import ( - "encoding/json" - "fmt" - "reflect" - "sort" - "strings" - "testing" - - "zabbix.com/pkg/std" -) - -func TestParserErrors(t *testing.T) { - type Options struct { - Test string `conf:"name=Te$t,optional"` - Range string `conf:"optional,range="` - } - - var input = []string{ - "abc", - "abc =", - " = abc", - "Test = value", - "Te$t = value", - "Range=1", - } - - for _, data := range input { - var options Options - if err := Unmarshal([]byte(data), &options); err != nil { - t.Logf("Returned error: %s", err.Error()) - } else { - t.Errorf("Successfully parsed conf: %s", data) - } - } -} - -func TestParserSuccess(t *testing.T) { - type Options struct { - Text string `conf:"optional"` - } - - var input = []string{ - "Text=1", - " Text = 2 ", - "Text = 3\nText=4", - "# comments\nText=5", - " # comments\nText=6", - " \nText=7", - "Text=8=9", - "Text=", - "Text=9\n#", - "Text=10\n", - "\n Text = 11 \n", - "\n#####Text=x\nText=12", - } - - var output = []Options{ - {Text: "1"}, - {Text: "2"}, - {Text: "4"}, - {Text: "5"}, - {Text: "6"}, - {Text: "7"}, - {Text: "8=9"}, - {Text: ""}, - {Text: "9"}, - {Text: "10"}, - {Text: "11"}, - {Text: "12"}, - } - - for i, data := range input { - var options Options - if err := Unmarshal([]byte(data), &options); err != nil { - t.Logf("[%d] returned error: %s", i, err.Error()) - t.Fail() - } - if options.Text != output[i].Text { - t.Errorf("[%d] expected %s while got %s\n", i, output[i].Text, options.Text) - } - } -} - -func TestUtf8(t *testing.T) { - type Options struct { - Text string `conf:"optional"` - } - - var input = []string{ - "Text=\xFE", - "Text\xFE=2", - } - - for i, data := range input { - var options Options - if err := Unmarshal([]byte(data), &options); err == nil { - t.Errorf("[%d] expected error while got success\n", i) - } - } -} - -func TestParserRangeErrors(t *testing.T) { - type Options struct { - Value int `conf:"range=-10:10"` - } - - var input = []string{ - `Value=-11`, - `Value=-10.5`, - `Value=10.5`, - `Value=11`, - } - - for i, data := range input { - var options Options - if err := Unmarshal([]byte(data), &options); err != nil { - t.Logf("Returned error: %s", err.Error()) - } else { - t.Errorf("[%d] expected error while got success", i) - } - } -} - -func TestParserExistanceErrors(t *testing.T) { - type Options struct { - Text string - Value int - } - - var input = []string{ - `Value=1`, - `Value=1 - Text=1 - None=1`, - } - - for i, data := range input { - var options Options - if err := Unmarshal([]byte(data), &options); err != nil { - t.Logf("Returned error: %s", err.Error()) - } else { - t.Errorf("[%d] expected error while got %+v", i, options) - } - } -} - -func checkUnmarshal(t *testing.T, data []byte, expected interface{}, options interface{}) { - if err := Unmarshal([]byte(data), options); err != nil { - t.Errorf("Expected success while got error: %s", err.Error()) - } - if !reflect.DeepEqual(options, expected) { - t.Errorf("Expected %+v while got %+v", expected, options) - } -} - -func TestNestedPointer(t *testing.T) { - type Options struct { - Pointer ***int - } - input := `Pointer = 42` - - value := 42 - pvalue := &value - ppvalue := &pvalue - var options Options - var expected Options = Options{&ppvalue} - checkUnmarshal(t, []byte(input), &expected, &options) -} - -func TestArray(t *testing.T) { - type Options struct { - Values []int `conf:"name=Value"` - } - input := ` - Value = 1 - Value = 2 - Value = 3` - - var options Options - var expected Options = Options{[]int{1, 2, 3}} - checkUnmarshal(t, []byte(input), &expected, &options) -} - -func TestNestedArray(t *testing.T) { - type Options struct { - Values [][]int `conf:"name=Value"` - } - input := ` - Value.1 = 1 - Value.1 = 2 - Value.2 = 3 - Value.2 = 4 - Value.3 = 5 - Value.3 = 6` - - var options Options - var expected Options = Options{[][]int{[]int{1, 2}, []int{3, 4}, []int{5, 6}}} - checkUnmarshal(t, []byte(input), &expected, &options) -} - -func TestOptional(t *testing.T) { - type Options struct { - Text *string `conf:"optional"` - } - input := `` - - var options Options - var expected Options = Options{nil} - checkUnmarshal(t, []byte(input), &expected, &options) -} - -func TestDefault(t *testing.T) { - type Options struct { - Text string `conf:"default=Default, \"value\""` - } - input := `` - - var options Options - var expected Options = Options{`Default, "value"`} - checkUnmarshal(t, []byte(input), &expected, &options) -} - -func TestMap(t *testing.T) { - type Options struct { - Index map[string]uint64 - } - input := ` - Index.apple = 9 - Index.orange = 7 - Index.banana = 3 - ` - - var options Options - var expected Options = Options{map[string]uint64{"apple": 9, "orange": 7, "banana": 3}} - checkUnmarshal(t, []byte(input), &expected, &options) -} - -func TestStructMap(t *testing.T) { - type Object struct { - Id uint64 - Description string - } - type Options struct { - Index map[string]Object - } - input := ` - Index.apple.Id = 9 - Index.apple.Description = An apple - Index.orange.Id = 7 - Index.orange.Description = An orange - Index.banana.Id = 3 - Index.banana.Description = A banana - ` - - var options Options - var expected Options = Options{map[string]Object{ - "apple": Object{9, "An apple"}, - "orange": Object{7, "An orange"}, - "banana": Object{3, "A banana"}}} - checkUnmarshal(t, []byte(input), &expected, &options) -} - -func TestStructPtrMap(t *testing.T) { - type Object struct { - Id uint64 - Description string - } - type Options struct { - Index map[string]*Object - } - input := ` - Index.apple.Id = 9 - Index.apple.Description = An apple - Index.orange.Id = 7 - Index.orange.Description = An orange - Index.banana.Id = 3 - Index.banana.Description = A banana - ` - - objects := []Object{Object{9, "An apple"}, Object{7, "An orange"}, Object{3, "A banana"}} - var options Options - var expected Options = Options{map[string]*Object{ - "apple": &objects[0], - "orange": &objects[1], - "banana": &objects[2]}} - checkUnmarshal(t, []byte(input), &expected, &options) -} - -func TestNestedStruct(t *testing.T) { - type Object struct { - Id uint64 - Name string - } - type Options struct { - Chair Object - Desk Object - } - input := ` - Chair.Id = 1 - Chair.Name = a chair - Desk.Id = 2 - Desk.Name = a desk - ` - - var options Options - var expected Options = Options{Object{1, "a chair"}, Object{2, "a desk"}} - checkUnmarshal(t, []byte(input), &expected, &options) -} - -func TestInclude(t *testing.T) { - stdOs = std.NewMockOs() - stdOs.(std.MockOs).MockFile("/tmp/array10.conf", []byte("Value=10\nValue=20")) - stdOs.(std.MockOs).MockFile("/tmp/array100.conf", []byte("Value=100\nValue=200")) - - type Options struct { - Values []int `conf:"name=Value"` - } - input := ` - Value = 1 - Include = /tmp/array10.conf - Value = 2 - Include = /tmp/array100.conf - Value = 3 - ` - - var options Options - var expected Options = Options{[]int{1, 10, 20, 2, 100, 200, 3}} - checkUnmarshal(t, []byte(input), &expected, &options) -} - -func TestRecursiveInclude(t *testing.T) { - stdOs = std.NewMockOs() - stdOs.(std.MockOs).MockFile("/tmp/array10.conf", []byte("Value=10\nValue=20\nInclude = /tmp/array10.conf")) - - type Options struct { - Values []int `conf:"name=Value"` - } - input := ` - Value = 1 - Include = /tmp/array10.conf - Value = 2 - ` - - var options Options - if err := Unmarshal([]byte(input), &options); err != nil { - if !strings.Contains(err.Error(), "include depth exceeded limits") { - t.Errorf("Expected recursion error message while got: %s", err.Error()) - } - } else { - t.Errorf("Expected error while got success") - } -} - -func TestEmptyOptional(t *testing.T) { - type Options struct { - Text *string `conf:"optional"` - } - - var options Options - var expected Options = Options{nil} - checkUnmarshal(t, nil, &expected, &options) -} - -func TestEmptyMandatory(t *testing.T) { - type Options struct { - Text *string - } - var options Options - - if err := Unmarshal(nil, &options); err == nil { - t.Errorf("Expected error while got success") - } -} - -func TestInterface(t *testing.T) { - type Options struct { - LogFile string - LogLevel int - Timeout int - Plugins map[string]interface{} - } - - type RedisSession struct { - Address string - Port int `conf:"default=10001"` - } - type RedisOptions struct { - Enable int - Sessions map[string]RedisSession - } - - input := ` - LogFile = /tmp/log - LogLevel = 3 - Timeout = 10 - Plugins.Log.MaxLinesPerSecond = 25 - Plugins.Redis.Enable = 1 - Plugins.Redis.Sessions.Server1.Address = 127.0.0.1 - Plugins.Redis.Sessions.Server2.Address = 127.0.0.2 - Plugins.Redis.Sessions.Server2.Port = 10002 - Plugins.Redis.Sessions.Server3.Address = 127.0.0.3 - Plugins.Redis.Sessions.Server3.Port = 10003 - ` - - var o Options - if err := Unmarshal([]byte(input), &o); err != nil { - t.Errorf("Failed unmarshaling options: %s", err) - } - - var returnedOpts RedisOptions - _ = Unmarshal(o.Plugins["Redis"], &returnedOpts) - - expectedOpts := RedisOptions{ - Enable: 1, - Sessions: map[string]RedisSession{ - "Server1": RedisSession{"127.0.0.1", 10001}, - "Server2": RedisSession{"127.0.0.2", 10002}, - "Server3": RedisSession{"127.0.0.3", 10003}, - }, - } - - if !reflect.DeepEqual(expectedOpts, returnedOpts) { - t.Errorf("Expected %+v while got %+v", expectedOpts, returnedOpts) - } -} - -func TestRawAccess(t *testing.T) { - type Options struct { - LogFile string - LogLevel int - Timeout int - AllowKey interface{} `conf:"optional"` - DenyKey interface{} `conf:"optional"` - } - - input := ` - LogFile = /tmp/log - LogLevel = 3 - Timeout = 10 - AllowKey=system.localtime - DenyKey=* - AllowKey=vfs.*[*] - ` - var o Options - if err := Unmarshal([]byte(input), &o); err != nil { - t.Errorf("Failed unmarshaling options: %s", err) - } - - values := make([]*Value, 0) - if node, ok := o.AllowKey.(*Node); ok { - for _, v := range node.Nodes { - if value, ok := v.(*Value); ok { - value.Value = []byte(fmt.Sprintf("%s: %s", node.Name, string(value.Value))) - values = append(values, value) - } - } - } - if node, ok := o.DenyKey.(*Node); ok { - for _, v := range node.Nodes { - if value, ok := v.(*Value); ok { - value.Value = []byte(fmt.Sprintf("%s: %s", node.Name, string(value.Value))) - values = append(values, value) - } - } - } - - sort.SliceStable(values, func(i, j int) bool { - return values[i].Line < values[j].Line - }) - - var returnedOpts []string - - for _, value := range values { - returnedOpts = append(returnedOpts, string(value.Value)) - } - - expectedOpts := []string{ - "AllowKey: system.localtime", - "DenyKey: *", - "AllowKey: vfs.*[*]", - } - - if !reflect.DeepEqual(expectedOpts, returnedOpts) { - t.Errorf("Expected '%+v' while got '%+v'", expectedOpts, returnedOpts) - } -} - -func Test_checkGlobPattern(t *testing.T) { - type args struct { - path string - } - tests := []struct { - name string - args args - wantErr bool - }{ - {"+no_glob", args{"/foo/bar"}, false}, - {"+glob", args{"/foo/bar/*.conf"}, false}, - {"+glob_only", args{"/foo/bar/*"}, false}, - {"+glob_in_name", args{"/foo/bar/foo*bar.conf"}, false}, - {"+relative_name_with_glob", args{"./foo*bar"}, false}, - {"+empty", args{""}, false}, - {"-name_only_with_glob", args{"foo*bar"}, true}, - {"-name_start_glob", args{"*bar"}, true}, - {"-invalid_prefix", args{"*/foo/bar"}, true}, - {"-invalid_string", args{"*"}, true}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if err := checkGlobPattern(tt.args.path); (err != nil) != tt.wantErr { - t.Errorf("checkGlobPattern() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -func Test_jsonMarshaling(t *testing.T) { - type Options struct { - LogFile string - LogLevel int - Timeout int - Plugins map[string]interface{} - } - - type RedisSession struct { - Address string - Port int `conf:"default=10001"` - } - type RedisOptions struct { - Enable int - Sessions map[string]RedisSession - } - - input := ` - LogFile = /tmp/log - LogLevel = 3 - Timeout = 10 - Plugins.Log.MaxLinesPerSecond = 25 - Plugins.Redis.Enable = 1 - Plugins.Redis.Sessions.Server1.Address = 127.0.0.1 - Plugins.Redis.Sessions.Server2.Address = 127.0.0.2 - Plugins.Redis.Sessions.Server2.Port = 10002 - Plugins.Redis.Sessions.Server3.Address = 127.0.0.3 - Plugins.Redis.Sessions.Server3.Port = 10003 - ` - - var o Options - if err := Unmarshal([]byte(input), &o); err != nil { - t.Errorf("Failed unmarshaling options: %s", err) - } - - dataOut, _ := json.Marshal(o.Plugins["Redis"]) - var dataIn map[string]interface{} - _ = json.Unmarshal(dataOut, &dataIn) - - var returnedOpts RedisOptions - if err := Unmarshal(dataIn, &returnedOpts); err != nil { - t.Error(err) - } - - expectedOpts := RedisOptions{ - Enable: 1, - Sessions: map[string]RedisSession{ - "Server1": {"127.0.0.1", 10001}, - "Server2": {"127.0.0.2", 10002}, - "Server3": {"127.0.0.3", 10003}, - }, - } - - if !reflect.DeepEqual(expectedOpts, returnedOpts) { - t.Errorf("Expected %+v while got %+v", expectedOpts, returnedOpts) - } -} diff --git a/src/go/pkg/conf/node.go b/src/go/pkg/conf/node.go deleted file mode 100644 index 29bd18a61d9..00000000000 --- a/src/go/pkg/conf/node.go +++ /dev/null @@ -1,152 +0,0 @@ -/* -** Zabbix -** Copyright (C) 2001-2022 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - -// Package conf provides .conf file loading and unmarshalling -package conf - -import ( - "bytes" - "fmt" -) - -// Node structure is used to store parsed conf file parameters or parameter components. -type Node struct { - Name string - Nodes []interface{} - Line int - - used bool - parent *Node - level int - includeFail bool -} - -type Value struct { - Value []byte - Line int -} - -// get returns child node by name -func (n *Node) get(name string) (node *Node) { - for _, v := range n.Nodes { - if child, ok := v.(*Node); ok && child.Name == name { - return child - } - } - return nil -} - -// add appends new child node -func (n *Node) add(name []byte, value []byte, lineNum int) { - var node *Node - var key string - - split := bytes.IndexByte(name, '.') - if split == -1 { - key = string(name) - } else { - key = string(name[:split]) - } - - if node = n.get(key); node == nil { - node = &Node{ - Name: string(key), - used: false, - Nodes: make([]interface{}, 0), - parent: n, - Line: lineNum} - n.Nodes = append(n.Nodes, node) - } - - if split != -1 { - node.add(name[split+1:], value, lineNum) - } else { - node.Nodes = append(node.Nodes, &Value{Value: value, Line: lineNum}) - } -} - -// checkUsage checks if all conf nodes were recognized. -// This is done by recursively checking 'used' flag for all nodes. -func (n *Node) checkUsage() (err error) { - for _, v := range n.Nodes { - if child, ok := v.(*Node); ok { - if !child.used { - return child.newError("unknown parameter") - } - if err = child.checkUsage(); err != nil { - return - } - } - } - return -} - -// markUsed marks node and its children as used -func (n *Node) markUsed(used bool) { - n.used = used - for _, v := range n.Nodes { - if child, ok := v.(*Node); ok { - child.markUsed(used) - } - } -} - -// getValue returns node value or meta data default value or nil if -// metadata 'optional' tag is set. Otherwise error is returned. -func (n *Node) getValue(meta *Meta) (value *string, err error) { - if n != nil { - var tmp string - for _, v := range n.Nodes { - if val, ok := v.(*Value); ok { - tmp = string(val.Value) - } - value = &tmp - } - } - - if value == nil && meta != nil { - if meta.defaultValue != nil { - value = meta.defaultValue - } else if meta.optional { - return - } else { - return nil, fmt.Errorf("cannot find mandatory parameter %s", meta.name) - } - } - return -} - -// newNodeError creates error based on the specified node. The error message will -// have full node name (parameter name up to the node, including it) and the line -// number where parameter was defined. -func (n *Node) newError(format string, a ...interface{}) (err error) { - if n == nil { - return fmt.Errorf(format, a...) - } - var name string - for parent := n; parent.parent != nil; parent = parent.parent { - if name == "" { - name = parent.Name - } else { - name = parent.Name + "." + name - } - } - desc := fmt.Sprintf(format, a...) - return fmt.Errorf("invalid parameter %s at line %d: %s", name, n.Line, desc) -} diff --git a/src/go/pkg/conf/session.go b/src/go/pkg/conf/session.go deleted file mode 100644 index e4fe53ea6de..00000000000 --- a/src/go/pkg/conf/session.go +++ /dev/null @@ -1,28 +0,0 @@ -/* -** Zabbix -** Copyright (C) 2001-2022 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - -// Package conf provides .conf file loading and unmarshalling -package conf - -// Session is a general structure for storing sessions' configuration. -type Session struct { - URI string `conf:"name=Uri,optional"` - Password string `conf:"optional"` - User string `conf:"optional"` -} diff --git a/src/go/pkg/itemutil/value.go b/src/go/pkg/itemutil/value.go index 57e3b289cbf..bf3653cf7d6 100644 --- a/src/go/pkg/itemutil/value.go +++ b/src/go/pkg/itemutil/value.go @@ -24,7 +24,7 @@ import ( "strconv" "time" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) const StateNotSupported = 1 diff --git a/src/go/pkg/log/log.go b/src/go/pkg/log/log.go deleted file mode 100644 index 39250fae1d6..00000000000 --- a/src/go/pkg/log/log.go +++ /dev/null @@ -1,270 +0,0 @@ -/* -** Zabbix -** Copyright (C) 2001-2022 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - -package log - -import ( - "bytes" - "errors" - "fmt" - "log" - "os" - "path/filepath" - "runtime" - "runtime/debug" - "sync" -) - -const Info = 0 -const Crit = 1 -const Err = 2 -const Warning = 3 -const Debug = 4 -const Trace = 5 - -const None = -1 - -const Undefined = 0 -const System = 1 -const File = 2 -const Console = 3 - -const MB = 1048576 - -//DefaultLogger is the default Zabbix agent 2 and Zabbix web service logger. -var DefaultLogger *log.Logger - -var logLevel int - -type LogStat struct { - logType int - filename string - filesize int64 - f *os.File - currentSize int64 -} - -var logStat LogStat -var logAccess sync.Mutex - -func CheckLogLevel(level int) bool { - if level > logLevel { - return false - } - return true -} - -func Level() string { - switch logLevel { - case None: - return "none" - case Info: - return "info" - case Crit: - return "critical" - case Err: - return "error" - case Warning: - return "warning" - case Debug: - return "debug" - case Trace: - return "trace" - default: - return "unknown" - } -} - -func IncreaseLogLevel() (success bool) { - if logLevel != Trace { - logLevel++ - return true - } - return false -} - -func DecreaseLogLevel() (success bool) { - if logLevel != Info { - logLevel-- - return true - } - return false -} - -// Open sets a new logger based on the log type and a new log output level -func Open(logType int, level int, filename string, filesize int) error { - logStat.logType = logType - logStat.filename = filename - logStat.filesize = int64(filesize) * MB - var err error - - switch logType { - case System: - err = createSyslog() - if err != nil { - return err - } - case Console: - DefaultLogger = log.New(os.Stdout, "", log.Lmicroseconds|log.Ldate) - case File: - logStat.f, err = os.OpenFile(filename, os.O_APPEND|os.O_CREATE|os.O_WRONLY, 0644) - if err != nil { - return err - } - DefaultLogger = log.New(logStat.f, "", log.Lmicroseconds|log.Ldate) - default: - return errors.New("invalid argument") - } - - logLevel = level - return nil -} - -func Infof(format string, args ...interface{}) { - if CheckLogLevel(Info) { - procLog(format, args, Info) - } -} - -func Critf(format string, args ...interface{}) { - if CheckLogLevel(Crit) { - procLog(format, args, Crit) - } -} - -func Errf(format string, args ...interface{}) { - if CheckLogLevel(Err) { - procLog(format, args, Err) - } -} - -func Warningf(format string, args ...interface{}) { - if CheckLogLevel(Warning) { - procLog(format, args, Warning) - } -} - -func Tracef(format string, args ...interface{}) { - if CheckLogLevel(Trace) { - procLog(format, args, Trace) - } -} - -func Debugf(format string, args ...interface{}) { - if CheckLogLevel(Debug) { - procLog(format, args, Debug) - } -} - -func procLog(format string, args []interface{}, level int) { - if logStat.logType == System { - procSysLog(format, args, level) - return - } - - logAccess.Lock() - defer logAccess.Unlock() - rotateLog() - DefaultLogger.Printf(format, args...) -} - -func rotateLog() { - if logStat.logType == File { - fstat, err := os.Stat(logStat.filename) - if err != nil || fstat.Size() == 0 || logStat.currentSize > fstat.Size() { - - logStat.f.Close() - - if logStat.f, err = os.OpenFile(logStat.filename, os.O_CREATE|os.O_WRONLY, 0644); err != nil { - logStat.logType = Undefined - log.Fatal(fmt.Sprintf("Cannot open log file %s", logStat.filename)) - } - - DefaultLogger = log.New(logStat.f, "", log.Lmicroseconds|log.Ldate) - logStat.currentSize = 0 - return - } - - if logStat.filesize != 0 { - var printError string - - logStat.currentSize = fstat.Size() - - if logStat.currentSize > logStat.filesize { - filenameOld := logStat.filename + ".old" - logStat.f.Close() - os.Remove(filenameOld) - - err = os.Rename(logStat.filename, filenameOld) - if err != nil { - printError = err.Error() - } - - logStat.f, err = os.OpenFile(logStat.filename, os.O_CREATE|os.O_WRONLY, 0644) - if err != nil { - errmsg := fmt.Sprintf("Cannot open log file %s", logStat.filename) - if printError != "" { - errmsg = fmt.Sprintf("%s and cannot rename it: %s", errmsg, printError) - } - logStat.logType = Undefined - log.Fatal(errmsg) - } - - DefaultLogger = log.New(logStat.f, "", log.Lmicroseconds|log.Ldate) - if printError != "" { - DefaultLogger.Printf("cannot rename log file \"%s\" to \"%s\":%s\n", - logStat.filename, filenameOld, printError) - DefaultLogger.Printf("Logfile \"%s\" size reached configured limit LogFileSize but"+ - " moving it to \"%s\" failed. The logfile was truncated.", - logStat.filename, filenameOld) - } - } - } - } -} - -func PanicHook() { - if r := recover(); r != nil { - if logStat.logType != Undefined { - data := debug.Stack() - Critf("Critical failure: %v", r) - var tail int - for offset, end, num := 0, 0, 1; end != -1; offset, num = offset+end+1, num+1 { - end = bytes.IndexByte(data[offset:], '\n') - if end != -1 { - tail = offset + end - } else { - tail = len(data) - } - Critf("%s", string(data[offset:tail])) - } - } - panic(r) - } -} - -func Caller() (name string) { - pc := make([]uintptr, 2) - n := runtime.Callers(2, pc) - frames := runtime.CallersFrames(pc[:n]) - if frame, ok := frames.Next(); ok { - return filepath.Base(frame.Func.Name()) - } - return "" -} diff --git a/src/go/pkg/log/log_nix.go b/src/go/pkg/log/log_nix.go deleted file mode 100644 index 80aa5b0ba03..00000000000 --- a/src/go/pkg/log/log_nix.go +++ /dev/null @@ -1,51 +0,0 @@ -//go:build !windows -// +build !windows - -/* -** Zabbix -** Copyright (C) 2001-2022 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - -package log - -import ( - "fmt" - "log/syslog" -) - -var syslogWriter *syslog.Writer - -func createSyslog() (err error) { - syslogWriter, err = syslog.New(syslog.LOG_WARNING|syslog.LOG_DAEMON, "zabbix_agent2") - return -} - -func procSysLog(format string, args []interface{}, level int) { - switch level { - case Info: - syslogWriter.Info(fmt.Sprintf(format, args...)) - case Crit: - syslogWriter.Crit(fmt.Sprintf(format, args...)) - case Err: - syslogWriter.Err(fmt.Sprintf(format, args...)) - case Warning: - syslogWriter.Warning(fmt.Sprintf(format, args...)) - case Debug, Trace: - syslogWriter.Debug(fmt.Sprintf(format, args...)) - } - return -} diff --git a/src/go/pkg/log/log_windows.go b/src/go/pkg/log/log_windows.go deleted file mode 100644 index 8512ebb6377..00000000000 --- a/src/go/pkg/log/log_windows.go +++ /dev/null @@ -1,32 +0,0 @@ -/* -** Zabbix -** Copyright (C) 2001-2022 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - -package log - -import ( - "errors" -) - -func createSyslog() error { - return errors.New("system log is not supported on Windows") -} - -func procSysLog(format string, args []interface{}, level int) { - return -} diff --git a/src/go/pkg/log/logger.go b/src/go/pkg/log/logger.go deleted file mode 100644 index 778c696a0eb..00000000000 --- a/src/go/pkg/log/logger.go +++ /dev/null @@ -1,48 +0,0 @@ -package log - -import "fmt" - -type Logger interface { - Tracef(format string, args ...interface{}) - Debugf(format string, args ...interface{}) - Warningf(format string, args ...interface{}) - Infof(format string, args ...interface{}) - Errf(format string, args ...interface{}) - Critf(format string, args ...interface{}) -} - -type loggerImpl struct { - prefix string -} - -func New(module string) Logger { - var prefix string - if module != "" { - prefix = fmt.Sprintf("[%s] ", module) - } - return &loggerImpl{prefix: prefix} -} - -func (l *loggerImpl) Critf(format string, args ...interface{}) { - Critf(l.prefix+format, args...) -} - -func (l *loggerImpl) Infof(format string, args ...interface{}) { - Infof(l.prefix+format, args...) -} - -func (l *loggerImpl) Warningf(format string, args ...interface{}) { - Warningf(l.prefix+format, args...) -} - -func (l *loggerImpl) Tracef(format string, args ...interface{}) { - Tracef(l.prefix+format, args...) -} - -func (l *loggerImpl) Debugf(format string, args ...interface{}) { - Debugf(l.prefix+format, args...) -} - -func (l *loggerImpl) Errf(format string, args ...interface{}) { - Errf(l.prefix+format, args...) -} diff --git a/src/go/pkg/metric/metric.go b/src/go/pkg/metric/metric.go deleted file mode 100644 index 68deafbc140..00000000000 --- a/src/go/pkg/metric/metric.go +++ /dev/null @@ -1,445 +0,0 @@ -/* -** Zabbix -** Copyright (C) 2001-2022 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - -// Package metric provides an interface for describing a schema of metric's parameters. -package metric - -import ( - "fmt" - "reflect" - "strconv" - "strings" - "unicode" - - "zabbix.com/pkg/zbxerr" -) - -type paramKind int - -const ( - kindSession paramKind = iota - kindConn - kindGeneral - kindSessionOnly -) - -const ( - required = true - optional = false -) - -// Param stores parameters' metadata. -type Param struct { - name string - description string - kind paramKind - required bool - validator Validator - defaultValue *string -} - -func ucFirst(str string) string { - for i, v := range str { - return string(unicode.ToUpper(v)) + str[i+1:] - } - - return "" -} - -func newParam(name, description string, kind paramKind, required bool, validator Validator) *Param { - name = strings.TrimSpace(name) - if len(name) == 0 { - panic("parameter name cannot be empty") - } - - description = ucFirst(strings.TrimSpace(description)) - if len(description) == 0 { - panic("parameter description cannot be empty") - } - - if description[len(description)-1:] != "." { - description += "." - } - - return &Param{ - name: name, - description: description, - kind: kind, - required: required, - validator: validator, - defaultValue: nil, - } -} - -// NewParam creates a new parameter with given name and validator. -// Returns a pointer. -func NewParam(name, description string) *Param { - return newParam(name, description, kindGeneral, optional, nil) -} - -// NewConnParam creates a new connection parameter with given name and validator. -// Returns a pointer. -func NewConnParam(name, description string) *Param { - return newParam(name, description, kindConn, optional, nil) -} - -// NewSessionParam creates a new connection parameter with given name and validator. -// Returns a pointer. -func NewSessionOnlyParam(name, description string) *Param { - return newParam(name, description, kindSessionOnly, optional, nil) -} - -// WithSession transforms a connection typed parameter to a dual purpose parameter which can be either -// a connection parameter or session name. -// Returns a pointer. -func (p *Param) WithSession() *Param { - if p.kind != kindConn { - panic("only connection typed parameter can be transformed to session") - } - - p.kind = kindSession - - return p -} - -// WithDefault sets the default value for a parameter. -// It panics if a default value is specified for a required parameter. -func (p *Param) WithDefault(value string) *Param { - if p.required { - panic("default value cannot be applied to a required parameter") - } - - p.defaultValue = &value - - return p -} - -// WithValidator sets a validator for a parameter -func (p *Param) WithValidator(validator Validator) *Param { - if validator == nil { - panic("validator cannot be nil") - } - - p.validator = validator - - if p.defaultValue != nil { - if err := p.validator.Validate(p.defaultValue); err != nil { - panic(fmt.Sprintf("invalid default value %q for parameter %q: %s", - *p.defaultValue, p.name, err.Error())) - } - } - - return p -} - -// SetRequired makes the parameter mandatory. -// It panics if default value is specified for required parameter. -func (p *Param) SetRequired() *Param { - if p.defaultValue != nil { - panic("required parameter cannot have a default value") - } - - p.required = required - - return p -} - -// Metric stores a description of a metric and its parameters. -type Metric struct { - description string - params []*Param - varParam bool -} - -// ordinalize convert a given number to an ordinal numeral. -func ordinalize(num int) string { - var ordinals = map[int]string{ - 1: "first", - 2: "second", - 3: "third", - 4: "fourth", - 5: "fifth", - 6: "sixth", - 7: "seventh", - 8: "eighth", - 9: "ninth", - 10: "tenth", - } - - if num >= 1 && num <= 10 { - return ordinals[num] - } - - suffix := "th" - switch num % 10 { - case 1: - if num%100 != 11 { - suffix = "st" - } - case 2: - if num%100 != 12 { - suffix = "nd" - } - case 3: - if num%100 != 13 { - suffix = "rd" - } - } - - return strconv.Itoa(num) + suffix -} - -// New creates an instance of a Metric and returns a pointer to it. -// It panics if a metric is not satisfied to one of the following rules: -// 1. Parameters must be named (and names must be unique). -// 2. It's forbidden to duplicate parameters' names. -// 3. Session must be placed first. -// 4. Connection parameters must be placed in a row. -func New(description string, params []*Param, varParam bool) *Metric { - connParamIdx := -1 - - description = ucFirst(strings.TrimSpace(description)) - if len(description) == 0 { - panic("metric description cannot be empty") - } - - if description[len(description)-1:] != "." { - description += "." - } - - if params == nil { - params = []*Param{} - } - - if len(params) > 0 { - if params[0].kind != kindGeneral { - connParamIdx = 0 - } - } - - paramsMap := make(map[string]bool) - - for i, p := range params { - if _, exists := paramsMap[p.name]; exists { - panic(fmt.Sprintf("name of parameter %q must be unique", p.name)) - } - - paramsMap[p.name] = true - - if i > 0 && p.kind == kindSession { - panic("session must be placed first") - } - - if p.kind == kindConn { - if i-connParamIdx > 1 { - panic("parameters describing a connection must be placed in a row") - } - - connParamIdx = i - } - } - - return &Metric{ - description: description, - params: params, - varParam: varParam, - } -} - -func findSession(name string, sessions interface{}) (session interface{}) { - v := reflect.ValueOf(sessions) - if v.Kind() != reflect.Map { - panic("sessions must be map of strings") - } - - for _, key := range v.MapKeys() { - if name == key.String() { - session = v.MapIndex(key).Interface() - break - } - } - - return -} - -func mergeWithSessionData(out map[string]string, metricParams []*Param, session interface{}) error { - v := reflect.ValueOf(session) - for i := 0; i < v.NumField(); i++ { - var p *Param = nil - - val := v.Field(i).String() - - j := 0 - for j = range metricParams { - if metricParams[j].name == v.Type().Field(i).Name { - p = metricParams[j] - break - } - } - - ordNum := ordinalize(j + 1) - - if p == nil { - panic(fmt.Sprintf("cannot find parameter %q in schema", v.Type().Field(i).Name)) - } - - if val == "" { - if p.required { - return zbxerr.ErrorTooFewParameters.Wrap( - fmt.Errorf("%s parameter %q is required", ordNum, p.name)) - } - - if p.defaultValue != nil { - val = *p.defaultValue - } - } - - if p.validator != nil { - if err := p.validator.Validate(&val); err != nil { - return zbxerr.New(fmt.Sprintf("invalid %s parameter %q", ordNum, p.name)).Wrap(err) - } - } - - out[p.name] = val - } - - return nil -} - -// EvalParams returns a mapping of parameters' names to their values passed to a plugin and/or -// sessions specified in the configuration file and extra remaining parameters. -// If a session is configured, then an other connection parameters must not be accepted and an error will be returned. -// Also it returns error in following cases: -// * incorrect number of parameters are passed; -// * missing required parameter; -// * value validation is failed. -func (m *Metric) EvalParams(rawParams []string, sessions interface{}) (params map[string]string, extraParams []string, - err error) { - session, err := m.parseRawParams(rawParams, sessions) - if err != nil { - return - } - - params = make(map[string]string) - - var i int - for _, p := range m.params { - kind := p.kind - if kind == kindSession { - if session != nil { - i++ - - continue - } - - kind = kindConn - } else if kind == kindSessionOnly { - continue - } - - var val *string - skipConnIfSessionIsSet := !(session != nil && kind == kindConn) - ordNum := ordinalize(i + 1) - - if i >= len(rawParams) || rawParams[i] == "" { - if p.required && skipConnIfSessionIsSet { - return nil, nil, zbxerr.ErrorTooFewParameters.Wrap( - fmt.Errorf("%s parameter %q is required", ordNum, p.name)) - } - - if p.defaultValue != nil && skipConnIfSessionIsSet { - val = p.defaultValue - } - } else { - val = &rawParams[i] - } - - i++ - - if val == nil { - continue - } - - if p.validator != nil && skipConnIfSessionIsSet { - if err = p.validator.Validate(val); err != nil { - return nil, nil, zbxerr.New(fmt.Sprintf("invalid %s parameter %q", ordNum, p.name)).Wrap(err) - } - } - - if kind == kindConn { - if session == nil { - params[p.name] = *val - } else { - return nil, nil, zbxerr.ErrorInvalidParams.Wrap( - fmt.Errorf("%s parameter %q cannot be passed along with session", ordNum, p.name)) - } - } - - if kind == kindGeneral { - params[p.name] = *val - } - } - - // Fill connection parameters with data from a session - if session != nil { - if err = mergeWithSessionData(params, m.params, session); err != nil { - return nil, nil, err - } - - params["sessionName"] = rawParams[0] - } - - if i < len(rawParams) { - extraParams = rawParams[i:] - } - - return params, extraParams, nil -} - -func (m *Metric) parseRawParams(rawParams []string, sessions interface{}) (interface{}, error) { - var nonsessionParams int - - for _, p := range m.params { - if p.kind != kindSessionOnly { - nonsessionParams++ - } - } - - if !m.varParam && len(rawParams) > nonsessionParams { - return nil, zbxerr.ErrorTooManyParameters - } - - if len(rawParams) > 0 && m.params[0].kind == kindSession { - return findSession(rawParams[0], sessions), nil - } - - return nil, nil -} - -// MetricSet stores a mapping of keys to metrics. -type MetricSet map[string]*Metric - -// List returns an array of metrics' keys and their descriptions suitable to pass to plugin.RegisterMetrics. -func (ml MetricSet) List() (list []string) { - for key, metric := range ml { - list = append(list, key, metric.description) - } - - return -} diff --git a/src/go/pkg/metric/metric_test.go b/src/go/pkg/metric/metric_test.go deleted file mode 100644 index 3a4c683fe6c..00000000000 --- a/src/go/pkg/metric/metric_test.go +++ /dev/null @@ -1,388 +0,0 @@ -/* -** Zabbix -** Copyright (C) 2001-2022 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - -package metric - -import ( - "reflect" - "testing" - - "zabbix.com/pkg/conf" -) - -var ( - paramURI = NewConnParam("URI", "Description.").WithDefault("localhost:1521").WithSession() - paramUsername = NewConnParam("User", "Description.").WithDefault("") - paramRequiredUsername = NewConnParam("User", "Description.").SetRequired() - paramUserValidation = NewConnParam("User", "Description.").WithDefault("").WithValidator( - SetValidator{Set: []string{"", "supervisor", "admin", "guest"}}) - paramPassword = NewConnParam("Password", "Description.").WithDefault("") - paramGeneral = NewParam("GeneralParam", "Description.") -) - -var metricSet = MetricSet{ - "metric.foo": New("Foo description.", - []*Param{paramURI, paramUsername, paramPassword, - NewParam("Param1", "Description.").WithDefault("60").WithValidator(SetValidator{Set: []string{"15", "60"}}), - }, false), - "metric.bar": New("bar description.", - []*Param{paramURI, paramUsername, NewSessionOnlyParam("Password", "Description.")}, true), - "metric.bar.strict": New("bar description.", - []*Param{paramURI, paramUsername, paramPassword, - NewSessionOnlyParam("Param1", "Description.").SetRequired(), - }, false), - "metric.query": New("Query description.", - []*Param{paramURI, paramUsername, paramPassword, - NewParam("QueryName", "Description.").SetRequired(), - }, true), - "metric.requiredSessionParam": New("RequiredSessionParam description.", - []*Param{paramURI, paramRequiredUsername, paramPassword}, false), - "metric.withoutPassword": New("WithoutPassword description.", - []*Param{paramURI, paramUsername}, false), - "metric.userValidation": New("UserValidation description.", - []*Param{paramURI, paramUserValidation, paramPassword}, false), -} - -func TestMetric_EvalParams(t *testing.T) { - type args struct { - rawParams []string - sessions interface{} - } - tests := []struct { - name string - m *Metric - args args - want map[string]string - wantExtra []string - wantErr bool - wantPanic bool - }{ - { - name: "Must fail if too many parameters passed", - m: metricSet["metric.foo"], - args: args{ - rawParams: []string{"localhost", "user", "password", "15", "excessParam"}, - sessions: map[string]conf.Session{}, - }, - want: nil, - wantErr: true, - wantPanic: false, - }, - { - name: "Must not fail if passed more parameters than described, but the metric has the varParam enabled", - m: metricSet["metric.query"], - args: args{ - rawParams: []string{"localhost", "user", "password", "queryName", "queryParam1", "queryParam2"}, - sessions: map[string]conf.Session{}, - }, - want: map[string]string{"Password": "password", "QueryName": "queryName", "URI": "localhost", "User": "user"}, - wantExtra: []string{"queryParam1", "queryParam2"}, - wantErr: false, - wantPanic: false, - }, - { - name: "Must not fail if passed more parameters than described, " + - "but the metric has the varParam enabled (with session)", - m: metricSet["metric.query"], - args: args{ - rawParams: []string{"Session1", "", "", "queryName", "queryParam1", "queryParam2"}, - sessions: map[string]conf.Session{ - "Session1": {URI: "localhost", User: "user", Password: "password"}, - }, - }, - want: map[string]string{ - "Password": "password", "QueryName": "queryName", "URI": "localhost", "User": "user", "sessionName": "Session1", - }, - wantExtra: []string{"queryParam1", "queryParam2"}, - wantErr: false, - wantPanic: false, - }, - { - name: "Must not fail if passed session only parameters none strict", - m: metricSet["metric.bar"], - args: args{ - rawParams: []string{"Session1", "", "queryParam1"}, - sessions: map[string]conf.Session{ - "Session1": {URI: "localhost", User: "user", Password: "password"}, - }, - }, - want: map[string]string{ - "Password": "password", "URI": "localhost", "User": "user", "sessionName": "Session1", - }, - wantExtra: []string{"queryParam1"}, - wantErr: false, - wantPanic: false, - }, - { - name: "Must not fail if missing session only parameters none strict", - m: metricSet["metric.bar"], - args: args{ - rawParams: []string{"Session1", "", "queryParam1"}, - sessions: map[string]conf.Session{ - "Session1": {URI: "localhost", User: "user"}, - }, - }, - want: map[string]string{ - "Password": "", "URI": "localhost", "User": "user", "sessionName": "Session1", - }, - wantExtra: []string{"queryParam1"}, - wantErr: false, - wantPanic: false, - }, - { - name: "Must not fail if passed session only parameters none strict", - m: metricSet["metric.bar"], - args: args{ - rawParams: []string{"Session1", "", "queryParam1"}, - sessions: map[string]conf.Session{ - "Session1": {URI: "localhost", User: "user", Password: "password"}, - }, - }, - want: map[string]string{ - "Password": "password", "URI": "localhost", "User": "user", "sessionName": "Session1", - }, - wantExtra: []string{"queryParam1"}, - wantErr: false, - wantPanic: false, - }, - { - name: "Must fail if missing session only parameters with strict required", - m: metricSet["metric.bar.strict"], - args: args{ - rawParams: []string{"Session1", "", "queryParam1"}, - sessions: map[string]conf.Session{ - "Session1": {URI: "localhost", User: "user"}, - }, - }, - want: nil, - wantExtra: nil, - wantErr: true, - wantPanic: false, - }, - { - name: "Must fail if session only parameter passed in key", - m: metricSet["metric.bar.strict"], - args: args{ - rawParams: []string{"localhost", "user", "password", "param1"}, - sessions: map[string]conf.Session{}, - }, - want: nil, - wantExtra: nil, - wantErr: true, - wantPanic: false, - }, - { - name: "Must fail if a required parameter is not specified", - m: metricSet["metric.query"], - args: args{ - rawParams: []string{"localhost", "user", "password", "", "queryParam1"}, - sessions: map[string]conf.Session{}, - }, - want: nil, - wantErr: true, - wantPanic: false, - }, - { - name: "Must fail if validation failed", - m: metricSet["metric.foo"], - args: args{ - rawParams: []string{"localhost", "user", "password", "wrongValue"}, - sessions: map[string]conf.Session{}, - }, - want: nil, - wantErr: true, - wantPanic: false, - }, - { - name: "Must fail if a session parameter did not pass validation", - m: metricSet["metric.userValidation"], - args: args{ - rawParams: []string{"Session1"}, - sessions: map[string]conf.Session{ - "Session1": {URI: "localhost", User: "bob", Password: "password"}, - }, - }, - want: nil, - wantErr: true, - wantPanic: false, - }, - { - name: "Must fail if a connection parameter passed along with a session", - m: metricSet["metric.foo"], - args: args{ - rawParams: []string{"Session1", "", "password"}, - sessions: map[string]conf.Session{ - "Session1": {URI: "localhost", User: "user", Password: "password"}, - }, - }, - want: nil, - wantErr: true, - wantPanic: false, - }, - { - name: "Must fail if a required parameter is omitted in a session", - m: metricSet["metric.requiredSessionParam"], - args: args{ - rawParams: []string{"Session1"}, - sessions: map[string]conf.Session{ - "Session1": {URI: "localhost", Password: "password"}, - }, - }, - want: nil, - wantErr: true, - wantPanic: false, - }, - { - name: "Must panic if cannot find any session's parameter in a schema", - m: metricSet["metric.withoutPassword"], - args: args{ - rawParams: []string{"Session1"}, - sessions: map[string]conf.Session{ - "Session1": {URI: "localhost", User: "user", Password: "password"}, - }, - }, - want: nil, - wantErr: false, - wantPanic: true, - }, - { - name: "Must successfully return parsed parameters (without session)", - m: metricSet["metric.foo"], - args: args{ - rawParams: []string{"localhost", "user", "password", "15"}, - sessions: map[string]conf.Session{}, - }, - want: map[string]string{"URI": "localhost", "User": "user", "Password": "password", "Param1": "15"}, - wantErr: false, - wantPanic: false, - }, - { - name: "Must successfully return parsed parameters (with session)", - m: metricSet["metric.foo"], - args: args{ - rawParams: []string{"Session1", "", "", "15"}, - sessions: map[string]conf.Session{ - "Session1": {URI: "localhost", User: "user", Password: "password"}, - }, - }, - want: map[string]string{ - "URI": "localhost", "User": "user", "Password": "password", "Param1": "15", "sessionName": "Session1", - }, - wantErr: false, - wantPanic: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if tt.wantPanic { - defer func() { - if r := recover(); r == nil { - t.Error("Metric.EvalParams() must panic with runtime error") - } - }() - } - - gotParams, gotExtraParams, err := tt.m.EvalParams(tt.args.rawParams, tt.args.sessions) - if (err != nil) != tt.wantErr { - t.Errorf("EvalParams() error = %v, wantErr %v", err, tt.wantErr) - return - } - if !reflect.DeepEqual(gotParams, tt.want) { - t.Errorf("EvalParams() got = %v, want %v", gotParams, tt.want) - } - if !reflect.DeepEqual(gotExtraParams, tt.wantExtra) { - t.Errorf("EvalParams() got extraParams = %v, want %v", gotExtraParams, tt.wantExtra) - } - }) - } -} - -func TestNew(t *testing.T) { - type args struct { - description string - params []*Param - varParam bool - } - tests := []struct { - name string - args args - want *Metric - wantPanic bool - }{ - { - name: "Must fail if a parameter has a non-unique name", - args: args{ - "Metric description.", - []*Param{paramURI, paramUsername, paramUsername, paramPassword, NewParam("Param", "Description.")}, - false, - }, - want: nil, - wantPanic: true, - }, - { - name: "Must fail if a session placed not first", - args: args{ - "Metric description.", - []*Param{paramUsername, paramPassword, paramURI, NewParam("Param", "Description.")}, - false, - }, - want: nil, - wantPanic: true, - }, - { - name: "Must fail if parameters describing a connection placed not in a row", - args: args{ - "Metric description.", - []*Param{paramURI, paramUsername, NewParam("Param", "Description."), paramPassword}, - false, - }, - want: nil, - wantPanic: true, - }, - { - name: "Must successfully return a new metric", - args: args{ - "Metric description.", - []*Param{paramURI, paramUsername, paramPassword, paramGeneral}, - false, - }, - want: &Metric{ - "Metric description.", - []*Param{paramURI, paramUsername, paramPassword, paramGeneral}, - false, - }, - wantPanic: false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if tt.wantPanic { - defer func() { - if r := recover(); r == nil { - t.Error("New() must panic with runtime error") - } - }() - } - - if got := New(tt.args.description, tt.args.params, tt.args.varParam); !reflect.DeepEqual(got, tt.want) { - t.Errorf("New() = %v, want %v", got, tt.want) - } - }) - } -} diff --git a/src/go/pkg/metric/validators.go b/src/go/pkg/metric/validators.go deleted file mode 100644 index c40acdf41ba..00000000000 --- a/src/go/pkg/metric/validators.go +++ /dev/null @@ -1,131 +0,0 @@ -/* -** Zabbix -** Copyright (C) 2001-2022 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - -// Package metric provides an interface for describing a schema of metric's parameters. -package metric - -import ( - "fmt" - "regexp" - "strconv" - "strings" -) - -type Validator interface { - Validate(value *string) error -} - -type SetValidator struct { - Set []string - CaseInsensitive bool -} - -func (v SetValidator) Validate(value *string) error { - if v.Set != nil && len(v.Set) == 0 { - panic("set cannot be empty") - } - - if value == nil { - return nil - } - - for _, s := range v.Set { - if (v.CaseInsensitive && strings.ToLower(*value) == strings.ToLower(s)) || (!v.CaseInsensitive && *value == s) { - return nil - } - } - - return fmt.Errorf("allowed values: %s", strings.Join(v.Set, ", ")) -} - -type PatternValidator struct { - Pattern string -} - -func (v PatternValidator) Validate(value *string) error { - if value == nil { - return nil - } - - b, err := regexp.MatchString(v.Pattern, *value) - if err != nil { - return err - } - - if !b { - return fmt.Errorf("value does not match pattern %q", v.Pattern) - } - - return nil -} - -type LenValidator struct { - Min *int - Max *int -} - -func (v LenValidator) Validate(value *string) error { - if value == nil || (v.Min == nil && v.Max == nil) { - return nil - } - - if v.Min != nil && len(*value) < *v.Min { - return fmt.Errorf("value cannot be shorter than %d characters", v.Min) - } - - if v.Max != nil && len(*value) > *v.Max { - return fmt.Errorf("value cannot be longer than %d characters", v.Max) - } - - return nil -} - -type RangeValidator struct { - Min int - Max int -} - -func (v RangeValidator) Validate(value *string) error { - if value == nil { - return nil - } - - intVal, err := strconv.Atoi(*value) - if err != nil { - return err - } - - if intVal < v.Min || intVal > v.Max { - return fmt.Errorf("value is out of range [%d..%d]", v.Min, v.Max) - } - - return nil -} - -type NumberValidator struct{} - -func (v NumberValidator) Validate(value *string) error { - if value == nil { - return nil - } - - _, err := strconv.Atoi(*value) - - return err -} diff --git a/src/go/pkg/metric/validators_test.go b/src/go/pkg/metric/validators_test.go deleted file mode 100644 index bf9d078b7fb..00000000000 --- a/src/go/pkg/metric/validators_test.go +++ /dev/null @@ -1,203 +0,0 @@ -/* -** Zabbix -** Copyright (C) 2001-2022 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - -package metric - -import "testing" - -var ( - number = "42" - notNumber = "foo" -) - -func TestNumberValidator_Validate(t *testing.T) { - type args struct { - value *string - } - tests := []struct { - name string - args args - wantErr bool - }{ - { - name: "Must successfully validate a number", - args: args{&number}, - wantErr: false, - }, - { - name: "Must successfully validate nil", - args: args{nil}, - wantErr: false, - }, - { - name: "Must fail if a given value is not a number", - args: args{¬Number}, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - v := NumberValidator{} - if err := v.Validate(tt.args.value); (err != nil) != tt.wantErr { - t.Errorf("Validate() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -var ( - string1 = "hello123" - string2 = "hello world" -) - -func TestPatternValidator_Validate(t *testing.T) { - type fields struct { - Pattern string - } - type args struct { - value *string - } - tests := []struct { - name string - fields fields - args args - wantErr bool - }{ - { - name: "Must successfully validate a string value", - fields: fields{"^hello[0-9]+$"}, - args: args{&string1}, - wantErr: false, - }, - { - name: "Must successfully validate nil", - args: args{nil}, - wantErr: false, - }, - { - name: "Must fail if a given value does not match a given pattern", - fields: fields{"^hello[0-9]+$"}, - args: args{&string2}, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - v := PatternValidator{ - Pattern: tt.fields.Pattern, - } - if err := v.Validate(tt.args.value); (err != nil) != tt.wantErr { - t.Errorf("Validate() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -var ( - valInRange = "50" - valNotInRange = "1000" -) - -func TestRangeValidator_Validate(t *testing.T) { - type fields struct { - Min int - Max int - } - type args struct { - value *string - } - tests := []struct { - name string - fields fields - args args - wantErr bool - }{ - { - name: "Must successfully validate a value in a range", - fields: fields{0, 100}, - args: args{&valInRange}, - wantErr: false, - }, - { - name: "Must successfully validate nil", - args: args{nil}, - wantErr: false, - }, - { - name: "Must fail if a given value is out of a range", - fields: fields{0, 100}, - args: args{&valNotInRange}, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - v := RangeValidator{ - Min: tt.fields.Min, - Max: tt.fields.Max, - } - if err := v.Validate(tt.args.value); (err != nil) != tt.wantErr { - t.Errorf("Validate() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -func TestSetValidator_Validate(t *testing.T) { - type fields struct { - Set []string - } - type args struct { - value *string - } - tests := []struct { - name string - fields fields - args args - wantErr bool - }{ - { - name: "Must successfully validate a value in a set", - fields: fields{[]string{"foo", "42", "100500"}}, - args: args{&number}, - wantErr: false, - }, - { - name: "Must successfully validate nil", - args: args{nil}, - wantErr: false, - }, - { - name: "Must fail if a given value is out of a set", - fields: fields{[]string{"foo", "42", "100500"}}, - args: args{&string1}, - wantErr: true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - v := SetValidator{ - Set: tt.fields.Set, - } - if err := v.Validate(tt.args.value); (err != nil) != tt.wantErr { - t.Errorf("Validate() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} diff --git a/src/go/pkg/pdh/pdh_windows.go b/src/go/pkg/pdh/pdh_windows.go index af1cd0d1fb4..d900a9b8333 100644 --- a/src/go/pkg/pdh/pdh_windows.go +++ b/src/go/pkg/pdh/pdh_windows.go @@ -25,7 +25,7 @@ import ( "syscall" "unsafe" - "zabbix.com/pkg/log" + "git.zabbix.com/ap/plugin-support/log" "zabbix.com/pkg/win32" "golang.org/x/sys/windows" diff --git a/src/go/pkg/plugin/base.go b/src/go/pkg/plugin/base.go deleted file mode 100644 index fccc5ea85f9..00000000000 --- a/src/go/pkg/plugin/base.go +++ /dev/null @@ -1,70 +0,0 @@ -/* -** Zabbix -** Copyright (C) 2001-2022 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - -package plugin - -import ( - "zabbix.com/pkg/log" -) - -type Accessor interface { - Init(name string) - Name() string - Capacity() int - SetCapacity(capactity int) - IsExternal() bool -} - -type Base struct { - log.Logger - name string - capacity int - external bool -} - -func (b *Base) Init(name string) { - b.Logger = log.New(name) - b.name = name - b.capacity = DefaultCapacity -} - -func (b *Base) Name() string { - return b.name -} - -func (b *Base) Capacity() int { - return b.capacity -} - -func (b *Base) SetCapacity(capacity int) { - b.capacity = capacity -} - -func (b *Base) IsExternal() bool { - return b.external -} - -func (b *Base) SetExternal(isExternal bool) { - b.external = isExternal -} - -type SystemOptions struct { - Path string `conf:"optional"` - Capacity string `conf:"optional"` -} diff --git a/src/go/pkg/plugin/comms/connection.go b/src/go/pkg/plugin/comms/connection.go deleted file mode 100644 index 34fdceb88af..00000000000 --- a/src/go/pkg/plugin/comms/connection.go +++ /dev/null @@ -1,124 +0,0 @@ -/* -** Zabbix -** Copyright (C) 2001-2022 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - -package comms - -import ( - "bytes" - "encoding/binary" - "encoding/json" - "fmt" - "net" -) - -const JSONType = uint32(1) -const headerTypeLen = 4 -const headerDataLen = 4 - -func Read(conn net.Conn) (dataType uint32, requestData []byte, err error) { - reqByteType := make([]byte, headerTypeLen) - reqByteLen := make([]byte, headerDataLen) - n, err := conn.Read(reqByteType) - if err != nil { - return - } - - if n < headerTypeLen { - err = fmt.Errorf( - "incomplete protocol header type value, %d bytes read, must be 4 bytes", - n, - ) - - return - } - - if JSONType != binary.LittleEndian.Uint32(reqByteType) { - err = fmt.Errorf("only json data type (%d) supported", JSONType) - - return - } - - n, err = conn.Read(reqByteLen) - if err != nil { - return - } - - if n < headerDataLen { - err = fmt.Errorf( - "incomplete protocol header length value, %d bytes read, must be 4 bytes", - n, - ) - - return - } - - reqLen := int32(binary.LittleEndian.Uint32(reqByteLen)) - data := make([]byte, reqLen) - - n, err = conn.Read(data) - if err != nil { - return - } - - if n < int(reqLen) { - err = fmt.Errorf( - "incomplete protocol body value, %d bytes read, must be %d bytes", - n, - reqLen, - ) - - return - } - - var c Common - if err := json.Unmarshal(data, &c); err != nil { - return 0, nil, err - } - - return c.Type, data, nil -} - -func Write(conn net.Conn, in interface{}) (err error) { - reqBytes, err := json.Marshal(in) - if err != nil { - return - } - - buf := new(bytes.Buffer) - err = binary.Write(buf, binary.LittleEndian, JSONType) - if err != nil { - return - } - - err = binary.Write(buf, binary.LittleEndian, uint32(len(reqBytes))) - if err != nil { - return - } - - _, err = buf.Write(reqBytes) - if err != nil { - return - } - - if _, err = conn.Write(buf.Bytes()); err != nil { - return - } - - return -} diff --git a/src/go/pkg/plugin/comms/protocol.go b/src/go/pkg/plugin/comms/protocol.go deleted file mode 100644 index 57b3fad7bb5..00000000000 --- a/src/go/pkg/plugin/comms/protocol.go +++ /dev/null @@ -1,142 +0,0 @@ -/* -** Zabbix -** Copyright (C) 2001-2022 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - -package comms - -import ( - "zabbix.com/pkg/plugin" -) - -const Version = "1.0" - -const NonRequiredID = 0 - -const ( - Exporter = 1 << iota - Configurator - Runner -) - -const ( - LogRequestType = iota + 1 - RegisterRequestType - RegisterResponseType - StartRequestType - TerminateRequestType - ExportRequestType - ExportResponseType - ConfigureRequestType - ValidateRequestType - ValidateResponseType - PeriodRequestType - PeriodResponseType -) - -type request int - -var toString = map[request]string{ - LogRequestType: "Log Request", - RegisterRequestType: "Register Request", - RegisterResponseType: "Register Response", - StartRequestType: "Start Request", - TerminateRequestType: "Terminate Request", - ExportRequestType: "Export Request", - ExportResponseType: "Export Response", - ConfigureRequestType: "Configure Request", - ValidateRequestType: "Validate Request", - ValidateResponseType: "Validate Response", - PeriodRequestType: "Period Request", - PeriodResponseType: "Period Response", -} - -func GetRequestName(reqType uint32) string { - return toString[request(reqType)] -} - -func ImplementsConfigurator(in uint32) bool { - return in&Configurator != 0 -} - -func ImplementsExporter(in uint32) bool { - return in&Exporter != 0 -} - -func ImplementsRunner(in uint32) bool { - return in&Runner != 0 -} - -type Common struct { - Id uint32 `json:"id"` - Type uint32 `json:"type"` -} - -type LogRequest struct { - Common - Severity uint32 `json:"severity"` - Message string `json:"message"` -} - -type RegisterRequest struct { - Common - Version string `json:"version"` -} - -type RegisterResponse struct { - Common - Name string `json:"name"` - Metrics []string `json:"metrics,omitempty"` - Interfaces uint32 `json:"interfaces,omitempty"` - Error string `json:"error,omitempty"` -} - -type ValidateRequest struct { - Common - PrivateOptions interface{} `json:"private_options,omitempty"` -} - -type ValidateResponse struct { - Common - Error string `json:"error,omitempty"` -} - -type StartRequest struct { - Common -} - -type TerminateRequest struct { - Common -} - -type ExportRequest struct { - Common - Key string `json:"key"` - Params []string `json:"parameters,omitempty"` -} - -type ExportResponse struct { - Common - Value interface{} `json:"value,omitempty"` - Error string `json:"error,omitempty"` -} - -type ConfigureRequest struct { - Common - GlobalOptions *plugin.GlobalOptions `json:"global_options"` - PrivateOptions interface{} `json:"private_options,omitempty"` -} diff --git a/src/go/pkg/plugin/container/handler.go b/src/go/pkg/plugin/container/handler.go deleted file mode 100644 index bb44b307ad6..00000000000 --- a/src/go/pkg/plugin/container/handler.go +++ /dev/null @@ -1,380 +0,0 @@ -/* -** Zabbix -** Copyright (C) 2001-2022 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - -package container - -import ( - "encoding/json" - "errors" - "fmt" - "net" - "os" - "os/signal" - "strconv" - "syscall" - "time" - - "zabbix.com/pkg/plugin" - "zabbix.com/pkg/plugin/comms" -) - -const defaultTimeout = 3 -const socketArg = 2 -const startTypeArg = 3 - -const ( - Info = 0 - Crit = 1 - Err = 2 - Warning = 3 - Debug = 4 - Trace = 5 -) - -type handler struct { - name string - accessor plugin.Accessor - socket string - registerStart bool - connection net.Conn -} - -var supportedVersion map[string]bool - -func NewHandler(name string) (h handler, err error) { - h.name = name - - if len(os.Args) < socketArg { - err = errors.New("no socket provided") - - return - } - - h.socket = os.Args[1] - - if len(os.Args) < startTypeArg { - h.registerStart = false - - return - } - - h.registerStart, err = strconv.ParseBool(os.Args[2]) - if err != nil { - err = fmt.Errorf("failed to parse third parameter %s", err.Error()) - - return - } - - return -} - -func (h *handler) Execute() error { - err := h.setConnection(h.socket, defaultTimeout*time.Second) - if err != nil { - return err - } - - h.accessor, err = plugin.GetByName(h.name) - if err != nil { - h.Errf("failed to get accessor for plugin %s, %s", h.name, err.Error()) - - return err - } - - h.run() - - return nil -} - -func (h *handler) run() { - go ignoreSIGINTandSIGTERM() - - for { - err := h.handle() - if err != nil { - h.Errf("failed to handle request for plugin %s, %s", h.name, err.Error()) - } - } -} - -func (h *handler) handle() error { - reqType, data, err := comms.Read(h.connection) - if err != nil { - return err - } - - h.Tracef("plugin %s executing %s", h.name, comms.GetRequestName(reqType)) - - switch reqType { - case comms.RegisterRequestType: - err = h.register(data) - if err != nil { - return err - } - case comms.StartRequestType: - err = h.start() - if err != nil { - return err - } - case comms.TerminateRequestType: - h.terminate() - case comms.ValidateRequestType: - err = h.validate(data) - if err != nil { - return err - } - case comms.ExportRequestType: - err = h.export(data) - if err != nil { - return err - } - case comms.ConfigureRequestType: - err = h.configure(data) - if err != nil { - return err - } - default: - return fmt.Errorf("unknown request recivied: %d", reqType) - } - - h.Tracef("plugin %s executed %s", h.name, comms.GetRequestName(reqType)) - - return nil -} - -func (h *handler) start() error { - p, ok := h.accessor.(plugin.Runner) - if !ok { - return nil - } - - p.Start() - - return nil -} - -func (h *handler) stop() { - if h.registerStart { - return - } - - p, ok := h.accessor.(plugin.Runner) - if !ok { - return - } - - p.Stop() -} - -func (h *handler) register(data []byte) error { - var req comms.RegisterRequest - err := json.Unmarshal(data, &req) - if err != nil { - return err - } - - response := createEmptyRegisterResponse(req.Id) - - err = checkVersion(req.Version) - if err != nil { - response.Error = err.Error() - - return comms.Write(h.connection, response) - } - - var metrics []string - - for key, metric := range plugin.Metrics { - metrics = append(metrics, key) - metrics = append(metrics, metric.Description) - } - - interfaces := h.getInterfaces() - response.Name = h.name - response.Metrics = metrics - response.Interfaces = interfaces - - return comms.Write(h.connection, response) -} - -func checkVersion(version string) error { - if supportedVersion[version] { - return nil - } - - return fmt.Errorf("plugin does not support version %s", version) -} - -func (h *handler) validate(data []byte) error { - var req comms.ValidateRequest - err := json.Unmarshal(data, &req) - if err != nil { - return err - } - - response := createEmptyValidateResponse(req.Id) - - p, ok := h.accessor.(plugin.Configurator) - if !ok { - panic("plugin does not implement Configurator interface") - } - - err = p.Validate(req.PrivateOptions) - if err != nil { - response.Error = err.Error() - } - - return comms.Write(h.connection, response) -} - -func (h *handler) configure(data []byte) error { - var req comms.ConfigureRequest - err := json.Unmarshal(data, &req) - if err != nil { - return err - } - - p, ok := h.accessor.(plugin.Configurator) - if !ok { - panic("plugin does not implement Configurator interface") - } - - p.Configure(req.GlobalOptions, req.PrivateOptions) - - return nil -} - -func (h *handler) export(data []byte) error { - var req comms.ExportRequest - err := json.Unmarshal(data, &req) - if err != nil { - return err - } - - p, ok := h.accessor.(plugin.Exporter) - if !ok { - panic("plugin does not implement Exporter interface") - } - - response := createEmptyExportResponse(req.Id) - response.Value, err = p.Export(req.Key, req.Params, &emptyCtx{}) - if err != nil { - response.Error = err.Error() - } - - return comms.Write(h.connection, response) -} - -func (h *handler) terminate() { - h.stop() - os.Exit(0) -} - -func (h *handler) getInterfaces() uint32 { - var interfaces uint32 - - _, ok := h.accessor.(plugin.Exporter) - if ok { - interfaces |= comms.Exporter - } - - _, ok = h.accessor.(plugin.Configurator) - if ok { - interfaces |= comms.Configurator - } - - _, ok = h.accessor.(plugin.Runner) - if ok { - interfaces |= comms.Runner - } - - return interfaces -} - -func (h *handler) Tracef(format string, args ...interface{}) { - h.sendLog(createLogRequest(Trace, fmt.Sprintf(format, args...))) -} - -func (h *handler) Debugf(format string, args ...interface{}) { - h.sendLog(createLogRequest(Debug, fmt.Sprintf(format, args...))) -} - -func (h *handler) Warningf(format string, args ...interface{}) { - h.sendLog(createLogRequest(Warning, fmt.Sprintf(format, args...))) -} - -func (h *handler) Infof(format string, args ...interface{}) { - h.sendLog(createLogRequest(Info, fmt.Sprintf(format, args...))) -} - -func (h *handler) Errf(format string, args ...interface{}) { - h.sendLog(createLogRequest(Err, fmt.Sprintf(format, args...))) -} - -func (h *handler) Critf(format string, args ...interface{}) { - h.sendLog(createLogRequest(Crit, fmt.Sprintf(format, args...))) -} - -func createLogRequest(severity uint32, message string) comms.LogRequest { - return comms.LogRequest{ - Common: comms.Common{ - Id: comms.NonRequiredID, - Type: comms.LogRequestType, - }, - Severity: severity, - Message: message, - } -} - -func createEmptyRegisterResponse(id uint32) comms.RegisterResponse { - return comms.RegisterResponse{ - Common: comms.Common{ - Id: id, - Type: comms.RegisterResponseType, - }, - } -} - -func createEmptyExportResponse(id uint32) comms.ExportResponse { - return comms.ExportResponse{Common: comms.Common{Id: id, Type: comms.ExportResponseType}} -} - -func createEmptyValidateResponse(id uint32) comms.ValidateResponse { - return comms.ValidateResponse{Common: comms.Common{Id: id, Type: comms.ValidateResponseType}} -} - -func (h *handler) sendLog(request comms.LogRequest) { - err := comms.Write(h.connection, request) - if err != nil { - panic(fmt.Sprintf("failed to log message %s", err.Error())) - } -} - -func ignoreSIGINTandSIGTERM() { - sigs := make(chan os.Signal, 1) - signal.Notify(sigs, syscall.SIGINT, syscall.SIGTERM) - for { - <-sigs - } -} - -func init() { - supportedVersion = map[string]bool{} - supportedVersion[comms.Version] = true -} diff --git a/src/go/pkg/plugin/container/handler_linux.go b/src/go/pkg/plugin/container/handler_linux.go deleted file mode 100644 index 7c5e07ea50f..00000000000 --- a/src/go/pkg/plugin/container/handler_linux.go +++ /dev/null @@ -1,49 +0,0 @@ -/* -** Zabbix -** Copyright (C) 2001-2022 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - -package container - -import ( - "net" - "time" -) - -func (h *handler) setConnection(path string, timeout time.Duration) (err error) { - var i int - - for start := time.Now(); ; { - if i%5 == 0 { - if time.Since(start) > timeout { - break - } - } - - var conn net.Conn - conn, err = net.DialTimeout("unix", path, timeout) - if err != nil { - continue - } - - h.connection = conn - - return - } - - return -} diff --git a/src/go/pkg/plugin/container/handler_windows.go b/src/go/pkg/plugin/container/handler_windows.go deleted file mode 100644 index f05588d47da..00000000000 --- a/src/go/pkg/plugin/container/handler_windows.go +++ /dev/null @@ -1,50 +0,0 @@ -/* -** Zabbix -** Copyright (C) 2001-2022 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - -package container - -import ( - "net" - "time" - - "github.com/natefinch/npipe" -) - -func (h *handler) setConnection(path string, timeout time.Duration) (err error) { - var i int - - for start := time.Now(); ; { - if i%5 == 0 { - if time.Since(start) > timeout { - break - } - } - - var conn net.Conn - if conn, err = npipe.DialTimeout(path, timeout); err != nil { - return - } - - h.connection = conn - - return - } - - return -} diff --git a/src/go/pkg/plugin/container/interface.go b/src/go/pkg/plugin/container/interface.go deleted file mode 100644 index dccdeee56c3..00000000000 --- a/src/go/pkg/plugin/container/interface.go +++ /dev/null @@ -1,55 +0,0 @@ -/* -** Zabbix -** Copyright (C) 2001-2022 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ -package container - -import "zabbix.com/pkg/plugin" - -type emptyCtx struct { - resultWriter emptyResultWriter - matcher emptyMatcher -} - -func (ctx emptyCtx) ClientID() uint64 { - return 0 -} -func (ctx emptyCtx) ItemID() uint64 { - return 0 -} -func (ctx emptyCtx) Output() plugin.ResultWriter { - return ctx.resultWriter -} -func (ctx emptyCtx) Meta() *plugin.Meta { - return nil -} -func (ctx emptyCtx) GlobalRegexp() plugin.RegexpMatcher { - return ctx.matcher -} - -type emptyMatcher struct{} - -func (em emptyMatcher) Match(value string, pattern string, mode int, output_template *string) (bool, string) { - return false, "" -} - -type emptyResultWriter struct{} - -func (rw emptyResultWriter) Write(result *plugin.Result) {} -func (rw emptyResultWriter) Flush() {} -func (rw emptyResultWriter) SlotsAvailable() int { return 0 } -func (rw emptyResultWriter) PersistSlotsAvailable() int { return 0 } diff --git a/src/go/pkg/plugin/registry.go b/src/go/pkg/plugin/registry.go deleted file mode 100644 index 3176fbf7667..00000000000 --- a/src/go/pkg/plugin/registry.go +++ /dev/null @@ -1,160 +0,0 @@ -/* -** Zabbix -** Copyright (C) 2001-2022 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - -package plugin - -import ( - "fmt" - "reflect" - "regexp" - "unicode" -) - -type Metric struct { - Plugin Accessor - Key string - Description string - UsrPrm bool -} - -var Metrics map[string]*Metric = make(map[string]*Metric) -var Plugins map[string]Accessor = make(map[string]Accessor) - -func registerMetric(plugin Accessor, name string, key string, description string) { - var usrprm bool - - if ok, _ := regexp.MatchString(`^[A-Za-z0-9\._-]+$`, key); !ok { - panic(fmt.Sprintf(`cannot register metric "%s" having invalid format`, key)) - } - - if 0 == len(description) { - panic(fmt.Sprintf(`cannot register metric "%s" with empty description`, key)) - } - - if unicode.IsLower([]rune(description)[0]) { - panic(fmt.Sprintf(`cannot register metric "%s" with description without capital first letter: "%s"`, key, description)) - } - - if description[len(description)-1] != '.' { - panic(fmt.Sprintf(`cannot register metric "%s" without dot at the end of description: "%s"`, key, description)) - } - - if _, ok := Metrics[key]; ok { - panic(fmt.Sprintf(`cannot register duplicate metric "%s"`, key)) - } - - t := reflect.TypeOf(plugin) - for i := 0; i < t.NumMethod(); i++ { - method := t.Method(i) - switch method.Name { - case "Export": - if _, ok := plugin.(Exporter); !ok { - panic(fmt.Sprintf(`the "%s" plugin has %s method, but does implement Exporter interface`, name, method.Name)) - } - case "Collect", "Period": - if _, ok := plugin.(Collector); !ok { - panic(fmt.Sprintf(`the "%s" plugin has %s method, but does not implement Collector interface`, name, method.Name)) - } - case "Watch": - if _, ok := plugin.(Watcher); !ok { - panic(fmt.Sprintf(`the "%s" plugin has %s method, but does not implement Watcher interface`, name, method.Name)) - } - case "Configure", "Validate": - if _, ok := plugin.(Configurator); !ok { - panic(fmt.Sprintf(`the "%s" plugin has %s method, but does not implement Configurator interface`, name, method.Name)) - } - case "Start", "Stop": - if _, ok := plugin.(Runner); !ok { - panic(fmt.Sprintf(`the "%s" plugin has %s method, but does not implement Runner interface`, name, method.Name)) - } - } - } - switch plugin.(type) { - case Exporter, Collector, Runner, Watcher, Configurator: - default: - panic(fmt.Sprintf(`plugin "%s" does not implement any plugin interfaces`, name)) - } - - if p, ok := Plugins[name]; ok { - if p != plugin { - panic(fmt.Sprintf(`plugin name "%s" has been already registered by other plugin`, name)) - } - } else { - Plugins[name] = plugin - plugin.Init(name) - } - - if name == "UserParameter" { - usrprm = true - } else { - usrprm = false - } - - Metrics[key] = &Metric{Plugin: plugin, Key: key, Description: description, UsrPrm: usrprm} -} - -func RegisterMetrics(impl Accessor, name string, params ...string) { - if len(params) < 2 { - panic("expected at least one metric and its description") - } - if len(params)&1 != 0 { - panic("expected even number of metric and description parameters") - } - for i := 0; i < len(params); i += 2 { - registerMetric(impl, name, params[i], params[i+1]) - } -} - -func Get(key string) (acc Accessor, err error) { - if m, ok := Metrics[key]; ok { - return m.Plugin, nil - } - return nil, UnsupportedMetricError -} - -func ClearRegistry() { - Metrics = make(map[string]*Metric) - Plugins = make(map[string]Accessor) -} - -func GetByName(name string) (acc Accessor, err error) { - if p, ok := Plugins[name]; ok { - return p, nil - } - return nil, UnsupportedMetricError -} - -func ClearUserParamMetrics() (metricsFallback map[string]*Metric) { - metricsFallback = make(map[string]*Metric) - - for key, metric := range Metrics { - if metric.UsrPrm { - metricsFallback[key] = metric - delete(Metrics, key) - } - } - - return -} - -func RestoreUserParamMetrics(metrics map[string]*Metric) { - for key, metric := range metrics { - Metrics[key] = metric - } -} diff --git a/src/go/pkg/plugin/types.go b/src/go/pkg/plugin/types.go deleted file mode 100644 index fc693f0bab4..00000000000 --- a/src/go/pkg/plugin/types.go +++ /dev/null @@ -1,144 +0,0 @@ -/* -** Zabbix -** Copyright (C) 2001-2022 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - -package plugin - -import ( - "errors" - "sync/atomic" - "time" -) - -const ( - DefaultCapacity = 100 -) - -var UnsupportedMetricError error - -// Collector - interface for periodical metric collection -type Collector interface { - Collect() error - Period() int -} - -// Exporter - interface for exporting collected metrics -type Exporter interface { - // Export method exports data based on the key 'key' and its parameters 'params'. - Export(key string, params []string, context ContextProvider) (interface{}, error) -} - -// Runner - interface for managing background processes -type Runner interface { - // Start method activates plugin. - Start() - // Stop method deactivates pluing. - Stop() -} - -// Watcher - interface for fully custom monitoring -type Watcher interface { - // Watch method instructs plugin to watch for events based on item configuration in 'requests'. - Watch(requests []*Request, context ContextProvider) -} - -// Configurator - interface for plugin configuration in agent conf files -type Configurator interface { - // Configure method passes global and private plugin configuration after it has been activated. - Configure(globalOptions *GlobalOptions, privateOptions interface{}) - // Validate method validates private plugin configuration during agent startup. - Validate(privateOptions interface{}) error -} - -type ResultWriter interface { - Write(result *Result) - Flush() - SlotsAvailable() int - PersistSlotsAvailable() int -} - -type Meta struct { - lastLogsize uint64 - mtime int32 - Data interface{} -} - -func (m *Meta) SetLastLogsize(value uint64) { - atomic.StoreUint64(&m.lastLogsize, value) -} - -func (m *Meta) LastLogsize() uint64 { - return atomic.LoadUint64(&m.lastLogsize) -} - -func (m *Meta) SetMtime(value int32) { - atomic.StoreInt32(&m.mtime, value) -} - -func (m *Meta) Mtime() int32 { - return atomic.LoadInt32(&m.mtime) -} - -type RegexpMatcher interface { - Match(value string, pattern string, mode int, output_template *string) (match bool, output string) -} - -type ContextProvider interface { - ClientID() uint64 - ItemID() uint64 - Output() ResultWriter - Meta() *Meta - GlobalRegexp() RegexpMatcher -} - -type Result struct { - Itemid uint64 - Value *string - - // additional windows eventlog fields - EventSource *string - EventID *int - EventTimestamp *int - EventSeverity *int - - Ts time.Time - Error error - LastLogsize *uint64 - Mtime *int - Persistent bool -} - -type Request struct { - Itemid uint64 `json:"itemid"` - Key string `json:"key"` - Delay string `json:"delay"` - LastLogsize *uint64 `json:"lastlogsize"` - Mtime *int `json:"mtime"` -} - -// GlobalOptions are global agent configuration parameters that can be accessed by plugins. -// In most cases it's recommended to allow plugins overriding global configuration parameters -// they are using with plugin specific parameters. -type GlobalOptions struct { - Timeout int - SourceIP string -} - -func init() { - UnsupportedMetricError = errors.New("Unsupported item key.") -} diff --git a/src/go/pkg/tls/tls.go b/src/go/pkg/tls/tls.go index 698e3a0fe02..096e5a8f5cf 100644 --- a/src/go/pkg/tls/tls.go +++ b/src/go/pkg/tls/tls.go @@ -933,8 +933,8 @@ import ( "time" "unsafe" - "zabbix.com/pkg/log" - "zabbix.com/pkg/uri" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/uri" ) // TLS initialization diff --git a/src/go/pkg/tlsconfig/tlsconfig.go b/src/go/pkg/tlsconfig/tlsconfig.go index f580183cace..492a920bb4c 100644 --- a/src/go/pkg/tlsconfig/tlsconfig.go +++ b/src/go/pkg/tlsconfig/tlsconfig.go @@ -7,7 +7,7 @@ import ( "fmt" "io/ioutil" - "zabbix.com/pkg/uri" + "git.zabbix.com/ap/plugin-support/uri" ) type Details struct { diff --git a/src/go/pkg/uri/uri.go b/src/go/pkg/uri/uri.go deleted file mode 100644 index 39d8791a18f..00000000000 --- a/src/go/pkg/uri/uri.go +++ /dev/null @@ -1,283 +0,0 @@ -/* -** Zabbix -** Copyright (C) 2001-2022 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - -// Package uri provides a helper for URI validation and parsing -package uri - -import ( - "errors" - "fmt" - "net" - "net/url" - "strconv" - "strings" -) - -type URI struct { - scheme string - host string - port string - rawQuery string - socket string - user string - password string - rawUri string - path string -} - -func (u *URI) Scheme() string { - return u.scheme -} - -func (u *URI) Host() string { - return u.host -} - -func (u *URI) Socket() string { - return u.socket -} - -func (u *URI) Port() string { - return u.port -} - -func (u *URI) Query() string { - return u.rawQuery -} - -func (u *URI) Path() string { - return u.path -} - -func (u *URI) GetParam(key string) string { - params, err := url.ParseQuery(u.rawQuery) - if err != nil { - return "" - } - - return params.Get(key) -} - -func (u *URI) Password() string { - return u.password -} - -func (u *URI) User() string { - return u.user -} - -// Addr combines a host and a port into a network address ("host:port") or returns a socket. -func (u *URI) Addr() string { - if u.socket != "" { - return u.socket - } - - if u.port == "" { - return u.host - } - - return net.JoinHostPort(u.host, u.port) -} - -// String reassembles the URI to a valid URI string. -func (u *URI) String() string { - t := &url.URL{ - Scheme: u.scheme, - RawQuery: u.rawQuery, - } - - if u.socket != "" { - t.Path = u.socket - } else { - if u.port == "" { - t.Host = u.host - } else { - t.Host = net.JoinHostPort(u.host, u.port) - } - } - - if u.user != "" { - if u.password != "" { - t.User = url.UserPassword(u.user, u.password) - } else { - t.User = url.User(u.user) - } - } - - return t.String() -} - -func (u *URI) withCreds(user, password string) *URI { - u.password = password - u.user = user - - return u -} - -type Defaults struct { - Port string - Scheme string -} - -// New parses a given rawUri and returns a new filled URI structure. -// It ignores embedded credentials according to https://www.ietf.org/rfc/rfc3986.txt. -// Use NewWithCreds to add credentials to a structure. -func New(rawUri string, defaults *Defaults) (res *URI, err error) { - var ( - isSocket bool - noScheme bool - port string - ) - - rawUri = strings.TrimSpace(rawUri) - - res = &URI{ - rawUri: rawUri, - } - - // https://tools.ietf.org/html/rfc6874#section-2 - // %25 is allowed to escape a percent sign in IPv6 scoped-address literals - if !strings.Contains(rawUri, "%25") { - rawUri = strings.Replace(rawUri, "%", "%25", -1) - } - - if noScheme = !strings.Contains(rawUri, ":/"); noScheme { - if defaults != nil && defaults.Scheme != "" { - rawUri = defaults.Scheme + "://" + rawUri - } else { - rawUri = "tcp://" + rawUri - } - } - - u, err := url.Parse(rawUri) - if err != nil { - return nil, err - } - - res.scheme = u.Scheme - port = u.Port() - - if port == "" { - if defaults != nil { - port = defaults.Port - } - } - - if port != "" { - if _, err = strconv.ParseUint(port, 10, 16); err != nil { - return nil, errors.New("port must be integer and must be between 0 and 65535") - } - } - - isSocket = res.scheme == "unix" || (noScheme && u.Hostname() == "" && u.Path != "") - if isSocket { - if u.Path == "" { - return nil, errors.New("socket is required") - } - - res.scheme = "unix" - res.socket = u.Path - } else { - if u.Hostname() == "" { - return nil, errors.New("host is required") - } - - res.host = u.Hostname() - res.port = port - res.path = u.Path - } - - res.rawQuery = u.RawQuery - - return res, err -} - -func NewWithCreds(rawUri, user, password string, defaults *Defaults) (res *URI, err error) { - res, err = New(rawUri, defaults) - if err != nil { - return nil, err - } - - return res.withCreds(user, password), nil -} - -type URIValidator struct { - Defaults *Defaults - AllowedSchemes []string -} - -func (v URIValidator) Validate(value *string) error { - if value == nil { - return nil - } - - res, err := New(*value, v.Defaults) - if err != nil { - return err - } - - if v.AllowedSchemes != nil { - for _, s := range v.AllowedSchemes { - if res.Scheme() == s { - return nil - } - } - - return fmt.Errorf("allowed schemes: %s", strings.Join(v.AllowedSchemes, ", ")) - } - - return nil -} - -func IsHostnameOnly(host string) error { - if strings.Contains(host, ":/") { - return fmt.Errorf("must not contain scheme") - } - - uri, err := New(host, &Defaults{Port: "", Scheme: ""}) - if err != nil { - return err - } - - if uri.Port() != "" { - return fmt.Errorf("must not contain port") - } - - if uri.Socket() != "" { - return fmt.Errorf("must not contain socket") - } - - if uri.User() != "" { - return fmt.Errorf("must not contain user") - } - - if uri.Password() != "" { - return fmt.Errorf("must not contain password") - } - - if uri.Query() != "" { - return fmt.Errorf("must not contain query") - } - - if uri.Path() != "" { - return fmt.Errorf("must not contain path") - } - - return nil -} diff --git a/src/go/pkg/uri/uri_test.go b/src/go/pkg/uri/uri_test.go deleted file mode 100644 index 2a0b4775de7..00000000000 --- a/src/go/pkg/uri/uri_test.go +++ /dev/null @@ -1,448 +0,0 @@ -/* -** Zabbix -** Copyright (C) 2001-2022 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - -package uri - -import ( - "reflect" - "testing" -) - -func TestURI_Addr(t *testing.T) { - type fields struct { - scheme string - host string - port string - rawQuery string - socket string - user string - password string - rawUri string - } - tests := []struct { - name string - fields fields - want string - }{ - { - "Should return host:port", - fields{host: "127.0.0.1", port: "8003"}, - "127.0.0.1:8003", - }, - { - "Should return socket", - fields{host: "127.0.0.1", port: "8003", socket: "/var/lib/mysql/mysql.sock"}, - "/var/lib/mysql/mysql.sock", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - u := &URI{ - scheme: tt.fields.scheme, - host: tt.fields.host, - port: tt.fields.port, - rawQuery: tt.fields.rawQuery, - socket: tt.fields.socket, - user: tt.fields.user, - password: tt.fields.password, - rawUri: tt.fields.rawUri, - } - if got := u.Addr(); got != tt.want { - t.Errorf("Addr() = %v, want %v", got, tt.want) - } - }) - } -} - -func TestURI_String(t *testing.T) { - type fields struct { - scheme string - host string - port string - rawQuery string - socket string - user string - password string - rawUri string - } - tests := []struct { - name string - fields fields - want string - }{ - { - "Should return URI with creds. Test 1", - fields{scheme: "https", host: "127.0.0.1", port: "8003", user: "zabbix", - password: "a35c2787-6ab4-4f6b-b538-0fcf91e678ed"}, - "https://zabbix:a35c2787-6ab4-4f6b-b538-0fcf91e678ed@127.0.0.1:8003", - }, - { - "Should return URI with creds. Test 2", - fields{scheme: "unix", socket: "/tmp/redis.sock", user: "zabbix", password: "secret"}, - "unix://zabbix:secret@/tmp/redis.sock", - }, - { - "Should return URI with user only", - fields{scheme: "unix", socket: "/tmp/redis.sock", user: "zabbix"}, - "unix://zabbix@/tmp/redis.sock", - }, - { - "Should return URI with creds containing special characters", - fields{scheme: "https", host: "127.0.0.1", port: "8003", user: "zabbix", - password: `!@#$%^&*()_+{}?|\/., -=_+`}, - "https://zabbix:%21%40%23$%25%5E&%2A%28%29_+%7B%7D%3F%7C%5C%2F.,%20-=_+@127.0.0.1:8003", - }, - { - "Should return URI with username", - fields{scheme: "https", host: "127.0.0.1", port: "8003", user: "zabbix"}, - "https://zabbix@127.0.0.1:8003", - }, - { - "Should return URI without creds", - fields{scheme: "https", host: "127.0.0.1", port: "8003"}, - "https://127.0.0.1:8003", - }, - { - "Should return URI with path", - fields{scheme: "oracle", host: "127.0.0.1", port: "1521", rawQuery: "dbname=XE"}, - "oracle://127.0.0.1:1521?dbname=XE", - }, - { - "Should return URI without port", - fields{scheme: "https", host: "127.0.0.1"}, - "https://127.0.0.1", - }, - { - "Should return URI with socket", - fields{scheme: "unix", socket: "/var/lib/mysql/mysql.sock"}, - "unix:///var/lib/mysql/mysql.sock", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - u := &URI{ - scheme: tt.fields.scheme, - host: tt.fields.host, - port: tt.fields.port, - rawQuery: tt.fields.rawQuery, - socket: tt.fields.socket, - user: tt.fields.user, - password: tt.fields.password, - rawUri: tt.fields.rawUri, - } - if got := u.String(); got != tt.want { - t.Errorf("String() = %v, want %v", got, tt.want) - } - }) - } -} - -var ( - defaults = &Defaults{Scheme: "https", Port: "443"} - defaultsWithoutPort = &Defaults{Scheme: "https"} - defaultsWithoutScheme = &Defaults{Port: "443"} - emptyDefaults = &Defaults{} - invalidDefaults = &Defaults{Port: "99999"} -) - -func TestNew(t *testing.T) { - type args struct { - rawuri string - defaults *Defaults - } - tests := []struct { - name string - args args - wantRes *URI - wantErr bool - }{ - { - "Parse URI with scheme and port, defaults are not set", - args{"http://localhost:80", nil}, - &URI{scheme: "http", host: "localhost", port: "80", rawUri: "http://localhost:80"}, - false, - }, - { - "Parse URI with scheme, path and port, defaults are not set", - args{"http://localhost:80/foo/bar", nil}, - &URI{scheme: "http", host: "localhost", port: "80", rawUri: "http://localhost:80/foo/bar", path: "/foo/bar"}, - false, - }, - { - "Parse URI without scheme and port, defaults are not set", - args{"localhost", nil}, - &URI{scheme: "tcp", host: "localhost", rawUri: "localhost"}, - false, - }, - { - "Parse URI without scheme and port, defaults are empty", - args{"localhost", emptyDefaults}, - &URI{scheme: "tcp", host: "localhost", rawUri: "localhost"}, - false, - }, - { - "Parse URI without scheme and port, defaults are fully set", - args{"localhost", defaults}, - &URI{scheme: "https", host: "localhost", port: "443", rawUri: "localhost"}, - false, - }, - { - "Parse URI without scheme and port, defaults are partly set (only scheme)", - args{"localhost", defaultsWithoutPort}, - &URI{scheme: "https", host: "localhost", rawUri: "localhost"}, - false, - }, - { - "Parse URI without scheme and port, defaults are partly set (only port)", - args{"localhost", defaultsWithoutScheme}, - &URI{scheme: "tcp", host: "localhost", port: "443", rawUri: "localhost"}, - false, - }, - { - "Must fail if defaults are invalid", - args{"localhost", invalidDefaults}, - nil, - true, - }, - { - "Must fail if scheme is omitted", - args{"://localhost", nil}, - nil, - true, - }, - { - "Must fail if host is omitted", - args{"tcp://:1521", nil}, - nil, - true, - }, - { - "Must fail if port is greater than 65535", - args{"tcp://localhost:65536", nil}, - nil, - true, - }, - { - "Must fail if port is not integer", - args{"tcp://:foo", nil}, - nil, - true, - }, - { - "Should fail if URI is invalid", - args{"!@#$%^&*()", nil}, - nil, - true, - }, - { - "Parse URI with query params", - args{"oracle://localhost:1521?dbname=XE", nil}, - &URI{scheme: "oracle", host: "localhost", port: "1521", rawQuery: "dbname=XE", - rawUri: "oracle://localhost:1521?dbname=XE"}, - false, - }, - { - "Parse URI with unix scheme. Test 1", - args{"unix:/var/run/memcached.sock", nil}, - &URI{scheme: "unix", socket: "/var/run/memcached.sock", rawUri: "unix:/var/run/memcached.sock"}, - false, - }, - { - "Parse URI with unix scheme. Test 2", - args{"unix:///var/run/memcached.sock", nil}, - &URI{scheme: "unix", socket: "/var/run/memcached.sock", rawUri: "unix:///var/run/memcached.sock"}, - false, - }, - { - "Parse URI without unix scheme", - args{"/var/run/memcached.sock", nil}, - &URI{scheme: "unix", socket: "/var/run/memcached.sock", rawUri: "/var/run/memcached.sock"}, - false, - }, - { - "Parse socket with query params", - args{"/var/run/memcached.sock?dbname=postgres", nil}, - &URI{scheme: "unix", socket: "/var/run/memcached.sock", - rawQuery: "dbname=postgres", rawUri: "/var/run/memcached.sock?dbname=postgres"}, - false, - }, - { - "Must fail if scheme is wrong", - args{"tcp:///var/run/memcached.sock", nil}, - nil, - true, - }, - { - "Must fail if socket is not specified", - args{"unix://", nil}, - nil, - true, - }, - { - "Parse URI with ipv6 address. Test 1", - args{"tcp://[fe80::1ce7:d24a:97f0:3d83%25en0]:11211", nil}, - &URI{scheme: "tcp", host: "fe80::1ce7:d24a:97f0:3d83%en0", port: "11211", - rawUri: "tcp://[fe80::1ce7:d24a:97f0:3d83%25en0]:11211"}, - false, - }, - { - "Parse URI with ipv6 address. Test 2", - args{"tcp://[fe80::1ce7:d24a:97f0:3d83%en0]:11211", nil}, - &URI{scheme: "tcp", host: "fe80::1ce7:d24a:97f0:3d83%en0", port: "11211", - rawUri: "tcp://[fe80::1ce7:d24a:97f0:3d83%en0]:11211"}, - false, - }, - { - "Parse URI with ipv6 address. Test 3", - args{"tcp://[fe80::1%25lo0]:11211", nil}, - &URI{scheme: "tcp", host: "fe80::1%lo0", port: "11211", rawUri: "tcp://[fe80::1%25lo0]:11211"}, - false, - }, - { - "Parse URI with ipv6 address. Test 4", - args{"https://[::1]", defaults}, - &URI{scheme: "https", host: "::1", port: "443", rawUri: "https://[::1]"}, - false, - }, - { - "Parse URI with ipv6 address. Test 5", - args{"https://[::1]", nil}, - &URI{scheme: "https", host: "::1", rawUri: "https://[::1]"}, - false, - }, - { - "Parse URI with ipv6 address. Test 6", - args{"tcp://fe80::1:11211", nil}, - &URI{scheme: "tcp", host: "fe80::1", port: "11211", rawUri: "tcp://fe80::1:11211"}, - false, - }, - { - "Parse URI with ipv6 address. Test 7", - args{"tcp://::1:11289", nil}, - &URI{scheme: "tcp", host: "::1", port: "11289", rawUri: "tcp://::1:11289"}, - false, - }, - { - "Parse URI with whitespaces", - args{" http://localhost:80 ", nil}, - &URI{scheme: "http", host: "localhost", port: "80", rawUri: "http://localhost:80"}, - false, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - gotRes, err := New(tt.args.rawuri, tt.args.defaults) - if (err != nil) != tt.wantErr { - t.Errorf("New() error = %v, wantErr %v", err, tt.wantErr) - return - } - - if !reflect.DeepEqual(gotRes, tt.wantRes) { - t.Errorf("New() gotRes = %#v, want %#v", gotRes, tt.wantRes) - } - }) - } -} - -var ( - uri = "ssh://localhost:22" - uriWithoutScheme = "localhost:22" - uriOnlyHost = "localhost" -) - -func TestURIValidator_Validate(t *testing.T) { - type fields struct { - Defaults *Defaults - AllowedSchemes []string - } - type args struct { - value *string - } - tests := []struct { - name string - fields fields - args args - wantErr bool - }{ - { - "Validate uri with scheme in specified range", - fields{nil, []string{"ssh"}}, - args{&uri}, - false, - }, - { - "Validate uri, scheme is not limited", - fields{nil, nil}, - args{&uriWithoutScheme}, - false, - }, - { - "Must fail if scheme is out of range", - fields{nil, []string{"ssh"}}, - args{&uriWithoutScheme}, - true, - }, - { - "Must fail if default scheme is out of range", - fields{defaults, []string{"ssh"}}, - args{&uriOnlyHost}, - true, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - v := URIValidator{ - Defaults: tt.fields.Defaults, - AllowedSchemes: tt.fields.AllowedSchemes, - } - if err := v.Validate(tt.args.value); (err != nil) != tt.wantErr { - t.Errorf("Validate() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} - -func TestIsHostnameOnly(t *testing.T) { - type args struct { - host string - } - tests := []struct { - name string - args args - wantErr bool - }{ - {"valid_hostname", args{"example.com"}, false}, - {"valid_hostname_2", args{"www.example.com"}, false}, - {"ip", args{"1.2.3.4"}, false}, - {"full_url", args{"https://www.example.com/foo/bar.tst?foo=example&bar=test"}, true}, - {"scheme_url", args{"https://www.example.com"}, true}, - {"path", args{"www.example.com/foo/bar.tst"}, true}, - {"query", args{"www.example.com?foo=example&bar=test"}, true}, - {"user_and_password", args{"username:password@example.com/"}, true}, - {"port", args{"example.com:443"}, true}, - {"fake_port", args{"example.com:abc"}, true}, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if err := IsHostnameOnly(tt.args.host); (err != nil) != tt.wantErr { - t.Errorf("IsHostnameOnly() error = %v, wantErr %v", err, tt.wantErr) - } - }) - } -} diff --git a/src/go/pkg/watch/manager.go b/src/go/pkg/watch/manager.go index 9f28dad5317..c34342a5b25 100644 --- a/src/go/pkg/watch/manager.go +++ b/src/go/pkg/watch/manager.go @@ -27,7 +27,7 @@ import ( "sync" "time" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) // EventSource generates events by calling Manager.Notify() method and passing arbitrary diff --git a/src/go/pkg/win32/pdh.go b/src/go/pkg/win32/pdh.go index 938249eabea..547d4933634 100644 --- a/src/go/pkg/win32/pdh.go +++ b/src/go/pkg/win32/pdh.go @@ -29,7 +29,7 @@ import ( "time" "unsafe" - "zabbix.com/pkg/log" + "git.zabbix.com/ap/plugin-support/log" "golang.org/x/sys/windows" ) diff --git a/src/go/pkg/wmi/wmi.go b/src/go/pkg/wmi/wmi.go index e8b32e63fcf..86a6ac3d194 100644 --- a/src/go/pkg/wmi/wmi.go +++ b/src/go/pkg/wmi/wmi.go @@ -26,7 +26,7 @@ import ( "github.com/go-ole/go-ole" "github.com/go-ole/go-ole/oleutil" - "zabbix.com/pkg/log" + "git.zabbix.com/ap/plugin-support/log" ) const S_FALSE = 0x1 diff --git a/src/go/pkg/zbxcmd/zbxcmd_nix.go b/src/go/pkg/zbxcmd/zbxcmd_nix.go index addd629406e..bd566fb772a 100644 --- a/src/go/pkg/zbxcmd/zbxcmd_nix.go +++ b/src/go/pkg/zbxcmd/zbxcmd_nix.go @@ -31,7 +31,7 @@ import ( "syscall" "time" - "zabbix.com/pkg/log" + "git.zabbix.com/ap/plugin-support/log" ) func execute(s string, timeout time.Duration, path string, strict bool) (string, error) { diff --git a/src/go/pkg/zbxcmd/zbxcmd_windows.go b/src/go/pkg/zbxcmd/zbxcmd_windows.go index f13ac4d2ea7..9f55b19e29a 100644 --- a/src/go/pkg/zbxcmd/zbxcmd_windows.go +++ b/src/go/pkg/zbxcmd/zbxcmd_windows.go @@ -28,7 +28,7 @@ import ( "time" "unsafe" - "zabbix.com/pkg/log" + "git.zabbix.com/ap/plugin-support/log" "golang.org/x/sys/windows" ) diff --git a/src/go/pkg/zbxcomms/comms.go b/src/go/pkg/zbxcomms/comms.go index ab9cee74d92..1584e38bb97 100644 --- a/src/go/pkg/zbxcomms/comms.go +++ b/src/go/pkg/zbxcomms/comms.go @@ -29,7 +29,7 @@ import ( "net" "time" - "zabbix.com/pkg/log" + "git.zabbix.com/ap/plugin-support/log" "zabbix.com/pkg/tls" ) diff --git a/src/go/pkg/zbxerr/zbxerr.go b/src/go/pkg/zbxerr/zbxerr.go deleted file mode 100644 index a704400d5e8..00000000000 --- a/src/go/pkg/zbxerr/zbxerr.go +++ /dev/null @@ -1,101 +0,0 @@ -/* -** Zabbix -** Copyright (C) 2001-2022 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - -package zbxerr - -import ( - "errors" - "unicode" -) - -type ZabbixError struct { - err error - cause error -} - -// New creates a new ZabbixError -func New(msg string) ZabbixError { - return ZabbixError{errors.New(msg), nil} -} - -// Wrap creates a new ZabbixError with wrapped cause -func (e ZabbixError) Wrap(cause error) error { - return ZabbixError{err: e, cause: cause} -} - -// Unwrap extracts an original underlying error -func (e ZabbixError) Unwrap() error { - return e.err -} - -// Cause returns a cause of original error -func (e ZabbixError) Cause() error { - return e.cause -} - -// Error stringifies an error according to Zabbix requirements: -// * the first letter must be capitalized; -// * an error text should be trailed by a dot. -func (e ZabbixError) Error() string { - var msg string - - ucFirst := func(str string) string { - for i, v := range str { - return string(unicode.ToUpper(v)) + str[i+1:] - } - - return "" - } - - if zbxErr, ok := e.err.(ZabbixError); ok { - msg = zbxErr.Raw() - } else { - msg = e.err.Error() - } - - if e.cause != nil { - msg += ": " + e.cause.Error() - } - - if msg[len(msg)-1:] != "." { - msg += "." - } - - return ucFirst(msg) -} - -// Raw returns a non-modified error message -func (e ZabbixError) Raw() string { - return e.err.Error() -} - -var ( - ErrorInvalidParams = New("invalid parameters") - ErrorTooFewParameters = New("too few parameters") - ErrorTooManyParameters = New("too many parameters") - ErrorInvalidConfiguration = New("invalid configuration") - ErrorCannotFetchData = New("cannot fetch data") - ErrorCannotUnmarshalJSON = New("cannot unmarshal JSON") - ErrorCannotMarshalJSON = New("cannot marshal JSON") - ErrorCannotParseResult = New("cannot parse result") - ErrorConnectionFailed = New("connection failed") - ErrorUnsupportedMetric = New("unsupported metric") - ErrorEmptyResult = New("empty result") - ErrorUnknownSession = New("unknown session") -) diff --git a/src/go/pkg/zbxerr/zbxerr_test.go b/src/go/pkg/zbxerr/zbxerr_test.go deleted file mode 100644 index 9a7b9a5a3fc..00000000000 --- a/src/go/pkg/zbxerr/zbxerr_test.go +++ /dev/null @@ -1,208 +0,0 @@ -/* -** Zabbix -** Copyright (C) 2001-2022 Zabbix SIA -** -** This program is free software; you can redistribute it and/or modify -** it under the terms of the GNU General Public License as published by -** the Free Software Foundation; either version 2 of the License, or -** (at your option) any later version. -** -** This program is distributed in the hope that it will be useful, -** but WITHOUT ANY WARRANTY; without even the implied warranty of -** MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the -** GNU General Public License for more details. -** -** You should have received a copy of the GNU General Public License -** along with this program; if not, write to the Free Software -** Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. -**/ - -package zbxerr - -import ( - "errors" - "reflect" - "testing" -) - -var ( - errorFooBar = errors.New("foo bar") - errorFoo = errors.New("foo") - errorBar = errors.New("bar") -) - -func TestNew(t *testing.T) { - type args struct { - msg string - } - tests := []struct { - name string - args args - want ZabbixError - }{ - { - "New must create a new ZabbixError with a corresponding message", - args{"foo"}, - ZabbixError{errorFoo, nil}, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := New(tt.args.msg); !reflect.DeepEqual(got, tt.want) { - t.Errorf("New() = %v, want %v", got, tt.want) - } - }) - } -} - -func TestZabbixError_Cause(t *testing.T) { - type fields struct { - err error - cause error - } - tests := []struct { - name string - fields fields - want error - }{ - { - "Cause must return a cause of original error", - fields{errorFoo, errorBar}, - errorBar, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - e := ZabbixError{ - err: tt.fields.err, - cause: tt.fields.cause, - } - if got := e.Cause(); got != tt.want { - t.Errorf("Cause() = %v, want %v", got, tt.want) - } - }) - } -} - -func TestZabbixError_Error(t *testing.T) { - tests := []struct { - name string - e ZabbixError - want string - }{ - { - "ZabbixError stringify", - ZabbixError{errorFooBar, nil}, - "Foo bar.", - }, - { - "ZabbixError stringify with wrapping", - ZabbixError{errorFoo, errorBar}, - "Foo: bar.", - }, - { - "ZabbixError stringify with wrapped ZabbixError", - ZabbixError{ZabbixError{errorFoo, nil}, errorBar}, - "Foo: bar.", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - if got := tt.e.Error(); got != tt.want { - t.Errorf("Error() = %v, want %v", got, tt.want) - } - }) - } -} - -func TestZabbixError_Raw(t *testing.T) { - type fields struct { - err error - cause error - } - tests := []struct { - name string - fields fields - want string - }{ - { - "Raw must return a non-modified error message", - fields{errorFoo, nil}, - "foo", - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - e := ZabbixError{ - err: tt.fields.err, - cause: tt.fields.cause, - } - if got := e.Raw(); got != tt.want { - t.Errorf("Raw() = %v, want %v", got, tt.want) - } - }) - } -} - -func TestZabbixError_Unwrap(t *testing.T) { - type fields struct { - err error - cause error - } - tests := []struct { - name string - fields fields - want error - }{ - { - "Unwrap must return an original underlying error", - fields{errorFoo, nil}, - errorFoo, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - e := ZabbixError{ - err: tt.fields.err, - cause: tt.fields.cause, - } - if got := e.Unwrap(); got != tt.want { - t.Errorf("Unwrap() = %v, want %v", got, tt.want) - } - }) - } -} - -func TestZabbixError_Wrap(t *testing.T) { - type fields struct { - err error - cause error - } - type args struct { - cause error - } - tests := []struct { - name string - fields fields - args args - want error - }{ - { - "Wrap must return a new ZabbixError with wrapped cause", - fields{errorFoo, nil}, - args{errorBar}, - ZabbixError{ZabbixError{errorFoo, nil}, errorBar}, - }, - } - for _, tt := range tests { - t.Run(tt.name, func(t *testing.T) { - e := ZabbixError{ - err: tt.fields.err, - cause: tt.fields.cause, - } - if got := e.Wrap(tt.args.cause); got != tt.want { - t.Errorf("Wrap() = %v, want %v", got, tt.want) - } - }) - } -} diff --git a/src/go/pkg/zbxlib/logger.go b/src/go/pkg/zbxlib/logger.go index 09b30ef5126..326df6f428c 100644 --- a/src/go/pkg/zbxlib/logger.go +++ b/src/go/pkg/zbxlib/logger.go @@ -22,7 +22,7 @@ package zbxlib import ( "C" ) -import "zabbix.com/pkg/log" +import "git.zabbix.com/ap/plugin-support/log" const c_info = 127 diff --git a/src/go/plugins/ceph/ceph.go b/src/go/plugins/ceph/ceph.go index 0a2bfbae0cc..226ef6c657c 100644 --- a/src/go/plugins/ceph/ceph.go +++ b/src/go/plugins/ceph/ceph.go @@ -25,9 +25,9 @@ import ( "net/http" "time" - "zabbix.com/pkg/uri" + "git.zabbix.com/ap/plugin-support/uri" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) const pluginName = "Ceph" diff --git a/src/go/plugins/ceph/config.go b/src/go/plugins/ceph/config.go index 3efe75d845d..3f5926207c3 100644 --- a/src/go/plugins/ceph/config.go +++ b/src/go/plugins/ceph/config.go @@ -20,8 +20,8 @@ package ceph import ( - "zabbix.com/pkg/conf" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/plugin" ) type Session struct { diff --git a/src/go/plugins/ceph/handler_df.go b/src/go/plugins/ceph/handler_df.go index 54f5bbe6f54..29e3f124438 100644 --- a/src/go/plugins/ceph/handler_df.go +++ b/src/go/plugins/ceph/handler_df.go @@ -23,7 +23,7 @@ import ( "encoding/json" "math" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) type cephDf struct { diff --git a/src/go/plugins/ceph/handler_discovery.go b/src/go/plugins/ceph/handler_discovery.go index e7e28c8e766..cfa019ca818 100644 --- a/src/go/plugins/ceph/handler_discovery.go +++ b/src/go/plugins/ceph/handler_discovery.go @@ -24,7 +24,7 @@ import ( "fmt" "strconv" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) type node struct { diff --git a/src/go/plugins/ceph/handler_osd.go b/src/go/plugins/ceph/handler_osd.go index 79c1bef7eea..f61d1b3e376 100644 --- a/src/go/plugins/ceph/handler_osd.go +++ b/src/go/plugins/ceph/handler_osd.go @@ -24,7 +24,7 @@ import ( "math" "sort" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) type aggDataInt struct { diff --git a/src/go/plugins/ceph/handler_osd_dump.go b/src/go/plugins/ceph/handler_osd_dump.go index 22af13604c6..e7fc19d0f70 100644 --- a/src/go/plugins/ceph/handler_osd_dump.go +++ b/src/go/plugins/ceph/handler_osd_dump.go @@ -23,7 +23,7 @@ import ( "encoding/json" "math" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) type cephOsdDump struct { diff --git a/src/go/plugins/ceph/handler_status.go b/src/go/plugins/ceph/handler_status.go index 04a08ecb0ce..b3ed9b1316f 100644 --- a/src/go/plugins/ceph/handler_status.go +++ b/src/go/plugins/ceph/handler_status.go @@ -24,7 +24,7 @@ import ( "fmt" "strings" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) type cephStatus struct { diff --git a/src/go/plugins/ceph/metrics.go b/src/go/plugins/ceph/metrics.go index c672ecc6c0a..683f824e81c 100644 --- a/src/go/plugins/ceph/metrics.go +++ b/src/go/plugins/ceph/metrics.go @@ -20,9 +20,9 @@ package ceph import ( - "zabbix.com/pkg/metric" - "zabbix.com/pkg/plugin" - "zabbix.com/pkg/uri" + "git.zabbix.com/ap/plugin-support/metric" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/uri" ) type command string diff --git a/src/go/plugins/ceph/request.go b/src/go/plugins/ceph/request.go index efb5436fe8a..577f1cf1c94 100644 --- a/src/go/plugins/ceph/request.go +++ b/src/go/plugins/ceph/request.go @@ -25,8 +25,8 @@ import ( "encoding/json" "net/http" - "zabbix.com/pkg/log" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/zbxerr" ) type cephResponse struct { diff --git a/src/go/plugins/debug/collector/collector.go b/src/go/plugins/debug/collector/collector.go index c2f3540b1fd..bec50ed61f3 100644 --- a/src/go/plugins/debug/collector/collector.go +++ b/src/go/plugins/debug/collector/collector.go @@ -20,8 +20,8 @@ package empty import ( - "zabbix.com/pkg/conf" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/plugin" ) type Options struct { diff --git a/src/go/plugins/debug/empty/empty.go b/src/go/plugins/debug/empty/empty.go index 45ee99b7397..806ebd7bb81 100644 --- a/src/go/plugins/debug/empty/empty.go +++ b/src/go/plugins/debug/empty/empty.go @@ -20,7 +20,7 @@ package empty import ( - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) // Plugin - diff --git a/src/go/plugins/debug/external/full/full.go b/src/go/plugins/debug/external/full/full.go index b5eb06d198b..6bdcff7bc49 100644 --- a/src/go/plugins/debug/external/full/full.go +++ b/src/go/plugins/debug/external/full/full.go @@ -23,8 +23,8 @@ import ( "fmt" "strings" - "zabbix.com/pkg/conf" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/plugin" ) type Options struct { diff --git a/src/go/plugins/debug/external/full/main.go b/src/go/plugins/debug/external/full/main.go index 532ac4bc716..feb71460333 100644 --- a/src/go/plugins/debug/external/full/main.go +++ b/src/go/plugins/debug/external/full/main.go @@ -22,7 +22,7 @@ package main import ( "fmt" - "zabbix.com/pkg/plugin/container" + "git.zabbix.com/ap/plugin-support/plugin/container" ) func main() { diff --git a/src/go/plugins/debug/external/multikey/main.go b/src/go/plugins/debug/external/multikey/main.go index 532ac4bc716..feb71460333 100644 --- a/src/go/plugins/debug/external/multikey/main.go +++ b/src/go/plugins/debug/external/multikey/main.go @@ -22,7 +22,7 @@ package main import ( "fmt" - "zabbix.com/pkg/plugin/container" + "git.zabbix.com/ap/plugin-support/plugin/container" ) func main() { diff --git a/src/go/plugins/debug/external/multikey/multikey.go b/src/go/plugins/debug/external/multikey/multikey.go index 6ef29625d7d..b60c2dd75ff 100644 --- a/src/go/plugins/debug/external/multikey/multikey.go +++ b/src/go/plugins/debug/external/multikey/multikey.go @@ -22,7 +22,7 @@ package main import ( "errors" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) // Plugin - diff --git a/src/go/plugins/debug/external/test/main.go b/src/go/plugins/debug/external/test/main.go index 158c675258b..4aa79a43433 100644 --- a/src/go/plugins/debug/external/test/main.go +++ b/src/go/plugins/debug/external/test/main.go @@ -22,7 +22,7 @@ package main import ( "fmt" - "zabbix.com/pkg/plugin/container" + "git.zabbix.com/ap/plugin-support/plugin/container" ) func main() { diff --git a/src/go/plugins/debug/external/test/test.go b/src/go/plugins/debug/external/test/test.go index a31f30ecd62..ef5613cb935 100644 --- a/src/go/plugins/debug/external/test/test.go +++ b/src/go/plugins/debug/external/test/test.go @@ -20,7 +20,7 @@ package main import ( - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) // Plugin - diff --git a/src/go/plugins/debug/filewatcher/filewatcher.go b/src/go/plugins/debug/filewatcher/filewatcher.go index cd5a3e9c0c8..92223adc0b1 100644 --- a/src/go/plugins/debug/filewatcher/filewatcher.go +++ b/src/go/plugins/debug/filewatcher/filewatcher.go @@ -23,8 +23,8 @@ import ( "fmt" "io/ioutil" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/pkg/itemutil" - "zabbix.com/pkg/plugin" "zabbix.com/pkg/watch" "github.com/fsnotify/fsnotify" diff --git a/src/go/plugins/debug/log/log.go b/src/go/plugins/debug/log/log.go index 1f021cafad2..01c9e45321a 100644 --- a/src/go/plugins/debug/log/log.go +++ b/src/go/plugins/debug/log/log.go @@ -22,7 +22,7 @@ package log import ( "time" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) // Plugin - diff --git a/src/go/plugins/debug/trapper/trapper.go b/src/go/plugins/debug/trapper/trapper.go index 50f7ada187a..3fc0d627f9f 100644 --- a/src/go/plugins/debug/trapper/trapper.go +++ b/src/go/plugins/debug/trapper/trapper.go @@ -27,9 +27,9 @@ import ( "regexp" "strconv" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/pkg/itemutil" - "zabbix.com/pkg/log" - "zabbix.com/pkg/plugin" "zabbix.com/pkg/watch" ) diff --git a/src/go/plugins/docker/client.go b/src/go/plugins/docker/client.go index bc2b93fd43e..f4cd5e171f4 100644 --- a/src/go/plugins/docker/client.go +++ b/src/go/plugins/docker/client.go @@ -28,7 +28,7 @@ import ( "path" "time" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) type client struct { diff --git a/src/go/plugins/docker/config.go b/src/go/plugins/docker/config.go index 814f4c5712c..101684612fb 100644 --- a/src/go/plugins/docker/config.go +++ b/src/go/plugins/docker/config.go @@ -23,8 +23,8 @@ import ( "errors" "strings" - "zabbix.com/pkg/conf" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/plugin" ) // Options is a plugin configuration diff --git a/src/go/plugins/docker/discovery.go b/src/go/plugins/docker/discovery.go index 01e7ac8bf33..2f53a7210b5 100644 --- a/src/go/plugins/docker/discovery.go +++ b/src/go/plugins/docker/discovery.go @@ -22,7 +22,7 @@ package docker import ( "encoding/json" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) type containerDiscovery struct { diff --git a/src/go/plugins/docker/docker.go b/src/go/plugins/docker/docker.go index c16de4eee4b..c6b15b6c154 100644 --- a/src/go/plugins/docker/docker.go +++ b/src/go/plugins/docker/docker.go @@ -23,9 +23,9 @@ import ( "encoding/json" "fmt" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) const ( diff --git a/src/go/plugins/docker/metrics.go b/src/go/plugins/docker/metrics.go index cb10f086f6c..07f2b4a1ba6 100644 --- a/src/go/plugins/docker/metrics.go +++ b/src/go/plugins/docker/metrics.go @@ -20,8 +20,8 @@ package docker import ( - "zabbix.com/pkg/metric" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/metric" + "git.zabbix.com/ap/plugin-support/plugin" ) type metricMeta struct { diff --git a/src/go/plugins/external/broker.go b/src/go/plugins/external/broker.go index 6e344c969db..ecf6f463365 100644 --- a/src/go/plugins/external/broker.go +++ b/src/go/plugins/external/broker.go @@ -26,10 +26,10 @@ import ( "net" "time" - "zabbix.com/pkg/conf" - "zabbix.com/pkg/log" - "zabbix.com/pkg/plugin" - "zabbix.com/pkg/plugin/comms" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/plugin/comms" ) const queSize = 100 diff --git a/src/go/plugins/external/plugin.go b/src/go/plugins/external/plugin.go index 6e260eb601d..62ff260e8be 100644 --- a/src/go/plugins/external/plugin.go +++ b/src/go/plugins/external/plugin.go @@ -28,8 +28,8 @@ import ( "sync" "time" - "zabbix.com/pkg/plugin" - "zabbix.com/pkg/plugin/comms" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/plugin/comms" ) var startLock sync.Mutex diff --git a/src/go/plugins/kernel/kernel.go b/src/go/plugins/kernel/kernel.go index 93056d72d08..89e66383c42 100644 --- a/src/go/plugins/kernel/kernel.go +++ b/src/go/plugins/kernel/kernel.go @@ -20,9 +20,9 @@ package kernel import ( - "zabbix.com/pkg/plugin" - "zabbix.com/pkg/std" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/std" + "git.zabbix.com/ap/plugin-support/zbxerr" ) // Plugin - diff --git a/src/go/plugins/kernel/kernel_test.go b/src/go/plugins/kernel/kernel_test.go index 324f24fb9fa..72a9a4a21cb 100644 --- a/src/go/plugins/kernel/kernel_test.go +++ b/src/go/plugins/kernel/kernel_test.go @@ -27,7 +27,7 @@ import ( "reflect" "testing" - "zabbix.com/pkg/std" + "git.zabbix.com/ap/plugin-support/std" ) var testSets = []testSet{ diff --git a/src/go/plugins/log/log.go b/src/go/plugins/log/log.go index b93bd09f44b..1f73e2396fb 100644 --- a/src/go/plugins/log/log.go +++ b/src/go/plugins/log/log.go @@ -25,11 +25,11 @@ import ( "time" "unsafe" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/internal/agent" - "zabbix.com/pkg/conf" "zabbix.com/pkg/glexpr" "zabbix.com/pkg/itemutil" - "zabbix.com/pkg/plugin" "zabbix.com/pkg/zbxlib" ) diff --git a/src/go/plugins/memcached/config.go b/src/go/plugins/memcached/config.go index b3d5b64b610..4996f6bcbab 100644 --- a/src/go/plugins/memcached/config.go +++ b/src/go/plugins/memcached/config.go @@ -22,8 +22,8 @@ package memcached import ( "fmt" - "zabbix.com/pkg/conf" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/plugin" ) type PluginOptions struct { diff --git a/src/go/plugins/memcached/conn.go b/src/go/plugins/memcached/conn.go index 90eb8065c49..e4e3bd82d42 100644 --- a/src/go/plugins/memcached/conn.go +++ b/src/go/plugins/memcached/conn.go @@ -24,11 +24,11 @@ import ( "sync" "time" - "zabbix.com/pkg/uri" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/uri" + "git.zabbix.com/ap/plugin-support/zbxerr" + "git.zabbix.com/ap/plugin-support/log" "github.com/memcachier/mc/v3" - "zabbix.com/pkg/log" ) const poolSize = 1 diff --git a/src/go/plugins/memcached/conn_test.go b/src/go/plugins/memcached/conn_test.go index da9f6adaff1..e648879e5f5 100644 --- a/src/go/plugins/memcached/conn_test.go +++ b/src/go/plugins/memcached/conn_test.go @@ -24,7 +24,7 @@ import ( "testing" "time" - "zabbix.com/pkg/uri" + "git.zabbix.com/ap/plugin-support/uri" ) func TestConnManager_closeUnused(t *testing.T) { diff --git a/src/go/plugins/memcached/handler_stats.go b/src/go/plugins/memcached/handler_stats.go index b149c6f1c48..2d0ceb181e9 100644 --- a/src/go/plugins/memcached/handler_stats.go +++ b/src/go/plugins/memcached/handler_stats.go @@ -22,7 +22,7 @@ package memcached import ( "encoding/json" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) const ( diff --git a/src/go/plugins/memcached/handler_stats_test.go b/src/go/plugins/memcached/handler_stats_test.go index 5ff42a83b59..b1792237248 100644 --- a/src/go/plugins/memcached/handler_stats_test.go +++ b/src/go/plugins/memcached/handler_stats_test.go @@ -24,7 +24,7 @@ import ( "reflect" "testing" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/memcachier/mc/v3" ) diff --git a/src/go/plugins/memcached/memcached.go b/src/go/plugins/memcached/memcached.go index 8bf4f80db38..cfed5aebeea 100644 --- a/src/go/plugins/memcached/memcached.go +++ b/src/go/plugins/memcached/memcached.go @@ -23,10 +23,10 @@ import ( "fmt" "time" - "zabbix.com/pkg/uri" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/uri" + "git.zabbix.com/ap/plugin-support/zbxerr" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) const pluginName = "Memcached" diff --git a/src/go/plugins/memcached/memcached_test.go b/src/go/plugins/memcached/memcached_test.go index b9ec219b96f..8f535be23d5 100644 --- a/src/go/plugins/memcached/memcached_test.go +++ b/src/go/plugins/memcached/memcached_test.go @@ -26,9 +26,9 @@ import ( "testing" "time" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/plugins/memcached/mockserver" ) diff --git a/src/go/plugins/memcached/metrics.go b/src/go/plugins/memcached/metrics.go index ba1abc7f00f..339b65bd0c4 100644 --- a/src/go/plugins/memcached/metrics.go +++ b/src/go/plugins/memcached/metrics.go @@ -20,9 +20,9 @@ package memcached import ( - "zabbix.com/pkg/metric" - "zabbix.com/pkg/plugin" - "zabbix.com/pkg/uri" + "git.zabbix.com/ap/plugin-support/metric" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/uri" ) // handlerFunc defines an interface must be implemented by handlers. diff --git a/src/go/plugins/modbus/modbus.go b/src/go/plugins/modbus/modbus.go index 58dcd153c06..13909154346 100644 --- a/src/go/plugins/modbus/modbus.go +++ b/src/go/plugins/modbus/modbus.go @@ -31,11 +31,11 @@ import ( "encoding/binary" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/plugin" named "github.com/BurntSushi/locker" "github.com/goburrow/modbus" mblib "github.com/goburrow/modbus" - "zabbix.com/pkg/conf" - "zabbix.com/pkg/plugin" ) // Plugin - diff --git a/src/go/plugins/mongodb/config.go b/src/go/plugins/mongodb/config.go index 3be5421665d..dbba4c6411c 100644 --- a/src/go/plugins/mongodb/config.go +++ b/src/go/plugins/mongodb/config.go @@ -20,8 +20,8 @@ package mongodb import ( - "zabbix.com/pkg/conf" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/plugin" ) type PluginOptions struct { diff --git a/src/go/plugins/mongodb/conn.go b/src/go/plugins/mongodb/conn.go index 403cfdecb35..1e9d787d02f 100644 --- a/src/go/plugins/mongodb/conn.go +++ b/src/go/plugins/mongodb/conn.go @@ -26,9 +26,9 @@ import ( "gopkg.in/mgo.v2/bson" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/uri" "gopkg.in/mgo.v2" - "zabbix.com/pkg/log" - "zabbix.com/pkg/uri" ) type MongoConn struct { diff --git a/src/go/plugins/mongodb/handler_collection_stats.go b/src/go/plugins/mongodb/handler_collection_stats.go index 0d65094ad2f..e1091fb48a5 100644 --- a/src/go/plugins/mongodb/handler_collection_stats.go +++ b/src/go/plugins/mongodb/handler_collection_stats.go @@ -22,8 +22,8 @@ package mongodb import ( "encoding/json" + "git.zabbix.com/ap/plugin-support/zbxerr" "gopkg.in/mgo.v2/bson" - "zabbix.com/pkg/zbxerr" ) // collectionStatsHandler diff --git a/src/go/plugins/mongodb/handler_collection_stats_test.go b/src/go/plugins/mongodb/handler_collection_stats_test.go index 5aeaca5ac3f..f8792ec776b 100644 --- a/src/go/plugins/mongodb/handler_collection_stats_test.go +++ b/src/go/plugins/mongodb/handler_collection_stats_test.go @@ -9,8 +9,8 @@ import ( "strings" "testing" + "git.zabbix.com/ap/plugin-support/zbxerr" "gopkg.in/mgo.v2/bson" - "zabbix.com/pkg/zbxerr" ) func Test_collectionStatsHandler(t *testing.T) { diff --git a/src/go/plugins/mongodb/handler_collections_discovery.go b/src/go/plugins/mongodb/handler_collections_discovery.go index 3fcc8d0c36b..eccc7f59689 100644 --- a/src/go/plugins/mongodb/handler_collections_discovery.go +++ b/src/go/plugins/mongodb/handler_collections_discovery.go @@ -23,7 +23,7 @@ import ( "encoding/json" "sort" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) type colEntity struct { diff --git a/src/go/plugins/mongodb/handler_collections_discovery_test.go b/src/go/plugins/mongodb/handler_collections_discovery_test.go index 029451ccea5..5f00491a087 100644 --- a/src/go/plugins/mongodb/handler_collections_discovery_test.go +++ b/src/go/plugins/mongodb/handler_collections_discovery_test.go @@ -5,7 +5,7 @@ import ( "reflect" "testing" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func Test_collectionsDiscoveryHandler(t *testing.T) { diff --git a/src/go/plugins/mongodb/handler_collections_usage.go b/src/go/plugins/mongodb/handler_collections_usage.go index 9b1dc6a4e45..825a660c2ea 100644 --- a/src/go/plugins/mongodb/handler_collections_usage.go +++ b/src/go/plugins/mongodb/handler_collections_usage.go @@ -22,8 +22,8 @@ package mongodb import ( "encoding/json" + "git.zabbix.com/ap/plugin-support/zbxerr" "gopkg.in/mgo.v2/bson" - "zabbix.com/pkg/zbxerr" ) // collectionsUsageHandler diff --git a/src/go/plugins/mongodb/handler_config_discovery.go b/src/go/plugins/mongodb/handler_config_discovery.go index fc6e033a7cc..616ed2eca5d 100644 --- a/src/go/plugins/mongodb/handler_config_discovery.go +++ b/src/go/plugins/mongodb/handler_config_discovery.go @@ -25,8 +25,8 @@ import ( "net" "strings" + "git.zabbix.com/ap/plugin-support/zbxerr" "gopkg.in/mgo.v2/bson" - "zabbix.com/pkg/zbxerr" ) type lldCfgEntity struct { diff --git a/src/go/plugins/mongodb/handler_connPool_stats.go b/src/go/plugins/mongodb/handler_connPool_stats.go index 0ffcca08c5a..64e7a4393e6 100644 --- a/src/go/plugins/mongodb/handler_connPool_stats.go +++ b/src/go/plugins/mongodb/handler_connPool_stats.go @@ -22,8 +22,8 @@ package mongodb import ( "encoding/json" + "git.zabbix.com/ap/plugin-support/zbxerr" "gopkg.in/mgo.v2/bson" - "zabbix.com/pkg/zbxerr" ) // connPoolStatsHandler diff --git a/src/go/plugins/mongodb/handler_connPool_stats_test.go b/src/go/plugins/mongodb/handler_connPool_stats_test.go index 0b819e040de..abe88dae2cb 100644 --- a/src/go/plugins/mongodb/handler_connPool_stats_test.go +++ b/src/go/plugins/mongodb/handler_connPool_stats_test.go @@ -9,8 +9,8 @@ import ( "strings" "testing" + "git.zabbix.com/ap/plugin-support/zbxerr" "gopkg.in/mgo.v2/bson" - "zabbix.com/pkg/zbxerr" ) func Test_connPoolStatsHandler(t *testing.T) { diff --git a/src/go/plugins/mongodb/handler_database_stats.go b/src/go/plugins/mongodb/handler_database_stats.go index 9ad277fc358..7d7e3e8a5fd 100644 --- a/src/go/plugins/mongodb/handler_database_stats.go +++ b/src/go/plugins/mongodb/handler_database_stats.go @@ -22,8 +22,8 @@ package mongodb import ( "encoding/json" + "git.zabbix.com/ap/plugin-support/zbxerr" "gopkg.in/mgo.v2/bson" - "zabbix.com/pkg/zbxerr" ) // databaseStatsHandler diff --git a/src/go/plugins/mongodb/handler_database_stats_test.go b/src/go/plugins/mongodb/handler_database_stats_test.go index 38d752bd35d..7a441ee3412 100644 --- a/src/go/plugins/mongodb/handler_database_stats_test.go +++ b/src/go/plugins/mongodb/handler_database_stats_test.go @@ -9,8 +9,8 @@ import ( "strings" "testing" + "git.zabbix.com/ap/plugin-support/zbxerr" "gopkg.in/mgo.v2/bson" - "zabbix.com/pkg/zbxerr" ) func Test_databaseStatsHandler(t *testing.T) { diff --git a/src/go/plugins/mongodb/handler_databases_discovery.go b/src/go/plugins/mongodb/handler_databases_discovery.go index 96cf82f4578..b556930e0e5 100644 --- a/src/go/plugins/mongodb/handler_databases_discovery.go +++ b/src/go/plugins/mongodb/handler_databases_discovery.go @@ -23,7 +23,7 @@ import ( "encoding/json" "sort" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) type dbEntity struct { diff --git a/src/go/plugins/mongodb/handler_databases_discovery_test.go b/src/go/plugins/mongodb/handler_databases_discovery_test.go index 5eed8622bf8..803fba298d5 100644 --- a/src/go/plugins/mongodb/handler_databases_discovery_test.go +++ b/src/go/plugins/mongodb/handler_databases_discovery_test.go @@ -5,7 +5,7 @@ import ( "reflect" "testing" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func Test_databasesDiscoveryHandler(t *testing.T) { diff --git a/src/go/plugins/mongodb/handler_jumbo_chunks.go b/src/go/plugins/mongodb/handler_jumbo_chunks.go index fc818657533..4860133d2d4 100644 --- a/src/go/plugins/mongodb/handler_jumbo_chunks.go +++ b/src/go/plugins/mongodb/handler_jumbo_chunks.go @@ -20,8 +20,8 @@ package mongodb import ( + "git.zabbix.com/ap/plugin-support/zbxerr" "gopkg.in/mgo.v2/bson" - "zabbix.com/pkg/zbxerr" ) // jumboChunksHandler diff --git a/src/go/plugins/mongodb/handler_oplog_stats.go b/src/go/plugins/mongodb/handler_oplog_stats.go index 835e8a29e42..6bf7d250b1e 100644 --- a/src/go/plugins/mongodb/handler_oplog_stats.go +++ b/src/go/plugins/mongodb/handler_oplog_stats.go @@ -23,9 +23,9 @@ import ( "encoding/json" "time" + "git.zabbix.com/ap/plugin-support/zbxerr" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" - "zabbix.com/pkg/zbxerr" ) type oplogStats struct { diff --git a/src/go/plugins/mongodb/handler_replset_config.go b/src/go/plugins/mongodb/handler_replset_config.go index cd693260f3e..6eb4c56396d 100644 --- a/src/go/plugins/mongodb/handler_replset_config.go +++ b/src/go/plugins/mongodb/handler_replset_config.go @@ -22,8 +22,8 @@ package mongodb import ( "encoding/json" + "git.zabbix.com/ap/plugin-support/zbxerr" "gopkg.in/mgo.v2/bson" - "zabbix.com/pkg/zbxerr" ) // replSetConfigHandler diff --git a/src/go/plugins/mongodb/handler_replset_status.go b/src/go/plugins/mongodb/handler_replset_status.go index 0ba46216e0b..889d0183a6b 100644 --- a/src/go/plugins/mongodb/handler_replset_status.go +++ b/src/go/plugins/mongodb/handler_replset_status.go @@ -24,8 +24,8 @@ import ( "errors" "strings" + "git.zabbix.com/ap/plugin-support/zbxerr" "gopkg.in/mgo.v2/bson" - "zabbix.com/pkg/zbxerr" ) const ( diff --git a/src/go/plugins/mongodb/handler_server_status.go b/src/go/plugins/mongodb/handler_server_status.go index edf19661445..f5ee02dd4a9 100644 --- a/src/go/plugins/mongodb/handler_server_status.go +++ b/src/go/plugins/mongodb/handler_server_status.go @@ -22,8 +22,8 @@ package mongodb import ( "encoding/json" + "git.zabbix.com/ap/plugin-support/zbxerr" "gopkg.in/mgo.v2/bson" - "zabbix.com/pkg/zbxerr" ) // serverStatusHandler diff --git a/src/go/plugins/mongodb/handler_shards_discovery.go b/src/go/plugins/mongodb/handler_shards_discovery.go index 3278452bef1..d8cb1f1c3f0 100644 --- a/src/go/plugins/mongodb/handler_shards_discovery.go +++ b/src/go/plugins/mongodb/handler_shards_discovery.go @@ -26,7 +26,7 @@ import ( "strings" "time" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) type lldShEntity struct { diff --git a/src/go/plugins/mongodb/metrics.go b/src/go/plugins/mongodb/metrics.go index 5a92374cad8..9767eac9996 100644 --- a/src/go/plugins/mongodb/metrics.go +++ b/src/go/plugins/mongodb/metrics.go @@ -20,9 +20,9 @@ package mongodb import ( - "zabbix.com/pkg/metric" - "zabbix.com/pkg/plugin" - "zabbix.com/pkg/uri" + "git.zabbix.com/ap/plugin-support/metric" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/uri" ) // handlerFunc defines an interface must be implemented by handlers. diff --git a/src/go/plugins/mongodb/mockconn.go b/src/go/plugins/mongodb/mockconn.go index aad8053a55f..09f9cce71c4 100644 --- a/src/go/plugins/mongodb/mockconn.go +++ b/src/go/plugins/mongodb/mockconn.go @@ -5,9 +5,9 @@ import ( "fmt" "time" + "git.zabbix.com/ap/plugin-support/zbxerr" "gopkg.in/mgo.v2" "gopkg.in/mgo.v2/bson" - "zabbix.com/pkg/zbxerr" ) const ( diff --git a/src/go/plugins/mongodb/mongodb.go b/src/go/plugins/mongodb/mongodb.go index 65b47804704..4b5b8284b03 100644 --- a/src/go/plugins/mongodb/mongodb.go +++ b/src/go/plugins/mongodb/mongodb.go @@ -24,10 +24,10 @@ import ( "gopkg.in/mgo.v2" - "zabbix.com/pkg/uri" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/uri" + "git.zabbix.com/ap/plugin-support/zbxerr" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) const pluginName = "Mongo" diff --git a/src/go/plugins/mqtt/mqtt.go b/src/go/plugins/mqtt/mqtt.go index 571ecd85df6..15ad10fcf2d 100644 --- a/src/go/plugins/mqtt/mqtt.go +++ b/src/go/plugins/mqtt/mqtt.go @@ -35,10 +35,10 @@ import ( "strings" "time" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/plugin" mqtt "github.com/eclipse/paho.mqtt.golang" - "zabbix.com/pkg/conf" "zabbix.com/pkg/itemutil" - "zabbix.com/pkg/plugin" "zabbix.com/pkg/version" "zabbix.com/pkg/watch" ) diff --git a/src/go/plugins/mysql/config.go b/src/go/plugins/mysql/config.go index 9156f19d845..06e210f39d7 100644 --- a/src/go/plugins/mysql/config.go +++ b/src/go/plugins/mysql/config.go @@ -20,8 +20,8 @@ package mysql import ( - "zabbix.com/pkg/conf" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/plugin" ) // Session is a general structure for storing sessions' configuration. diff --git a/src/go/plugins/mysql/conn.go b/src/go/plugins/mysql/conn.go index 9a71783548c..e4b4a9fa10a 100644 --- a/src/go/plugins/mysql/conn.go +++ b/src/go/plugins/mysql/conn.go @@ -28,11 +28,11 @@ import ( "github.com/go-sql-driver/mysql" + "git.zabbix.com/ap/plugin-support/uri" "zabbix.com/pkg/tlsconfig" - "zabbix.com/pkg/uri" - "zabbix.com/pkg/log" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/zbxerr" ) type MyClient interface { diff --git a/src/go/plugins/mysql/handler_database_size.go b/src/go/plugins/mysql/handler_database_size.go index 5badf554a1f..7e977077d3c 100644 --- a/src/go/plugins/mysql/handler_database_size.go +++ b/src/go/plugins/mysql/handler_database_size.go @@ -22,7 +22,7 @@ package mysql import ( "context" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func databaseSizeHandler(ctx context.Context, conn MyClient, diff --git a/src/go/plugins/mysql/handler_databases_discovery.go b/src/go/plugins/mysql/handler_databases_discovery.go index 75feb5b2251..d3f3adb81d9 100644 --- a/src/go/plugins/mysql/handler_databases_discovery.go +++ b/src/go/plugins/mysql/handler_databases_discovery.go @@ -23,7 +23,7 @@ import ( "context" "encoding/json" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func databasesDiscoveryHandler(ctx context.Context, conn MyClient, _ map[string]string, diff --git a/src/go/plugins/mysql/handler_replication_discovery.go b/src/go/plugins/mysql/handler_replication_discovery.go index 2722f17746b..ebfb628c2c9 100644 --- a/src/go/plugins/mysql/handler_replication_discovery.go +++ b/src/go/plugins/mysql/handler_replication_discovery.go @@ -23,7 +23,7 @@ import ( "context" "encoding/json" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func replicationDiscoveryHandler(ctx context.Context, conn MyClient, _ map[string]string, diff --git a/src/go/plugins/mysql/handler_replication_status.go b/src/go/plugins/mysql/handler_replication_status.go index 594c2816104..ecbd69e1a79 100644 --- a/src/go/plugins/mysql/handler_replication_status.go +++ b/src/go/plugins/mysql/handler_replication_status.go @@ -24,7 +24,7 @@ import ( "encoding/json" "errors" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func replicationSlaveStatusHandler(ctx context.Context, conn MyClient, _ map[string]string, diff --git a/src/go/plugins/mysql/handler_status_variables.go b/src/go/plugins/mysql/handler_status_variables.go index 878fed75103..f6b7df2756f 100644 --- a/src/go/plugins/mysql/handler_status_variables.go +++ b/src/go/plugins/mysql/handler_status_variables.go @@ -23,7 +23,7 @@ import ( "context" "encoding/json" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func statusVarsHandler(ctx context.Context, conn MyClient, _ map[string]string, diff --git a/src/go/plugins/mysql/handler_version.go b/src/go/plugins/mysql/handler_version.go index 1823bb1107f..aaf76225c91 100644 --- a/src/go/plugins/mysql/handler_version.go +++ b/src/go/plugins/mysql/handler_version.go @@ -22,7 +22,7 @@ package mysql import ( "context" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func versionHandler(ctx context.Context, conn MyClient, params map[string]string, _ ...string) (interface{}, error) { diff --git a/src/go/plugins/mysql/metrics.go b/src/go/plugins/mysql/metrics.go index 466484b68be..444d5bfcc81 100644 --- a/src/go/plugins/mysql/metrics.go +++ b/src/go/plugins/mysql/metrics.go @@ -22,9 +22,9 @@ package mysql import ( "context" - "zabbix.com/pkg/metric" - "zabbix.com/pkg/plugin" - "zabbix.com/pkg/uri" + "git.zabbix.com/ap/plugin-support/metric" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/uri" ) const ( diff --git a/src/go/plugins/mysql/mysql.go b/src/go/plugins/mysql/mysql.go index 8ce8c7fefac..6598059c7bf 100644 --- a/src/go/plugins/mysql/mysql.go +++ b/src/go/plugins/mysql/mysql.go @@ -23,10 +23,10 @@ import ( "context" "time" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/uri" + "git.zabbix.com/ap/plugin-support/zbxerr" "zabbix.com/pkg/tlsconfig" - "zabbix.com/pkg/uri" - "zabbix.com/pkg/zbxerr" ) const ( diff --git a/src/go/plugins/net/dns/dns.go b/src/go/plugins/net/dns/dns.go index 107ffdfabcf..60efc74b3dd 100644 --- a/src/go/plugins/net/dns/dns.go +++ b/src/go/plugins/net/dns/dns.go @@ -26,9 +26,9 @@ import ( "strings" "time" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/miekg/dns" - "zabbix.com/pkg/plugin" - "zabbix.com/pkg/zbxerr" ) const ( diff --git a/src/go/plugins/net/dns/dns_windows.go b/src/go/plugins/net/dns/dns_windows.go index baf45c3d40d..a830f064ddb 100644 --- a/src/go/plugins/net/dns/dns_windows.go +++ b/src/go/plugins/net/dns/dns_windows.go @@ -23,8 +23,8 @@ import ( "strings" "unsafe" + "git.zabbix.com/ap/plugin-support/zbxerr" "golang.org/x/sys/windows" - "zabbix.com/pkg/zbxerr" ) func (o *options) setDefaultIP() error { diff --git a/src/go/plugins/net/netif/netif.go b/src/go/plugins/net/netif/netif.go index 728885d3d67..b58bc06253b 100644 --- a/src/go/plugins/net/netif/netif.go +++ b/src/go/plugins/net/netif/netif.go @@ -20,7 +20,7 @@ package netif import ( - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) const ( diff --git a/src/go/plugins/net/netif/netif_linux.go b/src/go/plugins/net/netif/netif_linux.go index 3c3c19d9416..40710f728e1 100644 --- a/src/go/plugins/net/netif/netif_linux.go +++ b/src/go/plugins/net/netif/netif_linux.go @@ -27,8 +27,8 @@ import ( "strconv" "strings" - "zabbix.com/pkg/plugin" - "zabbix.com/pkg/std" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/std" ) const ( diff --git a/src/go/plugins/net/netif/netif_test.go b/src/go/plugins/net/netif/netif_test.go index 9ad32680e5a..ecc3af1fc4c 100644 --- a/src/go/plugins/net/netif/netif_test.go +++ b/src/go/plugins/net/netif/netif_test.go @@ -27,7 +27,7 @@ import ( "reflect" "testing" - "zabbix.com/pkg/std" + "git.zabbix.com/ap/plugin-support/std" ) var testSets = []testSet{ diff --git a/src/go/plugins/net/netif/netif_unsupported.go b/src/go/plugins/net/netif/netif_unsupported.go index 8b21fb58c0f..8eab532dc59 100644 --- a/src/go/plugins/net/netif/netif_unsupported.go +++ b/src/go/plugins/net/netif/netif_unsupported.go @@ -23,7 +23,7 @@ package netif import ( - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) func (p *Plugin) Export(key string, params []string, ctx plugin.ContextProvider) (result interface{}, err error) { diff --git a/src/go/plugins/net/netif/netif_windows.go b/src/go/plugins/net/netif/netif_windows.go index d7aefb7ff57..2d202121254 100644 --- a/src/go/plugins/net/netif/netif_windows.go +++ b/src/go/plugins/net/netif/netif_windows.go @@ -26,8 +26,8 @@ import ( "net" "unsafe" + "git.zabbix.com/ap/plugin-support/plugin" "golang.org/x/sys/windows" - "zabbix.com/pkg/plugin" "zabbix.com/pkg/win32" ) diff --git a/src/go/plugins/net/tcp/tcp.go b/src/go/plugins/net/tcp/tcp.go index a1fedb31ac7..d09e1b09a04 100644 --- a/src/go/plugins/net/tcp/tcp.go +++ b/src/go/plugins/net/tcp/tcp.go @@ -31,10 +31,10 @@ import ( "strings" "time" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/plugin" "github.com/go-ldap/ldap" - "zabbix.com/pkg/conf" - "zabbix.com/pkg/log" - "zabbix.com/pkg/plugin" "zabbix.com/pkg/web" ) diff --git a/src/go/plugins/net/tcp/tcp_nix.go b/src/go/plugins/net/tcp/tcp_nix.go index 22d87c7d4ee..59ab5c9502b 100644 --- a/src/go/plugins/net/tcp/tcp_nix.go +++ b/src/go/plugins/net/tcp/tcp_nix.go @@ -25,7 +25,7 @@ package tcpudp import ( "errors" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) func exportSystemTcpListen(port uint16) (result interface{}, err error) { diff --git a/src/go/plugins/net/tcp/tcp_windows.go b/src/go/plugins/net/tcp/tcp_windows.go index 356342ed7b4..f84e66e6420 100644 --- a/src/go/plugins/net/tcp/tcp_windows.go +++ b/src/go/plugins/net/tcp/tcp_windows.go @@ -23,7 +23,7 @@ import ( "encoding/binary" "unsafe" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/pkg/win32" ) diff --git a/src/go/plugins/net/udp/udp.go b/src/go/plugins/net/udp/udp.go index f5a349d3b63..81781a82dbe 100644 --- a/src/go/plugins/net/udp/udp.go +++ b/src/go/plugins/net/udp/udp.go @@ -27,9 +27,9 @@ import ( "strconv" "time" - "zabbix.com/pkg/conf" - "zabbix.com/pkg/log" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/plugin" ) const ( diff --git a/src/go/plugins/oracle/config.go b/src/go/plugins/oracle/config.go index 51fa8211d2e..72d4c7f4a2c 100644 --- a/src/go/plugins/oracle/config.go +++ b/src/go/plugins/oracle/config.go @@ -20,8 +20,8 @@ package oracle import ( - "zabbix.com/pkg/conf" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/plugin" ) type Session struct { diff --git a/src/go/plugins/oracle/conn.go b/src/go/plugins/oracle/conn.go index 24666044515..e3c5dea3428 100644 --- a/src/go/plugins/oracle/conn.go +++ b/src/go/plugins/oracle/conn.go @@ -28,12 +28,12 @@ import ( "sync" "time" - "zabbix.com/pkg/uri" + "git.zabbix.com/ap/plugin-support/uri" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/godror/godror" "github.com/omeid/go-yarn" - "zabbix.com/pkg/log" - "zabbix.com/pkg/zbxerr" ) type OraClient interface { diff --git a/src/go/plugins/oracle/conn_test.go b/src/go/plugins/oracle/conn_test.go index e02cd80bd75..f9df2f653e4 100644 --- a/src/go/plugins/oracle/conn_test.go +++ b/src/go/plugins/oracle/conn_test.go @@ -27,7 +27,7 @@ import ( "testing" "time" - "zabbix.com/pkg/uri" + "git.zabbix.com/ap/plugin-support/uri" "github.com/omeid/go-yarn" ) diff --git a/src/go/plugins/oracle/handler_archive.go b/src/go/plugins/oracle/handler_archive.go index 9c13b764342..ce2cbb5bfb7 100644 --- a/src/go/plugins/oracle/handler_archive.go +++ b/src/go/plugins/oracle/handler_archive.go @@ -22,7 +22,7 @@ package oracle import ( "context" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func archiveHandler(ctx context.Context, conn OraClient, params map[string]string, _ ...string) (interface{}, error) { diff --git a/src/go/plugins/oracle/handler_archive_discovery.go b/src/go/plugins/oracle/handler_archive_discovery.go index 9c5c93bd9fa..e8ded3044b1 100644 --- a/src/go/plugins/oracle/handler_archive_discovery.go +++ b/src/go/plugins/oracle/handler_archive_discovery.go @@ -22,7 +22,7 @@ package oracle import ( "context" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func archiveDiscoveryHandler(ctx context.Context, conn OraClient, params map[string]string, diff --git a/src/go/plugins/oracle/handler_asm_diskgroups.go b/src/go/plugins/oracle/handler_asm_diskgroups.go index a79345cb579..c5d638ee63a 100644 --- a/src/go/plugins/oracle/handler_asm_diskgroups.go +++ b/src/go/plugins/oracle/handler_asm_diskgroups.go @@ -22,7 +22,7 @@ package oracle import ( "context" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func asmDiskGroupsHandler(ctx context.Context, conn OraClient, params map[string]string, diff --git a/src/go/plugins/oracle/handler_asm_diskgroups_discovery.go b/src/go/plugins/oracle/handler_asm_diskgroups_discovery.go index 4b75059e53b..4e4c1a2fa7b 100644 --- a/src/go/plugins/oracle/handler_asm_diskgroups_discovery.go +++ b/src/go/plugins/oracle/handler_asm_diskgroups_discovery.go @@ -22,7 +22,7 @@ package oracle import ( "context" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func asmDiskGroupsDiscovery(ctx context.Context, conn OraClient, params map[string]string, diff --git a/src/go/plugins/oracle/handler_cdb.go b/src/go/plugins/oracle/handler_cdb.go index 7527546431b..9b071efa33d 100644 --- a/src/go/plugins/oracle/handler_cdb.go +++ b/src/go/plugins/oracle/handler_cdb.go @@ -22,7 +22,7 @@ package oracle import ( "context" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func cdbHandler(ctx context.Context, conn OraClient, params map[string]string, _ ...string) (interface{}, error) { diff --git a/src/go/plugins/oracle/handler_custom_query.go b/src/go/plugins/oracle/handler_custom_query.go index fea2af50c14..66c75817a69 100644 --- a/src/go/plugins/oracle/handler_custom_query.go +++ b/src/go/plugins/oracle/handler_custom_query.go @@ -25,7 +25,7 @@ import ( "encoding/json" "strings" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) // customQueryHandler executes custom user queries diff --git a/src/go/plugins/oracle/handler_databases_discovery.go b/src/go/plugins/oracle/handler_databases_discovery.go index c2f5d0072b3..1797de5d896 100644 --- a/src/go/plugins/oracle/handler_databases_discovery.go +++ b/src/go/plugins/oracle/handler_databases_discovery.go @@ -22,7 +22,7 @@ package oracle import ( "context" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func databasesDiscoveryHandler(ctx context.Context, conn OraClient, params map[string]string, diff --git a/src/go/plugins/oracle/handler_datafiles.go b/src/go/plugins/oracle/handler_datafiles.go index 541b541f822..183b6576f0e 100644 --- a/src/go/plugins/oracle/handler_datafiles.go +++ b/src/go/plugins/oracle/handler_datafiles.go @@ -22,7 +22,7 @@ package oracle import ( "context" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func dataFileHandler(ctx context.Context, conn OraClient, params map[string]string, _ ...string) (interface{}, error) { diff --git a/src/go/plugins/oracle/handler_fra.go b/src/go/plugins/oracle/handler_fra.go index 65488ad666a..f896ae72c4d 100644 --- a/src/go/plugins/oracle/handler_fra.go +++ b/src/go/plugins/oracle/handler_fra.go @@ -22,7 +22,7 @@ package oracle import ( "context" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func fraHandler(ctx context.Context, conn OraClient, params map[string]string, _ ...string) (interface{}, error) { diff --git a/src/go/plugins/oracle/handler_instance.go b/src/go/plugins/oracle/handler_instance.go index e0977cd1134..6dfdbe5a6b2 100644 --- a/src/go/plugins/oracle/handler_instance.go +++ b/src/go/plugins/oracle/handler_instance.go @@ -22,7 +22,7 @@ package oracle import ( "context" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func instanceHandler(ctx context.Context, conn OraClient, params map[string]string, _ ...string) (interface{}, error) { diff --git a/src/go/plugins/oracle/handler_pdb.go b/src/go/plugins/oracle/handler_pdb.go index 9b3f9339183..24b9f67fe67 100644 --- a/src/go/plugins/oracle/handler_pdb.go +++ b/src/go/plugins/oracle/handler_pdb.go @@ -22,7 +22,7 @@ package oracle import ( "context" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func pdbHandler(ctx context.Context, conn OraClient, params map[string]string, _ ...string) (interface{}, error) { diff --git a/src/go/plugins/oracle/handler_pdb_discovery.go b/src/go/plugins/oracle/handler_pdb_discovery.go index 7d541100ec8..72cd5b0b0c2 100644 --- a/src/go/plugins/oracle/handler_pdb_discovery.go +++ b/src/go/plugins/oracle/handler_pdb_discovery.go @@ -22,7 +22,7 @@ package oracle import ( "context" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func pdbDiscoveryHandler(ctx context.Context, conn OraClient, params map[string]string, diff --git a/src/go/plugins/oracle/handler_pga.go b/src/go/plugins/oracle/handler_pga.go index d6e2d3b251d..a9fc35ed060 100644 --- a/src/go/plugins/oracle/handler_pga.go +++ b/src/go/plugins/oracle/handler_pga.go @@ -22,7 +22,7 @@ package oracle import ( "context" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func pgaHandler(ctx context.Context, conn OraClient, params map[string]string, _ ...string) (interface{}, error) { diff --git a/src/go/plugins/oracle/handler_processes.go b/src/go/plugins/oracle/handler_processes.go index c784710ef4e..ef8b1baabd6 100644 --- a/src/go/plugins/oracle/handler_processes.go +++ b/src/go/plugins/oracle/handler_processes.go @@ -22,7 +22,7 @@ package oracle import ( "context" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func procHandler(ctx context.Context, conn OraClient, params map[string]string, _ ...string) (interface{}, error) { diff --git a/src/go/plugins/oracle/handler_redolog.go b/src/go/plugins/oracle/handler_redolog.go index 9754d95f9fd..28acd23c5a1 100644 --- a/src/go/plugins/oracle/handler_redolog.go +++ b/src/go/plugins/oracle/handler_redolog.go @@ -22,7 +22,7 @@ package oracle import ( "context" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func redoLogHandler(ctx context.Context, conn OraClient, params map[string]string, _ ...string) (interface{}, error) { diff --git a/src/go/plugins/oracle/handler_sessions.go b/src/go/plugins/oracle/handler_sessions.go index 676b35ccf6c..8c0bffb211f 100644 --- a/src/go/plugins/oracle/handler_sessions.go +++ b/src/go/plugins/oracle/handler_sessions.go @@ -22,7 +22,7 @@ package oracle import ( "context" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func sessionsHandler(ctx context.Context, conn OraClient, params map[string]string, _ ...string) (interface{}, error) { diff --git a/src/go/plugins/oracle/handler_sga.go b/src/go/plugins/oracle/handler_sga.go index 4e348fafc4a..c2ac915e981 100644 --- a/src/go/plugins/oracle/handler_sga.go +++ b/src/go/plugins/oracle/handler_sga.go @@ -22,7 +22,7 @@ package oracle import ( "context" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func sgaHandler(ctx context.Context, conn OraClient, params map[string]string, _ ...string) (interface{}, error) { diff --git a/src/go/plugins/oracle/handler_sysmetrics.go b/src/go/plugins/oracle/handler_sysmetrics.go index a07ec3dcd84..43c1a5534f6 100644 --- a/src/go/plugins/oracle/handler_sysmetrics.go +++ b/src/go/plugins/oracle/handler_sysmetrics.go @@ -23,7 +23,7 @@ import ( "context" "strings" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) const ( diff --git a/src/go/plugins/oracle/handler_sysparams.go b/src/go/plugins/oracle/handler_sysparams.go index a8c5ea6552a..dff09d69d6a 100644 --- a/src/go/plugins/oracle/handler_sysparams.go +++ b/src/go/plugins/oracle/handler_sysparams.go @@ -22,7 +22,7 @@ package oracle import ( "context" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func sysParamsHandler(ctx context.Context, conn OraClient, params map[string]string, _ ...string) (interface{}, error) { diff --git a/src/go/plugins/oracle/handler_tablespaces.go b/src/go/plugins/oracle/handler_tablespaces.go index 6f11b694215..9c1191e54b9 100644 --- a/src/go/plugins/oracle/handler_tablespaces.go +++ b/src/go/plugins/oracle/handler_tablespaces.go @@ -23,7 +23,7 @@ import ( "context" "strings" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func tablespacesHandler(ctx context.Context, conn OraClient, params map[string]string, diff --git a/src/go/plugins/oracle/handler_tablespaces_discovery.go b/src/go/plugins/oracle/handler_tablespaces_discovery.go index cfef1ee923f..2a6baec6480 100644 --- a/src/go/plugins/oracle/handler_tablespaces_discovery.go +++ b/src/go/plugins/oracle/handler_tablespaces_discovery.go @@ -22,7 +22,7 @@ package oracle import ( "context" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func tablespacesDiscoveryHandler(ctx context.Context, conn OraClient, params map[string]string, diff --git a/src/go/plugins/oracle/handler_user.go b/src/go/plugins/oracle/handler_user.go index da742c916f0..bc5d346a3bc 100644 --- a/src/go/plugins/oracle/handler_user.go +++ b/src/go/plugins/oracle/handler_user.go @@ -23,7 +23,7 @@ import ( "context" "database/sql" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func userHandler(ctx context.Context, conn OraClient, params map[string]string, _ ...string) (interface{}, error) { diff --git a/src/go/plugins/oracle/metrics.go b/src/go/plugins/oracle/metrics.go index 9cce753fb37..d967bb953d5 100644 --- a/src/go/plugins/oracle/metrics.go +++ b/src/go/plugins/oracle/metrics.go @@ -22,9 +22,9 @@ package oracle import ( "context" - "zabbix.com/pkg/metric" - "zabbix.com/pkg/plugin" - "zabbix.com/pkg/uri" + "git.zabbix.com/ap/plugin-support/metric" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/uri" ) const ( diff --git a/src/go/plugins/oracle/oracle.go b/src/go/plugins/oracle/oracle.go index e49e6bbb16c..da6be0fa3f8 100644 --- a/src/go/plugins/oracle/oracle.go +++ b/src/go/plugins/oracle/oracle.go @@ -25,12 +25,12 @@ import ( "net/url" "time" - "zabbix.com/pkg/uri" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/uri" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/omeid/go-yarn" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) const ( diff --git a/src/go/plugins/oracle/oracle_test.go b/src/go/plugins/oracle/oracle_test.go index 98cb938e7f5..cfc9c3be78a 100644 --- a/src/go/plugins/oracle/oracle_test.go +++ b/src/go/plugins/oracle/oracle_test.go @@ -32,11 +32,11 @@ import ( "strings" "testing" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/omeid/go-yarn" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) type TestConfig struct { diff --git a/src/go/plugins/postgres/config.go b/src/go/plugins/postgres/config.go index 4191b27c7b5..4f37d9ae77f 100755 --- a/src/go/plugins/postgres/config.go +++ b/src/go/plugins/postgres/config.go @@ -20,8 +20,8 @@ package postgres import ( - "zabbix.com/pkg/conf" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/plugin" ) // Session struct holds individual options for PostgreSQL connection for each session. diff --git a/src/go/plugins/postgres/conn.go b/src/go/plugins/postgres/conn.go index 79ad07a1847..65c1178e3d2 100755 --- a/src/go/plugins/postgres/conn.go +++ b/src/go/plugins/postgres/conn.go @@ -31,13 +31,13 @@ import ( "sync" "time" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/uri" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/jackc/pgx/v4/pgxpool" "github.com/jackc/pgx/v4/stdlib" "github.com/omeid/go-yarn" - "zabbix.com/pkg/log" "zabbix.com/pkg/tlsconfig" - "zabbix.com/pkg/uri" - "zabbix.com/pkg/zbxerr" ) const MinSupportedPGVersion = 100000 diff --git a/src/go/plugins/postgres/handler_archive.go b/src/go/plugins/postgres/handler_archive.go index 72ded4f0e93..9a0641d0165 100644 --- a/src/go/plugins/postgres/handler_archive.go +++ b/src/go/plugins/postgres/handler_archive.go @@ -22,8 +22,9 @@ package postgres import ( "context" "errors" + + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/jackc/pgx/v4" - "zabbix.com/pkg/zbxerr" ) // archiveHandler gets info about count and size of archive files and returns JSON if all is OK or nil otherwise. diff --git a/src/go/plugins/postgres/handler_autovacuum.go b/src/go/plugins/postgres/handler_autovacuum.go index 8d69874c174..9274328ef1a 100644 --- a/src/go/plugins/postgres/handler_autovacuum.go +++ b/src/go/plugins/postgres/handler_autovacuum.go @@ -23,8 +23,8 @@ import ( "context" "errors" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/jackc/pgx/v4" - "zabbix.com/pkg/zbxerr" ) // autovacuumHandler returns count of autovacuum workers if all is OK or nil otherwise. diff --git a/src/go/plugins/postgres/handler_bgwriter.go b/src/go/plugins/postgres/handler_bgwriter.go index 21ee46a5a33..f5a29fb3f74 100644 --- a/src/go/plugins/postgres/handler_bgwriter.go +++ b/src/go/plugins/postgres/handler_bgwriter.go @@ -23,8 +23,8 @@ import ( "context" "errors" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/jackc/pgx/v4" - "zabbix.com/pkg/zbxerr" ) // bgwriterHandler executes select with statistics from pg_stat_bgwriter diff --git a/src/go/plugins/postgres/handler_cache.go b/src/go/plugins/postgres/handler_cache.go index eec459c2165..84ce45cf3ce 100644 --- a/src/go/plugins/postgres/handler_cache.go +++ b/src/go/plugins/postgres/handler_cache.go @@ -23,8 +23,8 @@ import ( "context" "errors" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/jackc/pgx/v4" - "zabbix.com/pkg/zbxerr" ) // cacheHandler finds cache hit percent and returns int64 if all is OK or nil otherwise. diff --git a/src/go/plugins/postgres/handler_connections.go b/src/go/plugins/postgres/handler_connections.go index 7b0b725ce53..74e82a9705a 100644 --- a/src/go/plugins/postgres/handler_connections.go +++ b/src/go/plugins/postgres/handler_connections.go @@ -23,8 +23,8 @@ import ( "context" "errors" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/jackc/pgx/v4" - "zabbix.com/pkg/zbxerr" ) // connectionsHandler executes select from pg_stat_activity command and returns JSON if all is OK or nil otherwise. diff --git a/src/go/plugins/postgres/handler_custom_query.go b/src/go/plugins/postgres/handler_custom_query.go index 200be03fb76..57c640b3b7f 100644 --- a/src/go/plugins/postgres/handler_custom_query.go +++ b/src/go/plugins/postgres/handler_custom_query.go @@ -25,8 +25,8 @@ import ( "errors" "strings" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/jackc/pgx/v4" - "zabbix.com/pkg/zbxerr" ) // customQueryHandler executes custom user queries from *.sql files. diff --git a/src/go/plugins/postgres/handler_database_age.go b/src/go/plugins/postgres/handler_database_age.go index 42c2a5af04f..384ace13541 100644 --- a/src/go/plugins/postgres/handler_database_age.go +++ b/src/go/plugins/postgres/handler_database_age.go @@ -23,8 +23,8 @@ import ( "context" "errors" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/jackc/pgx/v4" - "zabbix.com/pkg/zbxerr" ) // databaseAgeHandler gets age of specific database respectively or nil otherwise. diff --git a/src/go/plugins/postgres/handler_database_size.go b/src/go/plugins/postgres/handler_database_size.go index eeb6db4ee10..69f75fc818f 100644 --- a/src/go/plugins/postgres/handler_database_size.go +++ b/src/go/plugins/postgres/handler_database_size.go @@ -23,8 +23,8 @@ import ( "context" "errors" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/jackc/pgx/v4" - "zabbix.com/pkg/zbxerr" ) // databaseSizeHandler gets info about count and size of archive files and returns JSON if all is OK or nil otherwise. diff --git a/src/go/plugins/postgres/handler_databases_bloating.go b/src/go/plugins/postgres/handler_databases_bloating.go index 6b01f2397f4..c865cf68ad0 100644 --- a/src/go/plugins/postgres/handler_databases_bloating.go +++ b/src/go/plugins/postgres/handler_databases_bloating.go @@ -23,8 +23,8 @@ import ( "context" "errors" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/jackc/pgx/v4" - "zabbix.com/pkg/zbxerr" ) // databasesBloatingHandler gets info about count and size of archive files and returns JSON if all is OK or nil otherwise. diff --git a/src/go/plugins/postgres/handler_databases_discovery.go b/src/go/plugins/postgres/handler_databases_discovery.go index d0637c16d52..2010cd79377 100644 --- a/src/go/plugins/postgres/handler_databases_discovery.go +++ b/src/go/plugins/postgres/handler_databases_discovery.go @@ -23,8 +23,8 @@ import ( "context" "errors" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/jackc/pgx/v4" - "zabbix.com/pkg/zbxerr" ) // databasesDiscoveryHandler gets names of all databases and returns JSON if all is OK or nil otherwise. diff --git a/src/go/plugins/postgres/handler_dbstat.go b/src/go/plugins/postgres/handler_dbstat.go index fe4e23eccff..0818ab83569 100644 --- a/src/go/plugins/postgres/handler_dbstat.go +++ b/src/go/plugins/postgres/handler_dbstat.go @@ -24,8 +24,8 @@ import ( "errors" "fmt" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/jackc/pgx/v4" - "zabbix.com/pkg/zbxerr" ) const pgVersionWithChecksum = 120000 diff --git a/src/go/plugins/postgres/handler_locks.go b/src/go/plugins/postgres/handler_locks.go index 89e75178c3b..1dfba036d9e 100644 --- a/src/go/plugins/postgres/handler_locks.go +++ b/src/go/plugins/postgres/handler_locks.go @@ -23,7 +23,7 @@ import ( "context" "errors" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) // locksHandler executes select from pg_stat_database command and returns JSON if all is OK or nil otherwise. diff --git a/src/go/plugins/postgres/handler_oldest_xid.go b/src/go/plugins/postgres/handler_oldest_xid.go index e02aa0d05e2..4140fd6fde1 100644 --- a/src/go/plugins/postgres/handler_oldest_xid.go +++ b/src/go/plugins/postgres/handler_oldest_xid.go @@ -23,8 +23,8 @@ import ( "context" "errors" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/jackc/pgx/v4" - "zabbix.com/pkg/zbxerr" ) // oldestXIDHandler gets age of the oldest xid if all is OK or nil otherwise. diff --git a/src/go/plugins/postgres/handler_queries.go b/src/go/plugins/postgres/handler_queries.go index 82524582125..6ce96cc1c63 100644 --- a/src/go/plugins/postgres/handler_queries.go +++ b/src/go/plugins/postgres/handler_queries.go @@ -24,7 +24,7 @@ import ( "fmt" "strconv" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) // queriesHandler executes select from pg_database command and returns JSON if all is OK or nil otherwise. diff --git a/src/go/plugins/postgres/handler_replication.go b/src/go/plugins/postgres/handler_replication.go index 6dc8cce0931..8bd2aaebfe1 100644 --- a/src/go/plugins/postgres/handler_replication.go +++ b/src/go/plugins/postgres/handler_replication.go @@ -25,8 +25,8 @@ import ( "errors" "strconv" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/jackc/pgx/v4" - "zabbix.com/pkg/zbxerr" ) // replicationHandler gets info about recovery state if all is OK or nil otherwise. diff --git a/src/go/plugins/postgres/handler_replication_process_name_discovery.go b/src/go/plugins/postgres/handler_replication_process_name_discovery.go index fbfec767991..8fe5d3302c3 100644 --- a/src/go/plugins/postgres/handler_replication_process_name_discovery.go +++ b/src/go/plugins/postgres/handler_replication_process_name_discovery.go @@ -23,8 +23,8 @@ import ( "context" "errors" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/jackc/pgx/v4" - "zabbix.com/pkg/zbxerr" ) // processNameDiscoveryHandler gets names of all sender processes in pg_stat_replication diff --git a/src/go/plugins/postgres/handler_uptime.go b/src/go/plugins/postgres/handler_uptime.go index 25ac539aeef..23f6979be5d 100644 --- a/src/go/plugins/postgres/handler_uptime.go +++ b/src/go/plugins/postgres/handler_uptime.go @@ -23,8 +23,8 @@ import ( "context" "errors" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/jackc/pgx/v4" - "zabbix.com/pkg/zbxerr" ) // uptimeHandler finds difference btw current time and diff --git a/src/go/plugins/postgres/handler_wal.go b/src/go/plugins/postgres/handler_wal.go index d086e5b479f..822234f4125 100644 --- a/src/go/plugins/postgres/handler_wal.go +++ b/src/go/plugins/postgres/handler_wal.go @@ -23,8 +23,8 @@ import ( "context" "errors" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/jackc/pgx/v4" - "zabbix.com/pkg/zbxerr" ) // walHandler executes select from directory which contains wal files and returns JSON if all is OK or nil otherwise. diff --git a/src/go/plugins/postgres/metrics.go b/src/go/plugins/postgres/metrics.go index 245948d0695..3654ef90720 100644 --- a/src/go/plugins/postgres/metrics.go +++ b/src/go/plugins/postgres/metrics.go @@ -26,9 +26,9 @@ import ( "regexp" "strings" - "zabbix.com/pkg/metric" - "zabbix.com/pkg/plugin" - "zabbix.com/pkg/uri" + "git.zabbix.com/ap/plugin-support/metric" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/uri" ) const ( diff --git a/src/go/plugins/postgres/postgres.go b/src/go/plugins/postgres/postgres.go index 3dc97fa9b69..c4031facccc 100755 --- a/src/go/plugins/postgres/postgres.go +++ b/src/go/plugins/postgres/postgres.go @@ -25,13 +25,13 @@ import ( "net/url" "time" + "git.zabbix.com/ap/plugin-support/uri" + "git.zabbix.com/ap/plugin-support/zbxerr" "zabbix.com/pkg/tlsconfig" - "zabbix.com/pkg/uri" - "zabbix.com/pkg/zbxerr" "github.com/omeid/go-yarn" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) const ( diff --git a/src/go/plugins/postgres/postgres_test.go b/src/go/plugins/postgres/postgres_test.go index 40d993b845c..4255bee0d2d 100755 --- a/src/go/plugins/postgres/postgres_test.go +++ b/src/go/plugins/postgres/postgres_test.go @@ -27,9 +27,9 @@ import ( "reflect" "testing" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/plugin" "github.com/omeid/go-yarn" - "zabbix.com/pkg/log" - "zabbix.com/pkg/plugin" ) var testParamDatabase = map[string]string{"Database": "postgres"} diff --git a/src/go/plugins/postgres/testpool.go b/src/go/plugins/postgres/testpool.go index c20a749e697..79a98afca8e 100644 --- a/src/go/plugins/postgres/testpool.go +++ b/src/go/plugins/postgres/testpool.go @@ -27,7 +27,8 @@ import ( "fmt" "os" "time" - "zabbix.com/pkg/log" + + "git.zabbix.com/ap/plugin-support/log" ) var sharedConn *PGConn diff --git a/src/go/plugins/proc/proc_linux.go b/src/go/plugins/proc/proc_linux.go index e267786c374..b477e13cf57 100644 --- a/src/go/plugins/proc/proc_linux.go +++ b/src/go/plugins/proc/proc_linux.go @@ -37,8 +37,8 @@ import ( "sync" "time" - "zabbix.com/pkg/log" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/pkg/procfs" ) diff --git a/src/go/plugins/proc/proc_windows.go b/src/go/plugins/proc/proc_windows.go index 405f3e34a34..0cc3e86f94b 100644 --- a/src/go/plugins/proc/proc_windows.go +++ b/src/go/plugins/proc/proc_windows.go @@ -25,8 +25,8 @@ import ( "syscall" "unsafe" + "git.zabbix.com/ap/plugin-support/plugin" "golang.org/x/sys/windows" - "zabbix.com/pkg/plugin" "zabbix.com/pkg/win32" ) diff --git a/src/go/plugins/redis/config.go b/src/go/plugins/redis/config.go index f8913012c76..6cafb0d3e6c 100644 --- a/src/go/plugins/redis/config.go +++ b/src/go/plugins/redis/config.go @@ -20,8 +20,8 @@ package redis import ( - "zabbix.com/pkg/conf" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/plugin" ) type Session struct { diff --git a/src/go/plugins/redis/conn.go b/src/go/plugins/redis/conn.go index bf47c01a383..e4da2e87e74 100644 --- a/src/go/plugins/redis/conn.go +++ b/src/go/plugins/redis/conn.go @@ -25,10 +25,10 @@ import ( "sync" "time" + "git.zabbix.com/ap/plugin-support/log" + "git.zabbix.com/ap/plugin-support/uri" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/mediocregopher/radix/v3" - "zabbix.com/pkg/log" - "zabbix.com/pkg/uri" - "zabbix.com/pkg/zbxerr" ) const hkInterval = 10 diff --git a/src/go/plugins/redis/conn_test.go b/src/go/plugins/redis/conn_test.go index 423039e5a69..76f8dd04351 100644 --- a/src/go/plugins/redis/conn_test.go +++ b/src/go/plugins/redis/conn_test.go @@ -24,8 +24,8 @@ import ( "testing" "time" + "git.zabbix.com/ap/plugin-support/uri" "github.com/mediocregopher/radix/v3" - "zabbix.com/pkg/uri" ) func TestConnManager_closeUnused(t *testing.T) { diff --git a/src/go/plugins/redis/handler_config.go b/src/go/plugins/redis/handler_config.go index d712cc0b094..17fed798ac4 100644 --- a/src/go/plugins/redis/handler_config.go +++ b/src/go/plugins/redis/handler_config.go @@ -24,8 +24,8 @@ import ( "fmt" "strings" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/mediocregopher/radix/v3" - "zabbix.com/pkg/zbxerr" ) const globChars = "*?[]!" diff --git a/src/go/plugins/redis/handler_info.go b/src/go/plugins/redis/handler_info.go index 8fc3c04e5a5..95327841bf1 100644 --- a/src/go/plugins/redis/handler_info.go +++ b/src/go/plugins/redis/handler_info.go @@ -25,7 +25,7 @@ import ( "regexp" "strings" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/mediocregopher/radix/v3" ) diff --git a/src/go/plugins/redis/handler_slowlog.go b/src/go/plugins/redis/handler_slowlog.go index c86adc410eb..26f88c0abaa 100644 --- a/src/go/plugins/redis/handler_slowlog.go +++ b/src/go/plugins/redis/handler_slowlog.go @@ -20,8 +20,8 @@ package redis import ( + "git.zabbix.com/ap/plugin-support/zbxerr" "github.com/mediocregopher/radix/v3" - "zabbix.com/pkg/zbxerr" ) type slowlog []interface{} diff --git a/src/go/plugins/redis/metrics.go b/src/go/plugins/redis/metrics.go index c8c54f37480..21fd08dcd51 100644 --- a/src/go/plugins/redis/metrics.go +++ b/src/go/plugins/redis/metrics.go @@ -20,9 +20,9 @@ package redis import ( - "zabbix.com/pkg/metric" - "zabbix.com/pkg/plugin" - "zabbix.com/pkg/uri" + "git.zabbix.com/ap/plugin-support/metric" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/uri" ) // handlerFunc defines an interface must be implemented by handlers. diff --git a/src/go/plugins/redis/redis.go b/src/go/plugins/redis/redis.go index 4968e6de37b..a89e7526c42 100644 --- a/src/go/plugins/redis/redis.go +++ b/src/go/plugins/redis/redis.go @@ -22,9 +22,9 @@ package redis import ( "time" - "zabbix.com/pkg/plugin" - "zabbix.com/pkg/uri" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/uri" + "git.zabbix.com/ap/plugin-support/zbxerr" ) const pluginName = "Redis" diff --git a/src/go/plugins/redis/redis_test.go b/src/go/plugins/redis/redis_test.go index e0f28fca000..ee8133e9cd7 100644 --- a/src/go/plugins/redis/redis_test.go +++ b/src/go/plugins/redis/redis_test.go @@ -23,7 +23,7 @@ import ( "reflect" "testing" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) func TestPlugin_Start(t *testing.T) { diff --git a/src/go/plugins/smart/smart.go b/src/go/plugins/smart/smart.go index f71407b6b97..f4bc05fb65f 100644 --- a/src/go/plugins/smart/smart.go +++ b/src/go/plugins/smart/smart.go @@ -22,9 +22,9 @@ package smart import ( "encoding/json" - "zabbix.com/pkg/conf" - "zabbix.com/pkg/plugin" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/zbxerr" ) // Options - diff --git a/src/go/plugins/smart/smartfs.go b/src/go/plugins/smart/smartfs.go index a01b87c4422..7cd96e15ba7 100644 --- a/src/go/plugins/smart/smartfs.go +++ b/src/go/plugins/smart/smartfs.go @@ -30,7 +30,7 @@ import ( "sync" "time" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) const ( diff --git a/src/go/plugins/system/cpu/cpu.go b/src/go/plugins/system/cpu/cpu.go index 5f22df69edf..d4783ee5349 100644 --- a/src/go/plugins/system/cpu/cpu.go +++ b/src/go/plugins/system/cpu/cpu.go @@ -24,7 +24,7 @@ import ( "errors" "strconv" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) const pluginName = "Cpu" diff --git a/src/go/plugins/system/cpu/cpu_linux.go b/src/go/plugins/system/cpu/cpu_linux.go index d52fff06fd4..188db3ea6a7 100644 --- a/src/go/plugins/system/cpu/cpu_linux.go +++ b/src/go/plugins/system/cpu/cpu_linux.go @@ -31,7 +31,7 @@ import ( "strconv" "strings" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) // Plugin - diff --git a/src/go/plugins/system/cpu/cpu_windows.go b/src/go/plugins/system/cpu/cpu_windows.go index eff02894286..8dd6817e9dc 100644 --- a/src/go/plugins/system/cpu/cpu_windows.go +++ b/src/go/plugins/system/cpu/cpu_windows.go @@ -23,9 +23,9 @@ import ( "errors" "unsafe" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/zbxerr" "zabbix.com/pkg/win32" - "zabbix.com/pkg/zbxerr" ) // Plugin - diff --git a/src/go/plugins/system/cpu/pdhcollector_windows.go b/src/go/plugins/system/cpu/pdhcollector_windows.go index 8ab789cba9b..2cb077e148f 100644 --- a/src/go/plugins/system/cpu/pdhcollector_windows.go +++ b/src/go/plugins/system/cpu/pdhcollector_windows.go @@ -23,7 +23,7 @@ import ( "fmt" "unsafe" - "zabbix.com/pkg/log" + "git.zabbix.com/ap/plugin-support/log" "zabbix.com/pkg/pdh" "zabbix.com/pkg/win32" ) diff --git a/src/go/plugins/system/hw/hw_linux.go b/src/go/plugins/system/hw/hw_linux.go index e2a7c17f151..7e8c5e23e5c 100644 --- a/src/go/plugins/system/hw/hw_linux.go +++ b/src/go/plugins/system/hw/hw_linux.go @@ -24,9 +24,9 @@ import ( "strings" "time" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/zbxerr" "zabbix.com/pkg/zbxcmd" - "zabbix.com/pkg/zbxerr" ) const ( diff --git a/src/go/plugins/system/sw/sw.go b/src/go/plugins/system/sw/sw.go index 0abaf05fb3b..ebb63625d50 100644 --- a/src/go/plugins/system/sw/sw.go +++ b/src/go/plugins/system/sw/sw.go @@ -30,9 +30,9 @@ import ( "strings" "time" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/zbxerr" "zabbix.com/pkg/zbxcmd" - "zabbix.com/pkg/zbxerr" ) // Plugin - diff --git a/src/go/plugins/system/swap/swap.go b/src/go/plugins/system/swap/swap.go index efdef39a348..d5228c916f3 100644 --- a/src/go/plugins/system/swap/swap.go +++ b/src/go/plugins/system/swap/swap.go @@ -23,7 +23,7 @@ import ( "errors" "fmt" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) // Plugin - diff --git a/src/go/plugins/system/uname/uname.go b/src/go/plugins/system/uname/uname.go index 2f00ced7764..6416fd3e628 100644 --- a/src/go/plugins/system/uname/uname.go +++ b/src/go/plugins/system/uname/uname.go @@ -20,7 +20,7 @@ package uname import ( - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) // Plugin - diff --git a/src/go/plugins/system/uptime/uptime.go b/src/go/plugins/system/uptime/uptime.go index 42244055154..5ba01afc30b 100644 --- a/src/go/plugins/system/uptime/uptime.go +++ b/src/go/plugins/system/uptime/uptime.go @@ -22,8 +22,8 @@ package uptime import ( "errors" - "zabbix.com/pkg/plugin" - "zabbix.com/pkg/std" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/std" ) // Plugin - diff --git a/src/go/plugins/system/uptime/uptime_linux.go b/src/go/plugins/system/uptime/uptime_linux.go index 1b73f0aae66..dd7dab4d930 100644 --- a/src/go/plugins/system/uptime/uptime_linux.go +++ b/src/go/plugins/system/uptime/uptime_linux.go @@ -27,7 +27,7 @@ import ( "strings" "time" - "zabbix.com/pkg/std" + "git.zabbix.com/ap/plugin-support/std" ) func getUptime() (uptime int, err error) { diff --git a/src/go/plugins/system/uptime/uptime_test.go b/src/go/plugins/system/uptime/uptime_test.go index 40c3ee7f001..8cc9c0b83d0 100644 --- a/src/go/plugins/system/uptime/uptime_test.go +++ b/src/go/plugins/system/uptime/uptime_test.go @@ -27,7 +27,7 @@ import ( "testing" "time" - "zabbix.com/pkg/std" + "git.zabbix.com/ap/plugin-support/std" ) var procStat = ` diff --git a/src/go/plugins/system/users/users.go b/src/go/plugins/system/users/users.go index 9faebbdab8b..ebf486e1de6 100644 --- a/src/go/plugins/system/users/users.go +++ b/src/go/plugins/system/users/users.go @@ -23,7 +23,7 @@ import ( "errors" "fmt" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) type Plugin struct { diff --git a/src/go/plugins/systemd/systemd.go b/src/go/plugins/systemd/systemd.go index 1c00aba813a..8e9c551370d 100644 --- a/src/go/plugins/systemd/systemd.go +++ b/src/go/plugins/systemd/systemd.go @@ -27,7 +27,7 @@ import ( "strings" "sync" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" "github.com/godbus/dbus" ) diff --git a/src/go/plugins/systemrun/systemrun.go b/src/go/plugins/systemrun/systemrun.go index 8707ecb4bab..e1c9817706e 100644 --- a/src/go/plugins/systemrun/systemrun.go +++ b/src/go/plugins/systemrun/systemrun.go @@ -23,9 +23,9 @@ import ( "fmt" "time" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/internal/agent" - "zabbix.com/pkg/conf" - "zabbix.com/pkg/plugin" "zabbix.com/pkg/zbxcmd" ) diff --git a/src/go/plugins/vfs/dev/dev.go b/src/go/plugins/vfs/dev/dev.go index f99f22bdd1c..91668adebbd 100644 --- a/src/go/plugins/vfs/dev/dev.go +++ b/src/go/plugins/vfs/dev/dev.go @@ -24,7 +24,7 @@ import ( "sync" "time" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) // Plugin - diff --git a/src/go/plugins/vfs/dir/count.go b/src/go/plugins/vfs/dir/count.go index 45438c83c2d..76777492a22 100644 --- a/src/go/plugins/vfs/dir/count.go +++ b/src/go/plugins/vfs/dir/count.go @@ -27,9 +27,9 @@ import ( "strings" "time" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) const ( diff --git a/src/go/plugins/vfs/dir/dir.go b/src/go/plugins/vfs/dir/dir.go index 40901c01d3b..84be106b5a6 100644 --- a/src/go/plugins/vfs/dir/dir.go +++ b/src/go/plugins/vfs/dir/dir.go @@ -25,8 +25,8 @@ import ( "regexp" "strings" - "zabbix.com/pkg/plugin" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/zbxerr" ) var impl Plugin diff --git a/src/go/plugins/vfs/dir/size.go b/src/go/plugins/vfs/dir/size.go index 2e69615f062..c558b620dd5 100644 --- a/src/go/plugins/vfs/dir/size.go +++ b/src/go/plugins/vfs/dir/size.go @@ -26,7 +26,7 @@ import ( "strconv" "strings" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) const ( diff --git a/src/go/plugins/vfs/file/cksum.go b/src/go/plugins/vfs/file/cksum.go index 4e71fc986d7..b493f9b8c6f 100644 --- a/src/go/plugins/vfs/file/cksum.go +++ b/src/go/plugins/vfs/file/cksum.go @@ -24,8 +24,8 @@ import ( "fmt" "time" - "zabbix.com/pkg/std" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/std" + "git.zabbix.com/ap/plugin-support/zbxerr" ) type checkSum func(file std.File, start time.Time, timeout int) (result interface{}, err error) diff --git a/src/go/plugins/vfs/file/cksum_test.go b/src/go/plugins/vfs/file/cksum_test.go index 05202c3ec8f..2e56bc01fc8 100644 --- a/src/go/plugins/vfs/file/cksum_test.go +++ b/src/go/plugins/vfs/file/cksum_test.go @@ -26,7 +26,7 @@ import ( "reflect" "testing" - "zabbix.com/pkg/std" + "git.zabbix.com/ap/plugin-support/std" ) var CrcFile = "1234" diff --git a/src/go/plugins/vfs/file/contents_test.go b/src/go/plugins/vfs/file/contents_test.go index 1980e02a91b..789abe3fab4 100644 --- a/src/go/plugins/vfs/file/contents_test.go +++ b/src/go/plugins/vfs/file/contents_test.go @@ -26,7 +26,7 @@ import ( "reflect" "testing" - "zabbix.com/pkg/std" + "git.zabbix.com/ap/plugin-support/std" ) func TestFileContentsEncoding(t *testing.T) { diff --git a/src/go/plugins/vfs/file/exists_test.go b/src/go/plugins/vfs/file/exists_test.go index 69fdce254c2..7b7ec73ab53 100644 --- a/src/go/plugins/vfs/file/exists_test.go +++ b/src/go/plugins/vfs/file/exists_test.go @@ -26,7 +26,7 @@ import ( "reflect" "testing" - "zabbix.com/pkg/std" + "git.zabbix.com/ap/plugin-support/std" ) func TestFileExists(t *testing.T) { diff --git a/src/go/plugins/vfs/file/file.go b/src/go/plugins/vfs/file/file.go index 8a581a47cb6..3fe6ef06c32 100644 --- a/src/go/plugins/vfs/file/file.go +++ b/src/go/plugins/vfs/file/file.go @@ -20,9 +20,9 @@ package file import ( - "zabbix.com/pkg/conf" - "zabbix.com/pkg/plugin" - "zabbix.com/pkg/std" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/std" ) type Options struct { diff --git a/src/go/plugins/vfs/file/get.go b/src/go/plugins/vfs/file/get.go index f9155838f7e..2759744aee9 100644 --- a/src/go/plugins/vfs/file/get.go +++ b/src/go/plugins/vfs/file/get.go @@ -25,7 +25,7 @@ import ( "os" "time" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) type jsTimeLoc time.Time diff --git a/src/go/plugins/vfs/file/get_windows.go b/src/go/plugins/vfs/file/get_windows.go index 078f291a5a9..b4dc0888b95 100644 --- a/src/go/plugins/vfs/file/get_windows.go +++ b/src/go/plugins/vfs/file/get_windows.go @@ -26,8 +26,8 @@ import ( "syscall" "time" + "git.zabbix.com/ap/plugin-support/zbxerr" "golang.org/x/sys/windows" - "zabbix.com/pkg/zbxerr" ) type userInfo struct { diff --git a/src/go/plugins/vfs/file/md5sum.go b/src/go/plugins/vfs/file/md5sum.go index 19a9580c03b..33c99c96d5c 100644 --- a/src/go/plugins/vfs/file/md5sum.go +++ b/src/go/plugins/vfs/file/md5sum.go @@ -26,8 +26,8 @@ import ( "io" "time" - "zabbix.com/pkg/std" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/std" + "git.zabbix.com/ap/plugin-support/zbxerr" ) func md5sum(file std.File, start time.Time, timeout int) (result interface{}, err error) { diff --git a/src/go/plugins/vfs/file/md5sum_test.go b/src/go/plugins/vfs/file/md5sum_test.go index cae28083644..461b2518c67 100644 --- a/src/go/plugins/vfs/file/md5sum_test.go +++ b/src/go/plugins/vfs/file/md5sum_test.go @@ -26,7 +26,7 @@ import ( "reflect" "testing" - "zabbix.com/pkg/std" + "git.zabbix.com/ap/plugin-support/std" ) var Md5File = "1234" diff --git a/src/go/plugins/vfs/file/owner_nix.go b/src/go/plugins/vfs/file/owner_nix.go index ac25587db15..621b2369a42 100644 --- a/src/go/plugins/vfs/file/owner_nix.go +++ b/src/go/plugins/vfs/file/owner_nix.go @@ -30,7 +30,7 @@ import ( "strconv" "syscall" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) // Export - diff --git a/src/go/plugins/vfs/file/owner_windows.go b/src/go/plugins/vfs/file/owner_windows.go index f9868073fd0..b1d5c57d23a 100644 --- a/src/go/plugins/vfs/file/owner_windows.go +++ b/src/go/plugins/vfs/file/owner_windows.go @@ -25,8 +25,8 @@ package file import ( "errors" "fmt" + "git.zabbix.com/ap/plugin-support/zbxerr" "golang.org/x/sys/windows" - "zabbix.com/pkg/zbxerr" ) // Export - diff --git a/src/go/plugins/vfs/file/permissions_nix.go b/src/go/plugins/vfs/file/permissions_nix.go index 76ab912072a..f9306ada382 100644 --- a/src/go/plugins/vfs/file/permissions_nix.go +++ b/src/go/plugins/vfs/file/permissions_nix.go @@ -27,7 +27,7 @@ import ( "fmt" "syscall" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) // mode2str - permission printable format diff --git a/src/go/plugins/vfs/file/permissions_windows.go b/src/go/plugins/vfs/file/permissions_windows.go index 7a3cb922b02..9387c6ad1c3 100644 --- a/src/go/plugins/vfs/file/permissions_windows.go +++ b/src/go/plugins/vfs/file/permissions_windows.go @@ -23,7 +23,7 @@ package file import ( - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) // exportPermissions - returns 4-digit string containing octal number with Unix permissions diff --git a/src/go/plugins/vfs/file/regexp_test.go b/src/go/plugins/vfs/file/regexp_test.go index 9b401bd9e01..ac5b8cc55cc 100644 --- a/src/go/plugins/vfs/file/regexp_test.go +++ b/src/go/plugins/vfs/file/regexp_test.go @@ -27,7 +27,7 @@ import ( "regexp" "testing" - "zabbix.com/pkg/std" + "git.zabbix.com/ap/plugin-support/std" "zabbix.com/pkg/zbxregexp" ) diff --git a/src/go/plugins/vfs/file/regmatch_test.go b/src/go/plugins/vfs/file/regmatch_test.go index 8bd74fdd630..188412052fb 100644 --- a/src/go/plugins/vfs/file/regmatch_test.go +++ b/src/go/plugins/vfs/file/regmatch_test.go @@ -26,7 +26,7 @@ import ( "reflect" "testing" - "zabbix.com/pkg/std" + "git.zabbix.com/ap/plugin-support/std" ) func TestFileRegmatch(t *testing.T) { diff --git a/src/go/plugins/vfs/file/sha256sum.go b/src/go/plugins/vfs/file/sha256sum.go index 01b5af28e5f..e50e57be0c1 100644 --- a/src/go/plugins/vfs/file/sha256sum.go +++ b/src/go/plugins/vfs/file/sha256sum.go @@ -26,7 +26,7 @@ import ( "io" "time" - "zabbix.com/pkg/std" + "git.zabbix.com/ap/plugin-support/std" ) func sha256sum(file std.File, start time.Time, timeout int) (result interface{}, err error) { diff --git a/src/go/plugins/vfs/file/size.go b/src/go/plugins/vfs/file/size.go index 1daf8fc29a8..981a5da5425 100644 --- a/src/go/plugins/vfs/file/size.go +++ b/src/go/plugins/vfs/file/size.go @@ -26,7 +26,7 @@ import ( "io" "os" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) // Export - diff --git a/src/go/plugins/vfs/file/size_test.go b/src/go/plugins/vfs/file/size_test.go index bcc9a1783c0..e6545367d3f 100644 --- a/src/go/plugins/vfs/file/size_test.go +++ b/src/go/plugins/vfs/file/size_test.go @@ -26,7 +26,7 @@ import ( "reflect" "testing" - "zabbix.com/pkg/std" + "git.zabbix.com/ap/plugin-support/std" ) func TestFileSize(t *testing.T) { diff --git a/src/go/plugins/vfs/file/time_nix.go b/src/go/plugins/vfs/file/time_nix.go index 33fa853c416..04862adeaa8 100644 --- a/src/go/plugins/vfs/file/time_nix.go +++ b/src/go/plugins/vfs/file/time_nix.go @@ -27,7 +27,7 @@ import ( "fmt" "syscall" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/zbxerr" ) // Export - diff --git a/src/go/plugins/vfs/file/time_test.go b/src/go/plugins/vfs/file/time_test.go index 4ee6977b98d..00be01e2cb0 100644 --- a/src/go/plugins/vfs/file/time_test.go +++ b/src/go/plugins/vfs/file/time_test.go @@ -26,7 +26,7 @@ import ( "reflect" "testing" - "zabbix.com/pkg/std" + "git.zabbix.com/ap/plugin-support/std" ) func TestFileModifyTime(t *testing.T) { diff --git a/src/go/plugins/vfs/file/time_windows.go b/src/go/plugins/vfs/file/time_windows.go index b03ab9fc387..3798aaf5d00 100644 --- a/src/go/plugins/vfs/file/time_windows.go +++ b/src/go/plugins/vfs/file/time_windows.go @@ -29,8 +29,8 @@ import ( "syscall" "unsafe" + "git.zabbix.com/ap/plugin-support/zbxerr" "golang.org/x/sys/windows" - "zabbix.com/pkg/zbxerr" ) const ( diff --git a/src/go/plugins/vfs/fs/fs.go b/src/go/plugins/vfs/fs/fs.go index cdab0191efd..be9fd8f8fcf 100644 --- a/src/go/plugins/vfs/fs/fs.go +++ b/src/go/plugins/vfs/fs/fs.go @@ -23,7 +23,7 @@ import ( "encoding/json" "errors" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" ) const ( diff --git a/src/go/plugins/vfs/fs/fs_nix.go b/src/go/plugins/vfs/fs/fs_nix.go index dc335f60c9f..5f26e966dd2 100644 --- a/src/go/plugins/vfs/fs/fs_nix.go +++ b/src/go/plugins/vfs/fs/fs_nix.go @@ -28,8 +28,8 @@ import ( "os" "strings" + "git.zabbix.com/ap/plugin-support/plugin" "golang.org/x/sys/unix" - "zabbix.com/pkg/plugin" ) func (p *Plugin) getFsInfoStats() (data []*FsInfoNew, err error) { diff --git a/src/go/plugins/vfs/fs/fs_windows.go b/src/go/plugins/vfs/fs/fs_windows.go index 9d75285f84e..bcae7ed65b0 100644 --- a/src/go/plugins/vfs/fs/fs_windows.go +++ b/src/go/plugins/vfs/fs/fs_windows.go @@ -22,8 +22,8 @@ package vfsfs import ( "syscall" + "git.zabbix.com/ap/plugin-support/plugin" "golang.org/x/sys/windows" - "zabbix.com/pkg/plugin" ) func getMountPaths() (paths []string, err error) { diff --git a/src/go/plugins/vm/memory/memory.go b/src/go/plugins/vm/memory/memory.go index f7e7e067903..5aac6bac2d2 100644 --- a/src/go/plugins/vm/memory/memory.go +++ b/src/go/plugins/vm/memory/memory.go @@ -20,8 +20,8 @@ package memory import ( - "zabbix.com/pkg/plugin" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/zbxerr" ) // Plugin - diff --git a/src/go/plugins/vm/memory/memory_linux.go b/src/go/plugins/vm/memory/memory_linux.go index a52cf1b3d24..fd67456a869 100644 --- a/src/go/plugins/vm/memory/memory_linux.go +++ b/src/go/plugins/vm/memory/memory_linux.go @@ -22,8 +22,8 @@ package memory import ( "errors" + "git.zabbix.com/ap/plugin-support/zbxerr" "zabbix.com/pkg/procfs" - "zabbix.com/pkg/zbxerr" ) func (p *Plugin) exportVMMemorySize(mode string) (result interface{}, err error) { diff --git a/src/go/plugins/vm/vmemory/vmemory_windows.go b/src/go/plugins/vm/vmemory/vmemory_windows.go index 5ec0a269f19..0772d76e499 100644 --- a/src/go/plugins/vm/vmemory/vmemory_windows.go +++ b/src/go/plugins/vm/vmemory/vmemory_windows.go @@ -20,9 +20,9 @@ package vmemory import ( - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/zbxerr" "zabbix.com/pkg/win32" - "zabbix.com/pkg/zbxerr" ) // Plugin - diff --git a/src/go/plugins/web/certificate/certificate.go b/src/go/plugins/web/certificate/certificate.go index 94d017bcfd6..18ee2aa45ff 100644 --- a/src/go/plugins/web/certificate/certificate.go +++ b/src/go/plugins/web/certificate/certificate.go @@ -30,10 +30,10 @@ import ( "strings" "time" - "zabbix.com/pkg/conf" - "zabbix.com/pkg/plugin" - "zabbix.com/pkg/uri" - "zabbix.com/pkg/zbxerr" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/plugin" + "git.zabbix.com/ap/plugin-support/uri" + "git.zabbix.com/ap/plugin-support/zbxerr" ) type Output struct { diff --git a/src/go/plugins/web/certificate/certificate_test.go b/src/go/plugins/web/certificate/certificate_test.go index 22a2c023a32..0cafb89fbca 100644 --- a/src/go/plugins/web/certificate/certificate_test.go +++ b/src/go/plugins/web/certificate/certificate_test.go @@ -21,7 +21,7 @@ package webcertificate import ( "testing" - "zabbix.com/pkg/uri" + "git.zabbix.com/ap/plugin-support/uri" ) func Test_getParameters(t *testing.T) { diff --git a/src/go/plugins/web/page/page.go b/src/go/plugins/web/page/page.go index 383322db347..a1c493a754b 100644 --- a/src/go/plugins/web/page/page.go +++ b/src/go/plugins/web/page/page.go @@ -27,9 +27,9 @@ import ( "strings" "time" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/internal/agent" - "zabbix.com/pkg/conf" - "zabbix.com/pkg/plugin" "zabbix.com/pkg/web" "zabbix.com/pkg/zbxregexp" ) diff --git a/src/go/plugins/windows/eventlog/eventlog_windows.go b/src/go/plugins/windows/eventlog/eventlog_windows.go index 9226936f3d8..cc410df78a3 100644 --- a/src/go/plugins/windows/eventlog/eventlog_windows.go +++ b/src/go/plugins/windows/eventlog/eventlog_windows.go @@ -25,11 +25,11 @@ import ( "time" "unsafe" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/internal/agent" - "zabbix.com/pkg/conf" "zabbix.com/pkg/glexpr" "zabbix.com/pkg/itemutil" - "zabbix.com/pkg/plugin" "zabbix.com/pkg/zbxlib" ) diff --git a/src/go/plugins/windows/perfinstance/perfinstance.go b/src/go/plugins/windows/perfinstance/perfinstance.go index 73c4674bb7d..b7f085ad886 100644 --- a/src/go/plugins/windows/perfinstance/perfinstance.go +++ b/src/go/plugins/windows/perfinstance/perfinstance.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows package perfinstance @@ -8,8 +9,8 @@ import ( "fmt" "time" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/pkg/pdh" - "zabbix.com/pkg/plugin" "zabbix.com/pkg/win32" ) diff --git a/src/go/plugins/windows/perfmon/perfmon.go b/src/go/plugins/windows/perfmon/perfmon.go index 5a8b8a0b4f0..e43fc2be649 100644 --- a/src/go/plugins/windows/perfmon/perfmon.go +++ b/src/go/plugins/windows/perfmon/perfmon.go @@ -1,3 +1,4 @@ +//go:build windows // +build windows /* @@ -27,8 +28,8 @@ import ( "sync" "time" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/pkg/pdh" - "zabbix.com/pkg/plugin" "zabbix.com/pkg/win32" ) diff --git a/src/go/plugins/windows/services/services_windows.go b/src/go/plugins/windows/services/services_windows.go index 5d1e04200f6..da24fc33c2f 100644 --- a/src/go/plugins/windows/services/services_windows.go +++ b/src/go/plugins/windows/services/services_windows.go @@ -26,10 +26,10 @@ import ( "syscall" "unsafe" + "git.zabbix.com/ap/plugin-support/plugin" "golang.org/x/sys/windows" "golang.org/x/sys/windows/svc" "golang.org/x/sys/windows/svc/mgr" - "zabbix.com/pkg/plugin" "zabbix.com/pkg/win32" ) diff --git a/src/go/plugins/windows/wmi/wmi.go b/src/go/plugins/windows/wmi/wmi.go index c0b0cf45b51..3ca05761849 100644 --- a/src/go/plugins/windows/wmi/wmi.go +++ b/src/go/plugins/windows/wmi/wmi.go @@ -23,7 +23,7 @@ import ( "encoding/json" "errors" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/pkg/wmi" ) diff --git a/src/go/plugins/zabbix/async/async.go b/src/go/plugins/zabbix/async/async.go index 62f020a4663..a3b7de1ec61 100644 --- a/src/go/plugins/zabbix/async/async.go +++ b/src/go/plugins/zabbix/async/async.go @@ -20,7 +20,7 @@ package zabbixasync import ( - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/pkg/zbxlib" ) diff --git a/src/go/plugins/zabbix/stats/stats.go b/src/go/plugins/zabbix/stats/stats.go index 865e7234644..817e2ac14ac 100644 --- a/src/go/plugins/zabbix/stats/stats.go +++ b/src/go/plugins/zabbix/stats/stats.go @@ -7,8 +7,8 @@ import ( "strconv" "time" - "zabbix.com/pkg/conf" - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/conf" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/pkg/zbxcomms" ) diff --git a/src/go/plugins/zabbix/sync/sync.go b/src/go/plugins/zabbix/sync/sync.go index dde57d8d57b..e9da3520615 100644 --- a/src/go/plugins/zabbix/sync/sync.go +++ b/src/go/plugins/zabbix/sync/sync.go @@ -20,7 +20,7 @@ package zabbixsync import ( - "zabbix.com/pkg/plugin" + "git.zabbix.com/ap/plugin-support/plugin" "zabbix.com/pkg/zbxlib" ) |