Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

github.com/cavaliercoder/go-zabbix

Package Overview
Dependencies
Alerts
File Explorer
Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

github.com/cavaliercoder/go-zabbix

  • v0.0.0-20230131181515-93725c39d639
  • Source
  • Go
  • Socket score

Version published
Created
Source

go-zabbix

Go bindings for the Zabbix API

go report card 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 asinterface{} 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 (
	"crypto/tls"
	"fmt"
	"log"
	"net/http"

	"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)
	}

	version, err := session.GetVersion()

	if err != nil {
		panic(err)
	}

	fmt.Printf("Connected to Zabbix API v%s", version)

	// Use session builder with caching.
	// You can use own cache by implementing SessionAbstractCache interface
	// Optionally an http.Client can be passed to the builder, allowing to skip TLS verification,
	// pass proxy settings, etc.

	client := &http.Client{
		Transport: &http.Transport{
			TLSClientConfig: &tls.Config{
				InsecureSkipVerify: true
			}
		}
	}

	cache := zabbix.NewSessionFileCache().SetFilePath("./zabbix_session")
	session, err := zabbix.CreateClient("http://zabbix/api_jsonrpc.php").
		WithCache(cache).
		WithHTTPClient(client).
		WithCredentials("Admin", "zabbix").
		Connect()
	if err != nil {
		log.Fatalf("%v\n", err)
	}

	version, err := session.GetVersion()

	if err != nil {
		log.Fatalf("%v\n", err)
	}

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

License

Released under the GNU GPL License

FAQs

Package last updated on 31 Jan 2023

Did you know?

Socket

Socket for GitHub automatically highlights issues in each pull request and monitors the health of all your open source dependencies. Discover the contents of your packages and block harmful activity before you install or update your dependencies.

Install

Related posts

SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc