Skip to content

neogan74/go-zabbix

 
 

Repository files navigation

go-zabbix

Go bindings for the Zabbix API

go report card cover.run GPL license GoDoc

Overview

This project provides bindings to interoperate between programs written in Go language and the Zabbix monitoring API.

A number of Zabbix API bindings already exist for Go with varying levels of maturity. This project aims to provide an alternative implementation which is stable, fast, and allows for loose typing (using types such as interface{} or map[string]interface{}) as well as strong types (such as Host or Event).

The package aims to have comprehensive coverage of Zabbix API methods from v1.8 through to v3.0 without introducing limitations to the native API methods.

Getting started

package main

import (
	"fmt"
	"time"

	"github.com/cavaliercoder/go-zabbix"
)

func main() {
	// Default approach - without session caching
	session, err := zabbix.NewSession("http://zabbix/api_jsonrpc.php", "Admin", "zabbix")
	if err != nil {
		panic(err)
	}

	// Use session builder with caching.
	// You can use own cache by implementing SessionAbstractCache interface

	cache := zabbix.NewSessionFileCache().SetFilePath("./zabbix_session")
	session, err := zabbix.CreateClient("http://zabbix/api_jsonrpc.php").
		WithCache(cache).
		WithCredentials("Admin", "zabbix").
		WithTimeout(5 * time.Second).
		Connect()

	fmt.Printf("Connected to Zabbix API v%s", session.Version())
}

License

Released under the GNU GPL License

About

Go bindings for the Zabbix API

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages

  • Go 99.5%
  • Makefile 0.5%