Skip to content

Eigenbahn/zabbix-api-client

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

32 Commits
 
 
 
 
 
 
 
 
 
 

Repository files navigation

zabbix-api-client

Client library wrapper around Zabbix HTTP API.

Installation

Add the following dependency to your project.clj file:

[eigenbahn/zabbix-api-client "1.0.0"]

General Usage

Connection

All methods take a connection conn as a first argument. It's just a simple map in the form:

{:url "<prometheus_base_url>" :user "<api_user>" :password "<api_password>"}

The :url field value must contain the base URL of the Zabbix instance. It is not expected to contain the "/api_jsonrpc.php" part.

So to connect to a local Zabbix instance running under http://company.com/zabbix/:

(def zabbix-conn {:url "http://company.com/zabbix" :user "Admin" :password "zabbix"})

Authentication

Authentication is done systematically before each API call.

Manual retrieval of an auth token is possible by calling the auth method.

Example usage

API version

(api-version zabbix-conn)
;; -> "5.2.5"

auth

(auth zabbix-conn)
;; -> "dd021d412befeea7a016d18b929a421c"

templates list

(get-templates zabbix-conn)
;; -> [{"templateid" "10001"
;;      "name" "Linux by Zabbix agent"
;;      "description" "Official Linux template [...]"
;;      ;; [...]},
;;    ;; [...]
;;    ]

applications list

(get-templates zabbix-conn)
;; -> [{"applicationid" "345",
;;      "flags" "0",
;;      "name" "Zabbix server",
;;      "hostid" "10084",
;;      "templateids" ["179"]},
;;     ;; [...]
;;    ]

And with filtering options:

;; only those on (host) templates:
(get-templates zabbix-conn :templated true)

;; only those on hosts (not templates):
(get-templates zabbix-conn :templated false)

;; only those on hosts and inherited from templates:
(get-templates zabbix-conn :inherited true)

;; only those local to hosts (not inherited):
(get-templates zabbix-conn :templated false :inherited false)

;; only those on templates but with no host (yet) inheriting them:
(get-templates zabbix-conn :templated true :inherited false)

hosts list

(get-hosts zabbix-conn)
;; -> [{"hostid" "10004"
;;      "name" "Zabbix server"
;;      "status" "0"
;;      ;; [...]},
;;    ;; [...]
;;    ]

About

Zabbix HTTP API client for Clojure

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published