Class: BigBrother::Nagios

Inherits:
Object
  • Object
show all
Defined in:
lib/big_brother/nagios.rb

Defined Under Namespace

Modules: Code

Instance Method Summary collapse

Constructor Details

#initialize(executor = ShellExecutor.new) ⇒ Nagios

Returns a new instance of Nagios.



10
11
12
# File 'lib/big_brother/nagios.rb', line 10

def initialize(executor = ShellExecutor.new)
  @executor = executor
end

Instance Method Details

#_send_passive(host, check, code, message, server) ⇒ Object



26
27
28
# File 'lib/big_brother/nagios.rb', line 26

def _send_passive(host, check, code, message, server)
  @executor.invoke("echo '#{host},#{check},#{code},#{message}' | send_nsca -H #{server} -d ,")
end

#send_critical(host, check, message, server) ⇒ Object



14
15
16
# File 'lib/big_brother/nagios.rb', line 14

def send_critical(host, check, message, server)
  _send_passive(host, check, Code::Critical, "CRITICAL #{message}", server)
end

#send_ok(host, check, message, server) ⇒ Object



18
19
20
# File 'lib/big_brother/nagios.rb', line 18

def send_ok(host, check, message, server)
  _send_passive(host, check, Code::Ok, "OK #{message}", server)
end

#send_warning(host, check, message, server) ⇒ Object



22
23
24
# File 'lib/big_brother/nagios.rb', line 22

def send_warning(host, check, message, server)
  _send_passive(host, check, Code::Warning, "WARNING #{message}", server)
end