-
Incident report
-
Resolution: Unresolved
-
Trivial
-
None
-
4.4.0, 4.4.1
-
None
Hi.
I know that currently the support of Zabbix agent 2 is experimental and it is supported in Linux platform only.
Just want to check if there is a plan to support others OS platforms.
Our Go expert on FreeBSD ports looked into, and for building Agent 2 on FreeBSD, there are some tweaks to be made.
- Change hardcoded paths for _linux.go.
- Replace syscall package which is not portable, for golang.org/x/sys/unix instead
These are the changes that were made, maybe it helps.
cp ${FILESDIR}/uname_freebsd.go ${WRKSRC}/go/src/zabbix/plugins/system/uname
ln -s ${WRKSRC}/go/src/zabbix/plugins/net/netif/netif_linux.go ${WRKSRC}/go/src/zabbix/plugins/net/netif/netif_freebsd.go
ln -s ${WRKSRC}/go/src/zabbix/plugins/system/cpucollector/cpu_linux.go ${WRKSRC}/go/src/zabbix/plugins/system/cpucollector/cpu_freebsd.go
ln -s ${WRKSRC}/go/src/zabbix/plugins/system/uptime/uptime_linux.go ${WRKSRC}/go/src/zabbix/plugins/system/uptime/uptime_freebsd.go
ln -s ${WRKSRC}/go/src/zabbix/plugins/kernel/kernel_linux.go ${WRKSRC}/go/src/zabbix/plugins/kernel/kernel_freebsd.go
ln -s ${WRKSRC}/go/src/zabbix/plugins/vfs/dev/dev_linux.go ${WRKSRC}/go/src/zabbix/plugins/vfs/dev/dev_freebsd.go
— net-mgmt/zabbix44-server/files/patch-configure.ac (nonexistent)
++ net-mgmt/zabbix44-server/files/patch-configure.ac (working copy)
@@ -0,0 +1,13 @@
— configure.ac.orig 2019-11-15 21:40:54 UTC
+++ configure.ac
@@1813,8 +1813,8 @@ CGO_LDFLAGS="-Wl,-start-group \
\${abs_top_builddir}/src/libs/zbxsysinfo/libzbxagentsysinfo.a \
\${abs_top_builddir}/src/libs/zbxsysinfo/common/libcommonsysinfo.a \
\${abs_top_builddir}/src/libs/zbxsysinfo/simple/libsimplesysinfo.a \
- \${abs_top_builddir}/src/libs/zbxsysinfo/linux/libspechostnamesysinfo.a \
- \${abs_top_builddir}/src/libs/zbxsysinfo/linux/libspecsysinfo.a \
+ \${abs_top_builddir}/src/libs/zbxsysinfo/freebsd/libspechostnamesysinfo.a \
+ \${abs_top_builddir}/src/libs/zbxsysinfo/freebsd/libspecsysinfo.a \
\${abs_top_builddir}/src/libs/zbxexec/libzbxexec.a \
\${abs_top_builddir}/src/libs/zbxalgo/libzbxalgo.a \
\${abs_top_builddir}/src/libs/zbxjson/libzbxjson.a \
— net-mgmt/zabbix44-server/files/patch-go_src_zabbix_pkg_std_os.go (nonexistent)
++ net-mgmt/zabbix44-server/files/patch-go_src_zabbix_pkg_std_os.go (working copy)
@@ -0,0 +1,22 @@
— go/src/zabbix/pkg/std/os.go.orig 2019-11-15 18:35:32 UTC
+++ go/src/zabbix/pkg/std/os.go
@@ -26,8 +26,9 @@ import (
"errors"
"io"
"os"
- "syscall"
"time"
+
+ "golang.org/x/sys/unix"
)// File interface is used to mock os.File structure
@@ -89,7 +90,7 @@ type fileStat structUnknown macro: { size int64 mode FileMode modTime time.Time - sys syscall.Stat_t + sys unix.Stat_t }func (o *mockOs) Open(name string) (File, error) {
— net-mgmt/zabbix44-server/files/patch-go_src_zabbix_pkg_tls_tls.go (nonexistent)
++ net-mgmt/zabbix44-server/files/patch-go_src_zabbix_pkg_tls_tls.go (working copy)
@@ -0,0 +1,11 @@
— go/src/zabbix/pkg/tls/tls.go.orig 2019-11-15 21:59:11 UTC
+++ go/src/zabbix/pkg/tls/tls.go
@@ -73,7 +73,7 @@ static int tls_init(void)tls_crypto_init_msg = "OpenSSL library successfully initialized";
return 0;
-#elif // OpenSSL 1.0.1/1.0.2 (before 1.1.0) or LibreSSL - currently not supported
+#else // OpenSSL 1.0.1/1.0.2 (before 1.1.0) or LibreSSL - currently not supported
zbx_crypto_lib_init_msg = "OpenSSL older than 1.1.0 and LibreSSL currently are not supported";
return -1;
#endif
— net-mgmt/zabbix44-server/files/patch-go_src_zabbix_pkg_zbxlib_checks.go (nonexistent)
++ net-mgmt/zabbix44-server/files/patch-go_src_zabbix_pkg_zbxlib_checks.go (working copy)
@@ -0,0 +1,11 @@
— go/src/zabbix/pkg/zbxlib/checks.go.orig 2019-11-15 21:53:47 UTC
+++ go/src/zabbix/pkg/zbxlib/checks.go
@@ -22,7 +22,7 @@ package zbxlib
/* cspell:disable *//*
-#cgo CFLAGS: -I${SRCDIR}/../../../../../include
+#cgo CFLAGS: -I${SRCDIR}/../../../../../include -I/usr/local/include#include "common.h"
#include "sysinfo.h"
— net-mgmt/zabbix44-server/files/patch-go_src_zabbix_pkg_zbxlib_globals.go (nonexistent)
++ net-mgmt/zabbix44-server/files/patch-go_src_zabbix_pkg_zbxlib_globals.go (working copy)
@@ -0,0 +1,13 @@
— go/src/zabbix/pkg/zbxlib/globals.go.orig 2019-11-15 21:36:36 UTC
+++ go/src/zabbix/pkg/zbxlib/globals.go
@@ -38,8 +38,8 @@ package zbxlib
#cgo LDFLAGS: ${SRCDIR}/../../../../../src/libs/zbxsysinfo/libzbxagentsysinfo.a
#cgo LDFLAGS: ${SRCDIR}/../../../../../src/libs/zbxsysinfo/common/libcommonsysinfo.a
#cgo LDFLAGS: ${SRCDIR}/../../../../../src/libs/zbxsysinfo/simple/libsimplesysinfo.a
-#cgo LDFLAGS: ${SRCDIR}/../../../../../src/libs/zbxsysinfo/linux/libspechostnamesysinfo.a
-#cgo LDFLAGS: ${SRCDIR}/../../../../../src/libs/zbxsysinfo/linux/libspecsysinfo.a
+#cgo LDFLAGS: ${SRCDIR}/../../../../../src/libs/zbxsysinfo/freebsd/libspechostnamesysinfo.a
+#cgo LDFLAGS: ${SRCDIR}/../../../../../src/libs/zbxsysinfo/freebsd/libspecsysinfo.a
#cgo LDFLAGS: ${SRCDIR}/../../../../../src/libs/zbxexec/libzbxexec.a
#cgo LDFLAGS: ${SRCDIR}/../../../../../src/libs/zbxalgo/libzbxalgo.a
#cgo LDFLAGS: ${SRCDIR}/../../../../../src/libs/zbxjson/libzbxjson.a
— net-mgmt/zabbix44-server/files/patch-go_src_zabbix_plugins_vfs_file_time.go (nonexistent)
++ net-mgmt/zabbix44-server/files/patch-go_src_zabbix_plugins_vfs_file_time.go (working copy)
@@ -0,0 +1,24 @@
— go/src/zabbix/plugins/vfs/file/time.go.orig 2019-11-15 22:17:30 UTC
+++ go/src/zabbix/plugins/vfs/file/time.go
@@ -22,7 +22,8 @@ package file
import (
"errors"
"fmt"
- "syscall"
+
+ "golang.org/x/sys/unix"
)// Export -
@@ -39,9 +40,9 @@ func (p *Plugin) exportTime(params []string) (result i
if len(params) == 1 || params[1] == "" || params[1] == "modify"Unknown macro: { return f.ModTime().Unix(), nil }else if params[1] == "access"
Unknown macro: { - return f.Sys().(*syscall.Stat_t).Atim.Sec, nil + return f.Sys().(*unix.Stat_t).Atim.Sec, nil }else if params[1] == "change"
Unknown macro: { - return f.Sys().(*syscall.Stat_t).Ctim.Sec, nil + return f.Sys().(*unix.Stat_t).Ctim.Sec, nil }else
Unknown macro: { return nil, errors.New("Invalid second parameter.") }
— net-mgmt/zabbix44-server/files/uname_freebsd.go (nonexistent)
++ net-mgmt/zabbix44-server/files/uname_freebsd.go (working copy)
@@ -0,0 +1,70 @@
/*
- Zabbix
- Copyright (C) 2001-2019 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 uname
import (
"fmt""golang.org/x/sys/unix"
)func arrayToString(unameArray *[256]byte) string {
var byteString [65]byte
var indexLength int
for ; indexLength < len(unameArray); indexLength++ {
if 0 == unameArray[indexLength]Unknown macro: { break }byteString[indexLength] = uint8(unameArray[indexLength])
}
return string(byteString[:indexLength])
}func getUname() (uname string, err error) {
var utsname unix.Utsname
if err = unix.Uname(&utsname); err != nilUnknown macro: { err = fmt.Errorf("Cannot obtain system information}uname = fmt.Sprintf("%s %s %s %s %s", arrayToString(&utsname.Sysname), arrayToString(&utsname.Nodename),
arrayToString(&utsname.Release), arrayToString(&utsname.Version), arrayToString(&utsname.Machine))return uname, nil
}func getHostname() (hostname string, err error) {
var utsname unix.Utsname
if err = unix.Uname(&utsname); err != nilUnknown macro: { err = fmt.Errorf("Cannot obtain system information}return arrayToString(&utsname.Nodename), nil
}func getSwArch() (uname string, err error) {
var utsname unix.Utsname
if err = unix.Uname(&utsname); err != nilUnknown macro: { err = fmt.Errorf("Cannot obtain system information}return arrayToString(&utsname.Machine), nil
}
This was just a test, others parts will need changes as well.
Thanks for your time.