bin/check-bluepill-procs.rb in sensu-plugins-bluepill-0.0.3 vs bin/check-bluepill-procs.rb in sensu-plugins-bluepill-1.0.0
- old
+ new
@@ -61,19 +61,19 @@
def merge_output(orig, add)
orig.keys.each { |k| orig[k].push(*add[k]) }
orig
end
- def bluepill_application_status(name) # rubocop:disable all
+ def bluepill_application_status(name)
out = { name: [], ok: [], warn: [], crit: [], err: [] }
app_status = `#{config[:sudo] ? 'sudo ' : nil }bluepill #{name} status 2<&1`
name = 'Unknown' if name == ''
out[:name] << name
puts "***** DEBUG: bluepill #{name} status *****\n#{app_status}" if config[:debug]
processes_found = 0
# #YELLOW
- app_status.each_line do |line| # rubocop:disable Style/Next
+ app_status.each_line do |line|
if line =~ /(pid:)/
processes_found += 1
case line
when /unmonitored$/
out[:warn] << "#{name}::#{line}".strip
@@ -93,11 +93,11 @@
out[:err] << name if processes_found == 0
puts "***** DEBUG: bluepill #{name} status parsed ******\n#{out.inspect}" if config[:debug]
out
end
- def parse_output(out) # rubocop:disable all
+ def parse_output(out)
puts "***** DEBUG: Full output hash ******\n#{out.inspect}" if config[:debug]
if !out[:crit].empty?
critical "Bluepill process(es) critical:\n#{out[:crit].join("\n")}"
elsif !out[:err].empty?
critical "Bluepill process(es) not found for applications: #{out[:err].join(',')}"
@@ -106,23 +106,23 @@
else
ok "Bluepill normal, #{out[:name].count} application(s) with #{out[:ok].count} process(es) up."
end
end
- def run # rubocop:disable all
+ def run
# Check if Bluepill is installed
`which bluepill`
# #YELLOW
- unless $CHILD_STATUS.success? # rubocop:disable IfUnlessModifier
+ unless $CHILD_STATUS.success?
ok 'bluepill not installed'
end
out = { name: [], ok: [], warn: [], crit: [], err: [] }
if config[:apps]
requested_apps = config[:apps].split(',').map(&:strip) || []
- puts "***** DEBUG: requested applications: #{requested_apps }*****" if config[:debug]
+ puts "***** DEBUG: requested applications: #{requested_apps}*****" if config[:debug]
requested_apps.each do |a|
out = merge_output(out, bluepill_application_status(a))
end
else
puts '***** DEBUG: checking all applications *****' if config[:debug]
@@ -140,10 +140,10 @@
# (Returning non-zero when there are multiple applications
# loaded seems bizarre, but hey, that's just me.)
# We assume that no found applications is OK, since we only
# get here if -a option is unset.
# #YELLOW
- bluepill_status.each_line do |line| # rubocop:disable Style/Next
+ bluepill_status.each_line do |line|
if line =~ /^\s \d\.\s/
app_name = line.split(/^\s \d\.\s/)[1].strip
# #YELLOW
puts "***** DEBUG: found an application: #{app_name} *****" if config[:debug] # rubocop:disable BlockNesting
out = merge_output(out, bluepill_application_status(app_name))