Coder Social home page Coder Social logo

zabbix.jl's Introduction

License: MIT Build Status codecov.io GitHub contributors GitHub issues GitHub version

ForTheBadge built-by-developers

Zabbix.jl

Julia bindings for Zabbix API 🔥

The package has been tested over version 3.2.11.

Installation

Since Zabbix is registered in METADATA.jl, you can directly install it like,

julia> Pkg.add("Zabbix")

Update

julia> Pkg.update("Zabbix")

How it works?

Please make sure that you have a valid Zabbix URL available along with the right access levels. In case you have only read access on the zabbix server, you may not be able to use configuration and management operations. Full read & write access is desired.

Creating a ZabbixAPI instance

julia> zabbix = Zabbix.ZabbixAPI("http://SERVER_IP/zabbix/api_jsonrpc.php","USERNAME","******",false)
Zabbix.ZabbixAPI("http://SERVER_IP/zabbix/api_jsonrpc.php", "USERNAME","******",false, 0, Dict("Content-Type"=>"application/json-rpc"), "2.0")

Note that I have set verbose=false. However, by default we have, verbose=true. Hence only set verbose=false if you are okay continuing without the info messages.

Get the Zabbix API's version Info

julia> Zabbix.api_version(zabbix)
v"3.2.11"

julia>typeof(Zabbix.api_version(zabbix))
VersionNumber

Get the auth token

julia> Zabbix.auth_token(zabbix)
"e8f8354d66f7fac2691f5c7441b8dfa0"

Get all hosts for a user

julia> Zabbix.get_all_hosts(zabbix)
Dict{String,Any} with 3 entries:
  "id"      => 1
  "jsonrpc" => "2.0"
  "result"  => Any[Dict{String,Any}(Pair{String,Any}("host", "localhost"),Pair{String,Any}("interfaces", Any[Dict{String,Any}(Pair{String,An

Make any request to the zabbix server

The make_request function requires you to pass methods(aka Zabbix methods like hosts.get etc) and params ie. parameters in a form of a Dict() object. A easy sample is given on Zabbix's official website

# another way to get the zabbix version
julia> Zabbix.make_request(zabbix, "apiinfo.version", Dict())
v"3.2.11"

# getting the details of a host given its hostname
julia> method = "host.get"
"host.get"

julia> params = Dict("output"=>"extend", "filter"=>Dict("host"=>["localhost"]))
Dict{String,Any} with 2 entries:
  "output" => "extend"
  "filter" => Dict("host"=>String["localhost"])

julia> Zabbix.make_request(zabbix, method, params)
Dict{String,Any} with 3 entries:
  "id"      => 1
  "jsonrpc" => "2.0"
  "result"  => Any[Dict{String,Any}(Pair{String,Any}("lastaccess", "0"),Pair{String,Any}("ipmi_privilege", "2"),Pair{String,Any}("ipmi_error…

 julia> Zabbix.make_request(zabbix, method, params)["result"][1]
Dict{String,Any} with 39 entries:
  "lastaccess"         => "0"
  "ipmi_privilege"     => "2"
  "ipmi_errors_from"   => "0"
  "snmp_available"     => "0"
  "templateid"         => "0"
  "disable_until"      => "0"
  "jmx_available"      => "0"
  "maintenance_from"   => "0"
  "tls_psk_identity"   => ""
  "available"          => "1"
  "ipmi_password"      => ""
  "tls_accept"         => "1"
  "name"               => "localhost"
  "tls_issuer"         => ""
  "status"             => "0"
  "maintenance_status" => "0"
  "hostid"             => "10084"
  "tls_connect"        => "1"
  "ipmi_available"     => "0"
  "description"        => ""
  "errors_from"        => "0"
  "maintenance_type"   => "0"
  "error"              => ""
  "ipmi_username"      => ""
  "snmp_disable_until" => "0"
  "snmp_error"         => ""
  "tls_subject"        => ""
  "maintenanceid"      => "0"
  "host"               => "localhost"
  "jmx_error"          => ""
  "ipmi_disable_until" => "0"
  "snmp_errors_from"   => "0"
  ⋮                    => ⋮

julia> Zabbix.make_request(zabbix, method, params)["result"][1]["hostid"]
"10084"

Facing issues? 😱

  • Open a PR with the detailed expaination of the issue
  • Reach me out here

zabbix.jl's People

Contributors

rahulkp220 avatar jpsamaroo avatar

Watchers

James Cloos avatar  avatar  avatar

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.