Sha256: bcc5f8dfd314294f43038115e657c708d4c40d71ed1ed656e2a1d3dba1b5f5df

Contents?: true

Size: 1.09 KB

Versions: 1

Compression:

Stored size: 1.09 KB

Contents

#! /usr/bin/env ruby
#
#   check-service-windows
#
# DESCRIPTION:
#   Check Named Windows Service Plugin
#   This plugin checks whether a User-inputted 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, metric data, etc
#
# 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'

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

  def run # rubocop:disable all
    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

1 entries across 1 versions & 1 rubygems

Version Path
sensu-plugins-windows-0.0.1.alpha.2 bin/check-windows-service.rb