Module: Nagios

Defined in:
lib/nagios.rb,
lib/generators/nagios/check_generator.rb,
lib/generators/nagios/check_em_generator.rb

Defined Under Namespace

Classes: Check, CheckEM, CheckEmGenerator, CheckGenerator, Runner, RunnerAsync

Constant Summary collapse

OK =
0
WARN =
1
CRIT =
2
OTHER =
3
CONCURRENCY_LEVEL =

for server

25
STATUS_NAMES =
{
  OK => 'OK',
  WARN => 'WARN',
  CRIT => 'CRIT',
  OTHER => 'OTHER'
}

Class Attribute Summary collapse

Class Method Summary collapse

Class Attribute Details

.project_initializer_loadedObject

Returns the value of attribute project_initializer_loaded.



33
34
35
# File 'lib/nagios.rb', line 33

def project_initializer_loaded
  @project_initializer_loaded
end

Class Method Details

.concurrency_levelObject



35
36
37
# File 'lib/nagios.rb', line 35

def concurrency_level
  @concurrency_level
end

.concurrency_level=(cl) ⇒ Object



43
44
45
46
# File 'lib/nagios.rb', line 43

def concurrency_level=(cl)
  @concurrency_level = cl
  EM.threadpool_size = cl
end

.load_initializersObject



68
69
70
71
72
73
74
75
76
77
78
79
80
81
# File 'lib/nagios.rb', line 68

def load_initializers
  mutex.lock

  unless project_initializer_loaded
    Dir[root + "/initializers/*.rb"].each do |file|
      require File.expand_path(file)
    end

    project_initializer_loaded = true
  end

ensure
  mutex.unlock
end

.loggerObject



27
28
29
30
31
# File 'lib/nagios.rb', line 27

def logger
  @logger ||= Logger.new(File.join(rails_root, "/log/nagios.log")).tap do |logger|
    logger.formatter = lambda { |s, d, p, m| "#{d.strftime("%d.%m.%Y %H:%M:%S")} #{m}\n" }
  end
end

.mutexObject



39
40
41
# File 'lib/nagios.rb', line 39

def mutex
  @mutex ||= Mutex.new
end

.rails_rootObject



52
53
54
# File 'lib/nagios.rb', line 52

def rails_root
  @rails_root ||= defined?(RAILS_ROOT) ? RAILS_ROOT : (defined?(Rails) ? Rails.root : nil)
end

.rails_root=(rails_root) ⇒ Object



56
57
58
# File 'lib/nagios.rb', line 56

def rails_root=(rails_root)
  @rails_root = rails_root
end

.rootObject



60
61
62
# File 'lib/nagios.rb', line 60

def root
  @root ||= File.join(rails_root, %w{ app nagios })
end

.root=(root) ⇒ Object



64
65
66
# File 'lib/nagios.rb', line 64

def root=(root)
  @root = root
end

.status_name(status) ⇒ Object



48
49
50
# File 'lib/nagios.rb', line 48

def status_name(status)
  ":#{ STATUS_NAMES[status] || 'unknown' }"
end

.url(method) ⇒ Object



83
84
85
# File 'lib/nagios.rb', line 83

def url(method)
  "http://localhost:3000/nagios/check?method=#{method}"
end