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")
}
Output:
Index ¶
Examples ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Start ¶
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")
}
Output:
Types ¶
type ItemFunc ¶ added in v1.1.0
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.