Class: SkyZabbix::Client

Inherits:
Object
  • Object
show all
Defined in:
lib/sky_zabbix/client.rb

Overview

Examples:

z = SkyZabbix::Client.new('http://example.com/zabbix/api_jsonrpc.php')
z.('admin', 'zabbix')
z.host.get

Defined Under Namespace

Classes: TargetBase

Instance Method Summary collapse

Constructor Details

#initialize(uri, logger: nil) ⇒ Client

Returns a new instance of Client.

Parameters:

  • uri (String)

    is URI of Zabbix Server API endpoint.

  • logger (Logger) (defaults to: nil)

    is a Logger.


9
10
11
12
# File 'lib/sky_zabbix/client.rb', line 9

def initialize(uri, logger: nil)
  @uri = uri
  @client = SkyZabbix::Jsonrpc.new(@uri, logger: logger)
end

Instance Method Details

#batch(*requests) ⇒ Object

Send Batch Request.

Parameters:

  • requests (Array<Hash>)

    are Hash created by build_* method.


29
30
31
# File 'lib/sky_zabbix/client.rb', line 29

def batch(*requests)
  return @client.batch(requests)
end

#login(user, pass) ⇒ Object

Login to Zabbix Server.

Parameters:

  • user (String)

    is Zabbix user name.

  • pass (String)

    is Zabbix password.


17
18
19
# File 'lib/sky_zabbix/client.rb', line 17

def (user, pass)
  @client.token = self.user.(user: user, password: pass)
end

#logoutObject

Logout from Zabbix Server.


22
23
24
25
# File 'lib/sky_zabbix/client.rb', line 22

def logout
  self.user.logout()
  @client.token = nil
end