Class: Zabbix::Sender::Connection

Inherits:
Object
  • Object
show all
Defined in:
lib/zabbix_sender_api/api.rb

Overview

Connection is an abstract class that defines the basis of specific connection types (Pipe, Socket). It is not meant to be instantiated on its own.

Direct Known Subclasses

Pipe, Socket

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(proxy: Zabbix::AgentConfiguration.zabbixProxy) ⇒ Connection

Initialize a new Connector object. Proxy is optional.

An attempt is made to provide sane default values. If you have a zabbix_agentd.conf file in one of the usual places and zabbix_sender is on your path, it’ll probably just work



88
89
90
91
# File 'lib/zabbix_sender_api/api.rb', line 88

def initialize(proxy: Zabbix::AgentConfiguration.zabbixProxy)
  @targetHost = proxy
  @pipe = nil
end

Instance Attribute Details

#pipeObject (readonly)

Returns the value of attribute pipe.



79
80
81
# File 'lib/zabbix_sender_api/api.rb', line 79

def pipe
  @pipe
end

#targetHostObject (readonly)

target host (server or proxy) name or ip



78
79
80
# File 'lib/zabbix_sender_api/api.rb', line 78

def targetHost
  @targetHost
end

Instance Method Details

#flushObject

Closes the zabbix_sender pipe if it’s open



116
117
118
119
120
# File 'lib/zabbix_sender_api/api.rb', line 116

def flush
  if @pipe and not @pipe.closed?
    @pipe.close
  end
end

#openObject

Aborts execution if directly called. Subclasses must override.



95
96
97
# File 'lib/zabbix_sender_api/api.rb', line 95

def open
  abort("Call to abstract method Connection::open")
end

#sendBatch(aBatch) ⇒ Object

Aborts execution if directly called. Subclasses must override.



101
102
103
# File 'lib/zabbix_sender_api/api.rb', line 101

def sendBatch(aBatch)
  abort("Call to abstract method Connection::sendBatch(aBatch)")
end

#sendBatchAtomic(aBatch) ⇒ Object

Send a Batch instance to zabbix (via zabbix_sender). This opens the pipe, writes the data to the pipe, and closes the pipe all in one go.



108
109
110
111
112
# File 'lib/zabbix_sender_api/api.rb', line 108

def sendBatchAtomic(aBatch)
  self.open
  self.sendBatch(aBatch)
  return self.flush
end