Help us shape the future of Go! Take the 2026 Go Developer Survey

zabbix

package module
v0.0.0-...-c9060d7 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Oct 5, 2019 License: MIT Imports: 6 Imported by: 0

README

go-zabbix

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

Example:

package main

import (
    "time"
    . "github.com/blacked/go-zabbix"
)

const (
    defaultHost  = `localhost`
    defaultPort  = 10051
)

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

    // Create instance of Packet class
    packet := NewPacket(metrics)

    // Send packet to zabbix
    z := NewSender(defaultHost, defaultPort)
    z.Send(packet)
}

Documentation

Overview

Package implement zabbix sender protocol for send metrics to zabbix.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func SendLLD

func SendLLD(zabbixTargetHost string, zabbixProxy string, key string, data []interface{}, desc string, debug bool)

Send discover data to Zabbix

func SendMetrics

func SendMetrics(zabbixProxy string, ml []*Metric, desc string, debug bool)

Send Metrics with trapper to Zabix

Types

type Metric

type Metric struct {
	Host  string `json:"host"`
	Key   string `json:"key"`
	Value string `json:"value"`
	Clock int64  `json:"clock"`
}

Metric class.

func NewMetric

func NewMetric(host, key, value string, clock ...int64) *Metric

Metric class constructor.

type Packet

type Packet struct {
	Request string    `json:"request"`
	Data    []*Metric `json:"data"`
	Clock   int64     `json:"clock"`
}

Packet class.

func NewPacket

func NewPacket(data []*Metric, clock ...int64) *Packet

Packet class constructor.

func (*Packet) DataLen

func (p *Packet) DataLen() []byte

DataLen Packet class method, return 8 bytes with packet length in little endian order.

type Sender

type Sender struct {
	Host  string
	Port  int
	Debug bool
}

Sender class.

func NewSender

func NewSender(host string, port int, debug bool) *Sender

Sender class constructor.

func (*Sender) Send

func (s *Sender) Send(packet *Packet) (res []byte, err error)

Method Sender class, send packet to zabbix.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL