<commit_before>#!/usr/bin/env ruby
#
# RabbitMQ Queue Drain Time
# ===
# This plugin checks the time it will take for each queue on the RabbitMQ
# server to drain based on the current message egress rate.  For example
# if a queue has 1,000 messages in it, but egresses only 1 message a sec
# the alert would fire as this is greater than the default critical level of 360s
#
# The plugin is based on the RabbitMQ Queue Metrics plugin
#
# Copyright 2015 <NAME> <<EMAIL>> and Cozy Services Ltd.
#
# Released under the same terms as Sensu (the MIT license); see LICENSE
# for details.

require 'sensu-plugin/check/cli'
require 'socket'
require 'carrot-top'

class CheckRabbitMQQueueDrainTime < Sensu::Plugin::Check::CLI
  option :host,
         description: 'RabbitMQ management API host',
         long: '--host HOST',
         default: 'localhost'

  option :port,
         description: 'RabbitMQ management API port',
         long: '--port PORT',
         proc: proc(&:to_i),
         default: 15_672

  option :user,
         description: 'RabbitMQ management API user',
         long: '--user USER',
         default: 'guest'

  option :password,
         description: 'RabbitMQ management API password',
         long: '--password PASSWORD',
         default: 'guest'

  option :scheme,
         description: 'Metric naming scheme, text to prepend to $queue_name.$metric',
         long: '--scheme SCHEME',
         default: "#{Socket.gethostname}.rabbitmq"

  option :filter,
         description: 'Regular expression for filtering queues',
         long: '--filter REGEX'<commit_msg>Remove copy paste fail from check-rabbitmq-queue-drain-time<commit_after>#!/usr/bin/env ruby
#
# RabbitMQ Queue Drain Time
# ===
# This plugin checks the time it will take for each queue on the RabbitMQ
# server to drain based on the current message egress rate.  For example
# if a queue has 1,000 messages in it, but egresses only 1 message a sec
# the alert would fire as this is greater than the default critical level of 360s
#
# The plugin is based on the RabbitMQ Queue Metrics plugin
#
# Copyright 2015 <NAME> <<EMAIL>> and Cozy Services Ltd.
#
# Released under the same terms as Sensu (the MIT license); see LICENSE
# for details.

require 'sensu-plugin/check/cli'
require 'socket'
require 'carrot-top'

class CheckRabbitMQQueueDrainTime < Sensu::Plugin::Check::CLI
  option :host,
         description: 'RabbitMQ management API host',
         long: '--host HOST',
         default: 'localhost'

  option :port,
         description: 'RabbitMQ management API port',
         long: '--port PORT',
         proc: proc(&:to_i),
         default: 15_672

  option :user,
         description: 'RabbitMQ management API user',
         long: '--user USER',
         default: 'guest'

  option :password,
         description: 'RabbitMQ management API password',
         long: '--password PASSWORD',
         default: 'guest'

  option :filter,
         description: 'Regular expression for filtering queues',
         long: '--filter REGEX'
{'fraction_non_alphanumeric': 0.0955833882663151, 'fraction_numerical': 0.01120632827949901, 'mean_word_length': 2.977719528178244, 'pattern_counts': {'":': 0, '<': 11, '<?xml version=': 0, '>': 9, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '4818115', 'n_tokens_mistral': 942, 'n_tokens_neox': 857, 'n_words': 348}