Class: Zabbix::Sender::Buffer

Inherits:
Zabbix::Sender show all
Defined in:
lib/zabbix/sender/buffer.rb

Constant Summary

Constants inherited from Zabbix::Sender

DEFAULT_SERVER_PORT

Instance Attribute Summary

Attributes inherited from Zabbix::Sender

#configured

Instance Method Summary collapse

Methods inherited from Zabbix::Sender

#configured?, #connect, #disconnect, #send_break, #send_data, #send_heartbeat, #send_start, #send_stop

Constructor Details

#initialize(opts = {}) ⇒ Buffer

Returns a new instance of Buffer.



2
3
4
5
# File 'lib/zabbix/sender/buffer.rb', line 2

def initialize(opts={})
  @buffer = [] 
  super(opts)
end

Instance Method Details

#append(key, value, opts = {}) ⇒ Object



7
8
9
10
# File 'lib/zabbix/sender/buffer.rb', line 7

def append(key, value, opts={})
  return false unless configured?
  @buffer << cons_zabbix_data_element(key, value, opts)
end

#flushObject Also known as: send!



12
13
14
15
16
17
# File 'lib/zabbix/sender/buffer.rb', line 12

def flush 
  return false unless @buffer.size > 0
  ret = send_zabbix_request(@buffer)
  @buffer.clear
  return ret
end