Coder Social home page Coder Social logo

go-zabbix's Introduction

go-zabbix

Golang package, implement zabbix sender protocol for send metrics to zabbix.

Example:

package main

import (
	"errors"
	"fmt"
	"time"

	"github.com/datadope-io/go-zabbix/v2"
)

const (
	zabbixAddress = `localhost:10051`
	agentActive   = true
	trapper       = false
)

func main() {
	var metrics []*zabbix.Metric
	metrics = append(metrics, zabbix.NewMetric("localhost", "cpu", "1.22", agentActive, time.Now().Unix()))
	metrics = append(metrics, zabbix.NewMetric("localhost", "status", "OK", agentActive))
	metrics = append(metrics, zabbix.NewMetric("localhost", "someTrapper", "3.14", trapper))

	// Send metrics to zabbix
	z := zabbix.NewSender(zabbixAddress)
	resActive, resTrapper, err := z.SendMetrics(metrics)

	fmt.Printf("Agent active, response=%s, info=%s\n", resActive.Response, resActive.Info)
	if errors.Is(err, zabbix.ErrActive) {
		fmt.Printf("Error:\n%v\n", err)
	}

	fmt.Printf("\n----\n\n")

	fmt.Printf("Trapper, response=%s, info=%s\n", resTrapper.Response, resTrapper.Info)
	if errors.Is(err, zabbix.ErrTrapper) {
		fmt.Printf("Error:\n%v\n", err)
	}
}

CHANGELOG

v2.0.1 - 2023-08-11

  • Go mimimum version 1.20
  • Retracted v2.0.0
  • Fix some errors format

v2.0.0 - 2023-08-10

  • New v2 with better error handling, NewSender and NewSenderTimeout using address (instead of host+port) and SendMetrics returning both errors (active + trappers) joined.

v1.6.0 - 2023-08-09

  • New methods to create a Sender using an address instead of host and port: NewSenderAddr and NewSenderAddrTimeout.

v1.5.1 - 2021-10-20

  • Better error handling if Zabbix server response is not valid

v1.4.0 - 2021-10-20

  • Compatible with go modules.

v1.3.0 - 2020-10-20

  • Now Active/Trapper response is formated in Response,Info strings and could be translated int ResponseInfo struct with Failed/Completed/Processed/Spent time.

go-zabbix's People

Contributors

adrianlzt avatar adubkov avatar komkom avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.