<commit_before>#!/usr/bin/env ruby
#
# Check Windows's CPU usage
# ===
#
# Tested on Windows 2008RC2.
#
# <NAME> <<EMAIL>>
#
# 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 CheckWindowsCpuLoad < Sensu::Plugin::Check::CLI
  option :warning,
         short: '-w WARNING',
         default: 85

  option :critical,
         short: '-c CRITICAL',
         default: 95

  def run
    io = IO.popen("typeperf -sc 1 \"processor(_total)\\% processor time\"")
    cpu_load = io.readlines[2].split(',')[1].gsub(/"/, '').to_i
    critical "CPU at #{cpu_load}%" if cpu_load > config[:critical]
    warning "CPU at #{cpu_load}%" if cpu_load > config[:warning]
    ok "CPU at #{cpu_load}%"
  end
end<commit_msg>Fixed argument passing coming in as string vs int<commit_after>#!/usr/bin/env ruby
#
# Check Windows's CPU usage
# ===
#
# Tested on Windows 2008RC2.
#
# <NAME> <<EMAIL>>
#
# 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 CheckWindowsCpuLoad < Sensu::Plugin::Check::CLI
  option :warning,
         short: '-w WARNING',
         default: 85,
         proc: proc(&:to_i)

  option :critical,
         short: '-c CRITICAL',
         default: 95,
         proc: proc(&:to_i)

  def run
    io = IO.popen("typeperf -sc 1 \"processor(_total)\\% processor time\"")
    cpu_load = io.readlines[2].split(',')[1].gsub(/"/, '').to_i
    critical "CPU at #{cpu_load}%" if cpu_load > config[:critical]
    warning "CPU at #{cpu_load}%" if cpu_load > config[:warning]
    ok "CPU at #{cpu_load}%"
  end
end
{'fraction_non_alphanumeric': 0.15880322209436135, 'fraction_numerical': 0.01726121979286536, 'mean_word_length': 3.2311435523114356, 'pattern_counts': {'":': 0, '<': 13, '<?xml version=': 0, '>': 13, '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': '1776190', 'n_tokens_mistral': 649, 'n_tokens_neox': 606, 'n_words': 175}