Sha256: 1b652f9de8188469f738e6e44d0ef8cd86925259f64293c2bb48adc9cd9928b4

Contents?: true

Size: 1.08 KB

Versions: 16

Compression:

Stored size: 1.08 KB

Contents

#! /usr/bin/env ruby
#
#   check-windows-cpu-load.rb
#
# DESCRIPTION:
#   This plugin collects and outputs the CPU load in a Graphite acceptable format.
#   It uses Typeperf to get the processor usage.
#
# OUTPUT:
#   plain text
#
# PLATFORMS:
#   Windows
#
# DEPENDENCIES:
#   gem: sensu-plugin
#
# USAGE:
#
# NOTES:
#  Tested on Windows 2008RC2.
#
# LICENSE:
#   Jean-Francois Theroux <me@failshell.io>
#   Released under the same terms as Sensu (the MIT license); see LICENSE for details.
#
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].delete('"').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

Version data entries

16 entries across 16 versions & 1 rubygems

Version Path
sensu-plugins-windows-2.9.1 bin/check-windows-cpu-load.rb
sensu-plugins-windows-2.9.0 bin/check-windows-cpu-load.rb
sensu-plugins-windows-2.8.1 bin/check-windows-cpu-load.rb
sensu-plugins-windows-2.8.0 bin/check-windows-cpu-load.rb
sensu-plugins-windows-2.7.0 bin/check-windows-cpu-load.rb
sensu-plugins-windows-2.6.0 bin/check-windows-cpu-load.rb
sensu-plugins-windows-2.5.0 bin/check-windows-cpu-load.rb
sensu-plugins-windows-2.4.1 bin/check-windows-cpu-load.rb
sensu-plugins-windows-2.4.0 bin/check-windows-cpu-load.rb
sensu-plugins-windows-2.3.0 bin/check-windows-cpu-load.rb
sensu-plugins-windows-2.2.1 bin/check-windows-cpu-load.rb
sensu-plugins-windows-2.2.0 bin/check-windows-cpu-load.rb
sensu-plugins-windows-2.1.0 bin/check-windows-cpu-load.rb
sensu-plugins-windows-2.0.0 bin/check-windows-cpu-load.rb
sensu-plugins-windows-1.0.0 bin/check-windows-cpu-load.rb
sensu-plugins-windows-0.1.0 bin/check-windows-cpu-load.rb