Module: NagiosHerald::Util
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Logging
#configure_logger_for, #logger, #logger_for
Class Method Details
.get_script_path(script_name) ⇒ Object
13
14
15
16
17
|
# File 'lib/nagios-herald/util.rb', line 13
def self.get_script_path(script_name)
current_dir = File.dirname(__FILE__)
rel_path = File.join(current_dir, '..', '..', 'bin', script_name)
return File.expand_path(rel_path)
end
|
.load_helper(name) ⇒ Object
19
20
21
22
23
24
25
26
27
28
29
|
# File 'lib/nagios-herald/util.rb', line 19
def self.load_helper(name)
helper_path = File.expand_path(File.join(File.dirname(__FILE__), 'helpers', name))
logger.warn "Helper '#{name}' not found" unless File.exist?(helper_path + ".rb")
begin
require helper_path
return true
rescue LoadError
logger.fatal "Exception encountered loading '#{name}' helper library!"
return false
end
end
|
.underscore_to_camel_case(name) ⇒ Object
39
40
41
42
|
# File 'lib/nagios-herald/util.rb', line 39
def self.underscore_to_camel_case(name)
words = name.downcase.split('_')
return words.map! {|w| w.capitalize}.join('')
end
|
Instance Method Details
#get_nagios_var(name) ⇒ Object
31
32
33
34
35
36
37
|
# File 'lib/nagios-herald/util.rb', line 31
def get_nagios_var(name)
if Config.config['icinga']
name.gsub!(/^NAGIOS_/, 'ICINGA_')
end
value = ENV[name]
end
|
#unescape_text(text) ⇒ Object
TODO: add methods for handling HTTP(s) requests so we can control timeouts
9
10
11
|
# File 'lib/nagios-herald/util.rb', line 9
def unescape_text(text)
return text.gsub("\\n", "\n").gsub("\\t", "\t")
end
|