Giter VIP home page Giter VIP logo

zabbix's Introduction

zabbix GoDoc Build Status Go Report Card

This Go package provides access to Zabbix API. Tested on Zabbix 2.0, 2.2, 2.4.

Install it: go get github.com/AlekSi/zabbix

You have to run tests before using this package โ€“ Zabbix API doesn't match documentation in few details, which are changing in patch releases. Tests are not expected to be destructive, but you are advised to run them against not-production instance or at least make a backup.

export TEST_ZABBIX_URL=http://localhost:8080/zabbix/api_jsonrpc.php
export TEST_ZABBIX_USER=Admin
export TEST_ZABBIX_PASSWORD=zabbix
export TEST_ZABBIX_VERBOSE=1
go test -v

TEST_ZABBIX_URL may contain HTTP basic auth username and password: http://username:password@host/api_jsonrpc.php. Also, in some setups URL should be like http://host/zabbix/api_jsonrpc.php.

Documentation is available on godoc.org. Also, Rafael Fernandes dos Santos wrote a great article about using and extending this package.

License: Simplified BSD License (see LICENSE).

zabbix's People

Contributors

aleksi avatar floriankoch avatar mcleod095 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

zabbix's Issues

Support for Zabbix 3.0

  • Add Zabbix 3.0 installation to setup.rb.
  • Check with Vagrant.
  • Check with Travis CI.
  • Update code.

Archiving project

Hi,

I'm going to archive that project soon. I stopped using Zabbix years ago, and have other commitments that require my attention.

I don't think I can promote any fork to the "official" status in the current state. If you want me to do that, please work on #14. Specifically, CI and tests should be rock-solid. That will require a considerable amount of efforts, so please be prepared for that.

Otherwise, I will just archive that project and link to https://github.com/AlekSi/zabbix/network.

Zabbix 2.4 apiinfo.version requires unauthenticated call

https://www.zabbix.com/documentation/2.2/manual/api/reference/apiinfo/version
This method is available to unauthenticated users and should be called without the auth parameter in the JSON-RPC request. Starting from Zabbix 2.4 the method will return an error if the auth parameter is given.

This is pretty annoying :(. Anyways, I'm open to working on this but wanted to get some thoughts together on the best way to approach it. I'd like to add an auth bool parameter to call.bytes and let it flex on using api.Auth[1], but this would require a slight change to all api methods that have been created. Thoughts?

[1]

func (api *API) callBytes(method string, params interface{}, auth bool) (b []byte, err error) {
        id := atomic.AddInt32(&api.id, 1)
        if auth {
                jsonobj := request{"2.0", method, params, api.Auth, id}
        } else {

                jsonobj := request{"2.0", method, params, "", id}
        }

Missing history support

Everything in the library works really well and it's easy to use. Only thing I'm missing is support for History objects. I wrote a simple version that does what I need, but I don't think it's complete enough to be added to master.

Couple things that need to be considered:

  • This version handles all Values as strings. This was trivial to implement since the reflector works great. It would also be quite easy to add version that checks history parameter and passes proper struct type to reflector. Problem with this is that it would need to either return interface{} (or an actual interface with getters), which is not how rest of the system works and is ugly. Another version would be to have Value as interface{}, in which case it would need to be casted to proper value each time, which is even worse.
  • I wrote a test, but since I'm using actual db and not an empty one it doesn't create new History object, thus it would fail on an empty db.

You can see the commit here: errnoh@9e6d3a1

Issue when creating hostgroup

When creating a host group using the api.HostGroupsCreate function I get

Error: -32602 (Invalid params.): Cannot set "internal" for host group "my.hosts.all".

I think the offending line is https://github.com/AlekSi/zabbix/blob/master/host_group.go#L20 where it needs to be marked as omitempty since it sounds like this might be a readonly field [1](but was erroneously noted otherwise if I'm reading the bug details correctly). If I call the api directly Api.Call("hostgroup.create", zabbix.Params{"name": hostgroup}) it works fine.

Using berngp/docker-zabbix container for testing if that helps ( zabbix ui shows 2.4.6 ).

[1]
https://support.zabbix.com/browse/ZBX-9017

Host structrure should include maintenance_status

The maintenance_status field of the host API should be returned as part of the host structure

`const (
Available AvailableType = 1
Unavailable AvailableType = 2

    Monitored   StatusType = 0
    Unmonitored StatusType = 1

    NotInMaint      StatusType = 0
    InMaint         StatusType = 1

)

// https://www.zabbix.com/documentation/2.2/manual/appendix/api/host/definitions
type Host struct {
HostId string json:"hostid,omitempty"
Host string json:"host"
Available AvailableType json:"available"
Error string json:"error"
Name string json:"name"
Status StatusType json:"status"
MaintenanceStatus StatusType json:"maintenance_status"

    // Fields below used only when creating hosts
    GroupIds   HostGroupIds   `json:"groups,omitempty"`
    Interfaces HostInterfaces `json:"interfaces,omitempty"`

}
`

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.