zbx

package module
v1.1.2 Latest Latest
Warning

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

Go to latest
Published: Aug 20, 2021 License: MIT Imports: 6 Imported by: 0

README

zbx

Go Report Card Godoc Releases LICENSE

Package zbx is a Zabbix Agent implementation in golang that allows your application to act as a zabbix agent and respond to simple requests.

It is compatible with Zabbix version 4 and newer.

Documentation

Overview

Package zbx is a Zabbix Agent implementation in golang that allows your application to act as a zabbix agent and respond to simple requests.

It is compatible with Zabbix version 4 and newer, but it does not support encryption or compression.

Example
package main

import (
	"runtime"

	"github.com/ecnepsnai/zbx"
)

func main() {
	getItem := func(itemKey string) (interface{}, error) {
		if itemKey == "agent.ping" {
			return "1", nil
		} else if itemKey == "runtime.version" {
			return runtime.Version, nil
		}

		return nil, nil
	}

	zbx.Start(getItem, "0.0.0.0:10050")
}

Index

Examples

Constants

This section is empty.

Variables

This section is empty.

Functions

func Start

func Start(itemFunc ItemFunc, address string) error

Start the Zabbix agent on the specified address. Will block and always return on error. Will panic if itemFunc is nil.

Example
package main

import (
	"runtime"

	"github.com/ecnepsnai/zbx"
)

func main() {
	getItem := func(itemKey string) (interface{}, error) {
		if itemKey == "agent.ping" {
			return "1", nil
		} else if itemKey == "runtime.version" {
			return runtime.Version, nil
		}

		return nil, nil
	}

	zbx.Start(getItem, "0.0.0.0:10050")
}

Types

type ItemFunc added in v1.1.0

type ItemFunc func(key string) (interface{}, error)

ItemFunc describes the method invoked when the Zabbix Server (or proxy) is requesting an item from this agent. The returned interface be encoded as a string and returned to the server.

If error is not nil, it will be sent back to the server. If (nil, nil) is returned then it is assumed the key is unknown.

Jump to

Keyboard shortcuts

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