zabbix

package module
v0.0.0-...-3c6a95e Latest Latest
Warning

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

Go to latest
Published: Jan 18, 2017 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

This section is empty.

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 cunstructor.

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
}

Sender class.

func NewSender

func NewSender(host string, port int) *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