This library provides easy-to-use wrapper for sending metrics to the Zabbix server.
Usage:
package main
import (
"github.com/blacked/go-zabbix"
"github.com/retailcrm/zabbix-metrics-collector"
)
func main() {
go metrics("app", "zabbix_server_docker", 10051)
// some other logic here
}
func metrics(appHostZabbix, host string, port, intervalSeconds int) {
sender := zabbix.NewSender(host, port)
collector := metrics.NewMemoryCollector(intervalSeconds)
proc := metrics.NewZabbix([]metrics.Collector{collector}, sender, appHostZabbix, intervalSeconds, metrics.DefaultLogger)
proc.Run()
}
To collect other metrics you must implement metrics.Collector
interface and collect relevant data there. The collector
must be goroutine-safe.
You also can implement your own transport by using metrics.Transport
interface. It may be useful in some cases.
The included Zabbix transport will work just fine for the majority of use-cases.