Sha256: 1399e5905a09cbcb4d158490fc7e6736f37bafdef822dc7be16a8dbac2a00dc4
Contents?: true
Size: 1.51 KB
Versions: 2
Compression:
Stored size: 1.51 KB
Contents
#! /usr/bin/env ruby # # check-windows-ram.rb # # DESCRIPTION: # # 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' # # Check Windows RAM Load # class CheckWindowsRAMLoad < 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 acquire_ram_usage # rubocop:disable all temp_arr_1 = [] temp_arr_2 = [] IO.popen("typeperf -sc 1 \"Memory\\Available bytes\" ") { |io| io.each { |line| temp_arr_1.push(line) } } temp = temp_arr_1[2].split(',')[1] ram_available_in_bytes = temp[1, temp.length - 3].to_f IO.popen('wmic OS get TotalVisibleMemorySize /Value') { |io| io.each { |line| temp_arr_2.push(line) } } total_ram = temp_arr_2[4].split('=')[1].to_f total_ram_in_bytes = total_ram * 1000.0 ram_use_percent = (total_ram_in_bytes - ram_available_in_bytes) * 100.0 / (total_ram_in_bytes) ram_use_percent.round(2) end def run # rubocop:disable all ram_load = acquire_ram_usage critical "RAM at #{ram_load}%" if ram_load > config[:critical] warning "RAM at #{ram_load}%" if ram_load > config[:warning] ok "RAM at #{ram_load}%" end end
Version data entries
2 entries across 2 versions & 1 rubygems
Version | Path |
---|---|
sensu-plugins-windows-0.0.5 | bin/check-windows-ram.rb |
sensu-plugins-windows-0.0.3 | bin/check-windows-ram.rb |