<commit_before>#!/usr/bin/env ruby
#
# Check Cluster Status Plugin
# ===
#
# This plugin checks the wsrep_ready status of the cluster.
#
# Copyright 2016 <NAME> <EMAIL>

# Based on the Percona Cluster Size Plugin by <NAME> <<EMAIL>>, import.io; which is based on
# Based on the MySQL Health Plugin by <NAME>
#
# Depends on mysql:
# gem install mysql
#
# Released under the same terms as Sensu (the MIT license); see LICENSE
# for details.

require 'sensu-plugin/check/cli'
require 'mysql'

class CheckWsrepReady < Sensu::Plugin::Check::CLI
  option :user,
         description: 'MySQL User',
         short: '-u USER',
         long: '--user USER',
         default: 'root'

  option :password,
         description: 'MySQL Password',
         short: '-p PASS',
         long: '--password PASS'

  option :hostname,
         description: 'Hostname to login to',
         short: '-h HOST',
         long: '--hostname HOST',
         default: 'localhost'

  def run
    db = Mysql.real_connect(config[:hostname], config[:user], config[:password], config[:database])
    wsrep_ready = db.query("SHOW STATUS LIKE 'wsrep_ready';").fetch_hash.fetch('Value')
    critical "WSREP Ready is not ON. Is #{wsrep_ready}" if wsrep_ready != 'ON'
    ok 'Cluster is OK!' if wsrep_ready == 'ON'
  rescue Mysql::Error => e
    critical "Percona MySQL check failed: #{e.error}"
  ensure
    db.close if db
  end
end
<commit_msg>replace header with standard one<commit_after>#!/usr/bin/env ruby
#
#  check-wsrep-ready
#
# DESCRIPTION:
#   This plugin checks the wsrep_ready status of the cluster.
#
# OUTPUT:
#   plain text
#
# PLATFORMS:
#   Linux
#
# DEPENDENCIES:
#   gem: sensu-plugin
#   gem: mysql
#
# USAGE:
#
# NOTES:
#   Based on the Percona Cluster Size Plugin by <NAME> <<EMAIL>>, import.io; which is based on
#   Based on the MySQL Health Plugin by <NAME>
#
# LICENSE:
#   Copyright 2016 <NAME> <EMAIL>
#   Released under the same terms as Sensu (the MIT license); see LICENSE
#   for details.
#

require 'sensu-plugin/check/cli'
require 'mysql'

class CheckWsrepReady < Sensu::Plugin::Check::CLI
  option :user,
         description: 'MySQL User',
         short: '-u USER',
         long: '--user USER',
         default: 'root'

  option :password,
         description: 'MySQL Password',
         short: '-p PASS',
         long: '--password PASS'

  option :hostname,
         description: 'Hostname to login to',
         short: '-h HOST',
         long: '--hostname HOST',
         default: 'localhost'

  def run
    db = Mysql.real_connect(config[:hostname], config[:user], config[:password], config[:database])
    wsrep_ready = db.query("SHOW STATUS LIKE 'wsrep_ready';").fetch_hash.fetch('Value')
    critical "WSREP Ready is not ON. Is #{wsrep_ready}" if wsrep_ready != 'ON'
    ok 'Cluster is OK!' if wsrep_ready == 'ON'
  rescue Mysql::Error => e
    critical "Percona MySQL check failed: #{e.error}"
  ensure
    db.close if db
  end
end

{'fraction_non_alphanumeric': 0.12898845892735913, 'fraction_numerical': 0.0027155465037338763, 'mean_word_length': 3.036986301369863, 'pattern_counts': {'":': 0, '<': 17, '<?xml version=': 0, '>': 17, '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': '6505040', 'n_tokens_mistral': 1003, 'n_tokens_neox': 957, 'n_words': 315}