Module: Zabbix

Extended by:
WrAPI::Configuration, WrAPI::RespondTo
Defined in:
lib/zabbix.rb,
lib/zabbix/api.rb,
lib/zabbix/error.rb,
lib/zabbix/client.rb,
lib/zabbix/request.rb,
lib/zabbix/version.rb,
lib/zabbix/authentication.rb

Overview

This module provides a Ruby API wrapper for Zabbix. It includes configuration options and creates client instances for interacting with the Zabbix API.

Examples:

Initialize a Zabbix client:

client = Zabbix.client(endpoint: 'https://your-zabbix-server/api_jsonrpc.php')

Defined Under Namespace

Modules: Authentication, Request Classes: API, AuthenticationError, Client, ConfigurationError, RPCError, ZabbixError

Constant Summary collapse

DEFAULT_UA =

Default User-Agent string for API requests.

"Ruby Zabbix API wrapper #{Zabbix::VERSION}"
VERSION =
'0.3.4'

Class Method Summary collapse

Class Method Details

.client(options = {}) ⇒ Zabbix::Client

Creates and returns a new Zabbix client instance. Merges default client settings with any user-provided options.

Examples:

Create a client with a custom User-Agent and endpoint:

client = Zabbix.client(user_agent: "MyApp Zabbix Client", endpoint: "https://zabbix.example.com/api_jsonrpc.php")

Parameters:

  • options (Hash) (defaults to: {})

    Optional settings to configure the client.

    • ‘:user_agent` (String) – Custom User-Agent string for API requests.

    • ‘:endpoint` (String) – The API endpoint URL (e.g., ’zabbix.example.com/api_jsonrpc.php’).

Returns:



33
34
35
36
37
38
39
# File 'lib/zabbix.rb', line 33

def self.client(options = {})
  # Ensure that the options argument is a Hash to prevent merge errors

  options = options.is_a?(Hash) ? options : {}
  Zabbix::Client.new({
    user_agent: DEFAULT_UA
  }.merge(options))
end

.resetvoid

This method returns an undefined value.

Resets the Zabbix module configuration to its default state.

This method sets the default endpoint and User-Agent string.



46
47
48
49
50
# File 'lib/zabbix.rb', line 46

def self.reset
  super
  self.endpoint   = nil
  self.user_agent = DEFAULT_UA
end