<commit_before>#!/usr/bin/env /opt/sensu/embedded/bin/ruby
#
# Check OS API
# ===
#
# Purpose: to check openstack service api endpoint.
#
# Released under the same terms as Sensu (the MIT license); see LICENSE
# for details.

require 'rubygems' if RUBY_VERSION < '1.9.0'
require 'sensu-plugin/check/cli'

class CheckOSApi < Sensu::Plugin::Check::CLI
  option :service, :long  => '--service SERVICE_TYPE'

  option :criticality,
         :short => '-z CRITICALITY',
         :long => '--criticality CRITICALITY',
         :default => 'critical'
  ##
  # Build a command to execute, since this is passed directly
  # to Kernel#system.

  def safe_command
    cmd = case config[:service]
    when "nova"
      "nova list"
    when "glance"
      "glance image-list"
    when "keystone"
      "keystone endpoint-list"
    when "heat"
      "heat stack-list"
    when "ceilometer"
      "ceilometer meter-list"
    end
  end

  def run
    system("#{safe_command}")

    if $?.exitstatus == 0
      exit
    elsif config[:criticality] == 'warning'
      warning
    else
      critical
    end
  end
end
<commit_msg>Replace keystone client usage w/ openstack client<commit_after>#!/usr/bin/env /opt/sensu/embedded/bin/ruby
#
# Check OS API
# ===
#
# Purpose: to check openstack service api endpoint.
#
# Released under the same terms as Sensu (the MIT license); see LICENSE
# for details.

require 'rubygems' if RUBY_VERSION < '1.9.0'
require 'sensu-plugin/check/cli'

class CheckOSApi < Sensu::Plugin::Check::CLI
  option :service, :long  => '--service SERVICE_TYPE'

  option :criticality,
         :short => '-z CRITICALITY',
         :long => '--criticality CRITICALITY',
         :default => 'critical'
  ##
  # Build a command to execute, since this is passed directly
  # to Kernel#system.

  def safe_command
    cmd = case config[:service]
    when "nova"
      "nova list"
    when "glance"
      "glance image-list"
    when "keystone"
      "openstack endpoint list"
    when "heat"
      "heat stack-list"
    when "ceilometer"
      "ceilometer meter-list"
    end
  end

  def run
    system("#{safe_command}")

    if $?.exitstatus == 0
      exit
    elsif config[:criticality] == 'warning'
      warning
    else
      critical
    end
  end
end

{'fraction_non_alphanumeric': 0.11863656485170429, 'fraction_numerical': 0.0035413899955732625, 'mean_word_length': 2.7049180327868854, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 11, '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': '4985574', 'n_tokens_mistral': 777, 'n_tokens_neox': 738, 'n_words': 219}