Zabbix::Client
This is a simple client of Zabbix API.
Installation
Add this line to your application's Gemfile:
gem 'zabbix-client'
And then execute:
$ bundle
Or install it yourself as:
$ gem install zabbix-client
Usage
require 'zabbix/client'
client = Zabbix::Client.new('http://localhost/zabbix/api_jsonrpc.php')
# https://www.zabbix.com/documentation/2.0/manual/appendix/api/user/login
client.user.login(user: 'Admin', password: 'zabbix')
# https://www.zabbix.com/documentation/2.0/manual/appendix/api/apiinfo/version
p client.apiinfo.version #=> "2.0.12"
# https://www.zabbix.com/documentation/2.0/manual/appendix/api/template/getobjects
p client.template.getobjects(host: ['Template OS Linux'])
#=> [{"hostid"=>"10001",
# "proxy_hostid"=>"0",
# "host"=>"Template OS Linux",
# ...
Use proxy
client = Zabbix::Client.new(
'http://localhost/zabbix/api_jsonrpc.php',
proxy_user: 'username', proxy_password: 'password'
)
Basic auth
client = Zabbix::Client.new(
'http://localhost/zabbix/api_jsonrpc.php',
basic_auth_user: 'username', basic_auth_password: 'password'
)
Debug mode
client = Zabbix::Client.new(
'http://localhost/zabbix/api_jsonrpc.php',
debug: true
)