Class: NagiosResque::Plugin
- Inherits:
-
NagiosPlugin::Plugin
- Object
- NagiosPlugin::Plugin
- NagiosResque::Plugin
- Includes:
- NagiosPlugin::DefaultOptions
- Defined in:
- lib/nagios_resque/plugin.rb
Class Method Summary collapse
Instance Method Summary collapse
- #check ⇒ Object
-
#initialize(*args) ⇒ Plugin
constructor
A new instance of Plugin.
- #parse_options(*args) ⇒ Object
- #service ⇒ Object
Constructor Details
#initialize(*args) ⇒ Plugin
Returns a new instance of Plugin.
55 56 57 58 59 60 61 |
# File 'lib/nagios_resque/plugin.rb', line 55 def initialize(*args) (*args, &) @service = Check.new() ENV['PATH'] = "/sbin:/bin:/usr/sbin:/usr/bin:/usr/local/sbin:/usr/local/bin" end |
Class Method Details
.run(*args) ⇒ Object
6 7 8 |
# File 'lib/nagios_resque/plugin.rb', line 6 def run(*args) self.new(*args).run end |
Instance Method Details
#check ⇒ Object
63 64 65 66 67 68 69 70 71 72 73 |
# File 'lib/nagios_resque/plugin.rb', line 63 def check if @service.critical? critical @service. elsif @service.warning? warning @service. else ok @service. end ensure @service.requeue end |
#parse_options(*args) ⇒ Object
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 (*args) = {} OptionParser.new do |opts| opts.on("-H", "--host hosname", String, "redis server") do |host| [:host] = host end opts.on("-p", "--port number", Integer, "redis server port") do |port| [:port] = port end opts.on("-n", "--namespace name", String, "redis namespace") do |namespace| [:namespace] = namespace end opts.on("-j", "--job name", String, "resque job name") do |job| [:job] = job end opts.on("-k", "--key name", String, "redis key for timestamp") do |key| [:key] = key end yield(opts) if block_given? begin opts.parse!(args) if [:warn].nil? && [:crit].nil? [:crit] ||= (600..600) end if ![:warn].nil? && ![:crit].nil? if [:warn].last > [:crit].first unknown "Critical and Warning thresholds shouldn't overlap" end end rescue => e unknown "#{e}\n\n#{opts}" end end end |
#service ⇒ Object
51 52 53 |
# File 'lib/nagios_resque/plugin.rb', line 51 def service 'Resque' end |