Project

zobbix

0.0
No commit activity in last 3 years
No release in over 3 years
Minimal wrapper for Zabbix Server API
2005
2006
2007
2008
2009
2010
2011
2012
2013
2014
2015
2016
2017
2018
2019
2020
2021
2022
2023
2024
 Dependencies

Development

~> 2.1
~> 5.8
~> 0.10
~> 10.0
~> 2.9

Runtime

~> 0.13
 Project Readme

Ruby Zabbix API Wrapper

Zabbix server requirements

Zabbix Server version should be 2.2 or 2.4

Installation

gem install zobbix

Usage

require 'zobbix'

zbx = Zobbix.connect(uri:      'http://localhost/zabbix',
                     user:     'Admin',
                     password: 'zabbix')

method = 'trigger.create'
params = {
  description: 'Name of the trigger',
  expression: 'Linux Template:system.cpu.util[all,idle,avg1].avg(120)}<5'
}

response = zbx.request(methods, params)

response.class #=> Zobbix::ApiResponse

version = zbx.request('apiinfo.version')

version.result #=> "2.4.6"
version.success? #=> true

error = zbx.request('unknown.method')
error.error? #=> true
error.result #=> nil
error.error_code #=> -32602
error.error_message #=> "Invalid params."
error.error_data #=> 'Incorrect API "unknown".'
error.raise_exception #=> Zobbix::Error: API returned error. Code: -32602 Message: Invalid params. Data: Incorrect API "unknown".

API Exceptions

# Enable API exceptions

zbx = Zobbix.connect(uri:      'http://localhost/zabbix',
                     user:     'Admin',
                     password: 'zabbix',
                     raise_exceptions: true)
zbx.request('unknown.method') #=> Zobbix::Error: API returned error. Code: -32602 Message: Invalid params. Data: Incorrect API "unknown".

Zabbix Server API

API reference (2.2)

API reference (2.4)