Sha256: 26da12ec782d4496b51a178b4d43a81dfdd79235c0807548dfd7bde066186d95
Contents?: true
Size: 1.78 KB
Versions: 3
Compression:
Stored size: 1.78 KB
Contents
#! /usr/bin/env ruby # # check-beanstalk-watchers # # DESCRIPTION: # #YELLOW # # OUTPUT: # plain-text # # PLATFORMS: # Linux # # DEPENDENCIES: # gem: beanstalk # gem: sensu-plugin # # USAGE: # #YELLOW # # NOTES: # # LICENSE: # Copyright S. Zachariah Sprackett <zac@sprackett.com> # Released under the same terms as Sensu (the MIT license); see LICENSE # for details. # require 'sensu-plugin/check/cli' require 'beanstalk-client' # # Check Beanstalk Watchers # class CheckBeanstalkWatchers < Sensu::Plugin::Check::CLI option :host, short: '-H HOST', default: 'localhost' option :port, short: '-p PORT', default: '11300' option :tube, short: '-t TUBE' option :crit, short: '-c CRIT_THRESHOLD', proc: proc(&:to_i), default: false option :warn, short: '-w WARN_THRESHOLD', proc: proc(&:to_i), default: false def run # rubocop:disable all unknown 'Tube was not set' unless config[:tube] begin beanstalk = Beanstalk::Connection.new( "#{config[:host]}:#{config[:port]}" ) rescue => 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 # #YELLOW unless watchers # rubocop:disable IfUnlessModifier watchers = 0 end 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 ok "#{watchers} watchers found." end end end
Version data entries
3 entries across 3 versions & 1 rubygems