Class: ZabbixSender::Sender
- Inherits:
-
Object
- Object
- ZabbixSender::Sender
- Defined in:
- lib/zabbix_sender/sender.rb
Instance Attribute Summary collapse
-
#zabbix_host ⇒ Object
readonly
Returns the value of attribute zabbix_host.
-
#zabbix_port ⇒ Object
readonly
Returns the value of attribute zabbix_port.
Instance Method Summary collapse
-
#initialize(zabbix_host: "127.0.0.1", zabbix_port: 10051) ⇒ Sender
constructor
A new instance of Sender.
- #post(host, key, value) ⇒ Object
Constructor Details
#initialize(zabbix_host: "127.0.0.1", zabbix_port: 10051) ⇒ Sender
Returns a new instance of Sender.
9 10 11 12 |
# File 'lib/zabbix_sender/sender.rb', line 9 def initialize(zabbix_host: "127.0.0.1", zabbix_port: 10051) @zabbix_host = zabbix_host @zabbix_port = zabbix_port end |
Instance Attribute Details
#zabbix_host ⇒ Object (readonly)
Returns the value of attribute zabbix_host.
7 8 9 |
# File 'lib/zabbix_sender/sender.rb', line 7 def zabbix_host @zabbix_host end |
#zabbix_port ⇒ Object (readonly)
Returns the value of attribute zabbix_port.
7 8 9 |
# File 'lib/zabbix_sender/sender.rb', line 7 def zabbix_port @zabbix_port end |
Instance Method Details
#post(host, key, value) ⇒ Object
14 15 16 17 18 19 20 21 22 |
# File 'lib/zabbix_sender/sender.rb', line 14 def post(host, key, value) request = Request.new(host, key, value) begin socket = TCPSocket.new(zabbix_host, zabbix_port) request.send(socket) ensure socket.close if socket end end |