Sha256: d415996c96f634240c1ced7c09a6208c5256d2f850e3db08667875a352e34ca7

Contents?: true

Size: 1023 Bytes

Versions: 11

Compression:

Stored size: 1023 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 /c:"' + 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

11 entries across 11 versions & 1 rubygems

Version Path
sensu-plugins-windows-2.9.1 bin/check-windows-service.rb
sensu-plugins-windows-2.9.0 bin/check-windows-service.rb
sensu-plugins-windows-2.8.1 bin/check-windows-service.rb
sensu-plugins-windows-2.8.0 bin/check-windows-service.rb
sensu-plugins-windows-2.7.0 bin/check-windows-service.rb
sensu-plugins-windows-2.6.0 bin/check-windows-service.rb
sensu-plugins-windows-2.5.0 bin/check-windows-service.rb
sensu-plugins-windows-2.4.1 bin/check-windows-service.rb
sensu-plugins-windows-2.4.0 bin/check-windows-service.rb
sensu-plugins-windows-2.3.0 bin/check-windows-service.rb
sensu-plugins-windows-2.2.1 bin/check-windows-service.rb