Class: Zabbix::Sender::Connection
- Inherits:
-
Object
- Object
- Zabbix::Sender::Connection
- 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.
Instance Attribute Summary collapse
-
#pipe ⇒ Object
readonly
Returns the value of attribute pipe.
-
#targetHost ⇒ Object
readonly
target host (server or proxy) name or ip.
Instance Method Summary collapse
-
#flush ⇒ Object
Closes the zabbix_sender pipe if it’s open.
-
#initialize(proxy: Zabbix::AgentConfiguration.zabbixProxy) ⇒ Connection
constructor
Initialize a new Connector object.
-
#open ⇒ Object
Aborts execution if directly called.
-
#sendBatch(aBatch) ⇒ Object
Aborts execution if directly called.
-
#sendBatchAtomic(aBatch) ⇒ Object
Send a Batch instance to zabbix (via zabbix_sender).
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
#pipe ⇒ Object (readonly)
Returns the value of attribute pipe.
79 80 81 |
# File 'lib/zabbix_sender_api/api.rb', line 79 def pipe @pipe end |
#targetHost ⇒ Object (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
#flush ⇒ Object
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 |
#open ⇒ Object
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 |