Class: Observium::Agent::Poller
- Inherits:
-
Object
- Object
- Observium::Agent::Poller
- Defined in:
- lib/observium/agent/poller.rb
Instance Method Summary collapse
-
#initialize(host, **args) ⇒ Poller
constructor
A new instance of Poller.
-
#poll ⇒ Object
Connects to the given host on the agent port to get the agent output.
Constructor Details
Instance Method Details
#poll ⇒ Object
Connects to the given host on the agent port to get the agent output. Connection times out after 5 seconds.
Raises a PollingFailed error if no data was output, or the command failed
Returns the raw output returned by the agent as a multiline string
16 17 18 19 20 21 22 23 |
# File 'lib/observium/agent/poller.rb', line 16 def poll @output = %x(nc -w #{@timeout} #{@host} #{@port} 2>&1) $?.success? or raise Errors::PollingFailed, "Agent check failed: #{error_msg}" has_data? or raise Errors::PollingFailed, "Agent didn't return any data" @output end |