bin/check-beanstalk-watchers.rb in sensu-plugins-beanstalk-1.2.0 vs bin/check-beanstalk-watchers.rb in sensu-plugins-beanstalk-2.0.0
- old
+ new
@@ -54,22 +54,20 @@
unknown 'Tube was not set' unless config[:tube]
begin
beanstalk = Beanstalk::Connection.new(
"#{config[:host]}:#{config[:port]}"
)
- rescue => e
+ rescue StandardError => e
critical "Failed to connect: (#{e})"
end
begin
stats = beanstalk.stats_tube(config[:tube])
watchers = stats['current-watching'].to_i
rescue Beanstalk::NotFoundError
warning "Tube #{config[:tube]} not found"
end
- unless watchers
- watchers = 0
- end
+ watchers ||= 0
if config[:crit] && watchers < config[:crit]
critical "Required at least #{config[:crit]} watchers but have #{watchers}"
elsif config[:warn] && watchers < config[:warn]
warning "Required at least #{config[:warn]} watchers but have #{watchers}"
else