-
Notifications
You must be signed in to change notification settings - Fork 2
Build binary
By default the openITCOCKPIT Monitoring Agent will be compiled into a static linked, zero dependencies single executable binary. It is not required to have Go (or any other libraries) installed on the target device.
CGO_ENABLED=0 go build -o agent main.go
The binary can only be execute on the same platform, as it was compiled on. If you want to build the binary for a different operating system or cpu architecture please read the Cross compile section.
To Enable libvirt monitoring the libvirt library is required to be present on the target device. By default libvirt support is disabled, otherwise the Agent would not be free of dependencies. If you want to enable support for libvirt monitoring, you have to compile the agent by your self.
It is recommended to build the binary on the same platform, as you want to use later. For example, if you want to monitor libvirt running on a CentOS 7.9 you should build the binary also on an CentOS 7.9
yum install gcc libvirt-devel
apt-get install gcc libvirt-dev
go build -o agent -tags libvirt main.go
You can use the command ldd agent
to get a list of all dynamic linked libraries
On macOS the agent is not free of dependencies. For collecting For collecting statistics about Disk IO some system libraries are required.
These libraries are available on macOS by default so we decided to enable Disk IO monitoring by default.
go build -o agent main.go
You can use the command otool -L agent
to get a list of all dynamic linked libraries
With cross compile you can build the binary for a different operating system or even cpu architecture.
CGO_ENABLED=0 GOARCH=386 go build -o agent main.go
CGO_ENABLED=0 GOARCH=arm64 go build -o agent main.go
Windows ARM devices have to use the i386 Version for now. Several libraries we're depending on require changes.
- github.com/go-ole/go-ole
- github.com/shirou/gopsutil/v3
We could also do this, as the changes should be minor, but we don't have any test devices for this right now.
CGO_ENABLED=0 GOOS=darwin GOARCH=amd64 go build -o agent main.go
See the full list of supported operating systems and cpu architectures of the Go programming language.
Please notice: The openITCOCKPIT Monitoring Agent was built to run on Linux, Windows and macOS with the main focus to be compatible with amd64 and arm64 processors. If you try to build the code for any other architecture or OS, please keep in mind that maybe the underlying libraries needs to be patched as well.
This section contain real world examples of how to compile the openITCOCKPIT Monitoring Agent on different hardware platforms.
Installing go
wget https://golang.org/dl/go1.16.3.linux-armv6l.tar.gz
tar -C /usr/local -xzf go1.16.3.linux-armv6l.tar.gz
export PATH=$PATH:/usr/local/go/bin
Build openITCOCKPIT Monitoring Agent for ARMv6
CGO_ENABLED=0 GOARCH=arm GOARM=6 go build -o openitcockpit-agent main.go
More information about go on ARM can be found here: https://github.com/golang/go/wiki/GoArm