Skip to content

retailcrm/zabbix-metrics-collector

Repository files navigation

Zabbix Metrics Collector

Build Status Coverage GitHub release Go Report Card GoLang version pkg.go.dev

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.