Sha256: 1739a790c94b1bc071aaa89958adde6fe9d52577a59c44f576e895b686d013c2

Contents?: true

Size: 1013 Bytes

Versions: 5

Compression:

Stored size: 1013 Bytes

Contents

#! /usr/bin/env ruby
#
#   check-windows-service.rb
#
# DESCRIPTION:
#   This plugin checks whether a User-supplied service on Windows is running or not
#   This checks users tasklist tool to find any service on Windows is running or not.
#
# OUTPUT:
#   plain text
#
# PLATFORMS:
#   Windows
#
# DEPENDENCIES:
#   gem: sensu-plugin
#
# USAGE:
#
# NOTES:
#
# LICENSE:
#   Edited from <jashishtech@gmail.com>
#   Copyright 2014 <jj.asghar@peopleadmin.com>
#   Released under the same terms as Sensu (the MIT license); see LICENSE for details.
#
require 'sensu-plugin/check/cli'

class CheckWinService < Sensu::Plugin::Check::CLI
  option :service,
         description: 'Check for a specific service',
         long: '--service SERVICE',
         short: '-s SERVICE'

  def run
    temp = system('tasklist /svc|findstr /i ' + config[:service])
    if temp == false
      message config[:service] + ' is not running'
      critical
    else
      message config[:service] + ' is running'
      ok
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
sensu-plugins-windows-2.2.0 bin/check-windows-service.rb
sensu-plugins-windows-2.1.0 bin/check-windows-service.rb
sensu-plugins-windows-2.0.0 bin/check-windows-service.rb
sensu-plugins-windows-1.0.0 bin/check-windows-service.rb
sensu-plugins-windows-0.1.0 bin/check-windows-service.rb