11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
# File 'lib/nagios_resque/plugin.rb', line 11
def parse_options(*args)
@options = {}
OptionParser.new do |opts|
opts.on("-H", "--host hosname", String, "redis server") do |host|
@options[:host] = host
end
opts.on("-p", "--port number", Integer, "redis server port") do |port|
@options[:port] = port
end
opts.on("-n", "--namespace name", String, "redis namespace") do |namespace|
@options[:namespace] = namespace
end
opts.on("-j", "--job name", String, "resque job name") do |job|
@options[:job] = job
end
opts.on("-k", "--key name", String, "redis key for timestamp") do |key|
@options[:key] = key
end
yield(opts) if block_given?
begin
opts.parse!(args)
if @options[:warn].nil? && @options[:crit].nil?
@options[:crit] ||= (600..600)
end
if !@options[:warn].nil? && !@options[:crit].nil?
if @options[:warn].last > @options[:crit].first
unknown "Critical and Warning thresholds shouldn't overlap"
end
end
@options
rescue => e
unknown "#{e}\n\n#{opts}"
end
end
end
|