sensu-plugins-windows 0.0.1.alpha.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: e8a70a84851e393ab3f7087da904c2172d49fc0a
4
+ data.tar.gz: f5d147853e7e3f1161bc39f2c8731c0548016630
5
+ SHA512:
6
+ metadata.gz: 1b3a2dbb2096dc9b72e1844a950ef103fbb1d5f67e4f79392edc9838d3b3b3f393ff3480c5d74cc38317eac653a475865e8b3c20bc15fc503b00e4439d2b852a
7
+ data.tar.gz: 9fc5782e35b2a2683077321739f27937b3971e0adbf51543d525f6f9f4bb3277734be469e506a84b863a08502507de6fdd85ba080b3e0c164c427455fdbfab65
checksums.yaml.gz.sig ADDED
Binary file
data.tar.gz.sig ADDED
Binary file
data/CHANGELOG.md ADDED
@@ -0,0 +1,7 @@
1
+ #### 0.0.1.alpha.1
2
+
3
+ * initial release, same as community plugins repo
4
+
5
+ #### 0.0.1.alpha.2
6
+
7
+ * build passes
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 devops@yieldbot.com
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,63 @@
1
+ ## Sensu-Plugins-windows
2
+
3
+ [![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-windows.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-windows)
4
+ [![Gem Version](https://badge.fury.io/rb/sensu-plugins-windows.svg)](http://badge.fury.io/rb/sensu-plugins-windows)
5
+ [![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-windows/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-windows)
6
+ [![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-windows/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-windows)
7
+ [![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-windows.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-windows)
8
+
9
+ ## Functionality
10
+
11
+ ## Files
12
+ * bin/metrics-windows-ram-usage
13
+ * bin/metrics-windows-cpu-load
14
+ * bin/metrics-windows-disk-usage
15
+ * bin/metrics-iis-get-requests
16
+ * bin/metrics-iis-current-connections
17
+ * bin/check-windows-service
18
+ * bin/check-windows-process
19
+ * bin/extension-wmi-metrics
20
+ * bin/check-windows-disk
21
+ * bin/check-windows-cpu-load
22
+ * bin/check-iis-current-connections
23
+
24
+ ## Usage
25
+
26
+ ## Installation
27
+
28
+ Add the public key (if you haven’t already) as a trusted certificate
29
+
30
+ ```
31
+ gem cert --add <(curl -Ls https://raw.githubusercontent.com/sensu-plugins/sensu-plugins.github.io/master/certs/sensu-plugins.pem)
32
+ gem install sensu-plugins-windows -P MediumSecurity
33
+ ```
34
+
35
+ You can also download the key from /certs/ within each repository.
36
+
37
+ #### Rubygems
38
+
39
+ `gem install sensu-plugins-windows`
40
+
41
+ #### Bundler
42
+
43
+ Add *sensu-plugins-windows* to your Gemfile and run `bundle install` or `bundle update`
44
+
45
+ #### Chef
46
+
47
+ Using the Sensu **sensu_gem** LWRP
48
+ ```
49
+ sensu_gem 'sensu-plugins-windows' do
50
+ options('--prerelease')
51
+ version '0.0.1.alpha.4'
52
+ end
53
+ ```
54
+
55
+ Using the Chef **gem_package** resource
56
+ ```
57
+ gem_package 'sensu-plugins-windows' do
58
+ options('--prerelease')
59
+ version '0.0.1.alpha.4'
60
+ end
61
+ ```
62
+
63
+ ## Notes
@@ -0,0 +1,54 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-iis-current-connections
4
+ #
5
+ # DESCRIPTION:
6
+ #
7
+ # OUTPUT:
8
+ # plain text
9
+ #
10
+ # PLATFORMS:
11
+ # Windows
12
+ #
13
+ # DEPENDENCIES:
14
+ # gem: sensu-plugin
15
+ #
16
+ # USAGE:
17
+ #
18
+ # NOTES:
19
+ # Tested on Windows 2012RC2.
20
+ #
21
+ # LICENSE:
22
+ # Yohei Kawahara <inokara@gmail.com>
23
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
24
+ # for details.
25
+ #
26
+
27
+ require 'sensu-plugin/check/cli'
28
+
29
+ #
30
+ # Check IIS Current Connections
31
+ #
32
+ class CheckIisCurrentConnections < Sensu::Plugin::Check::CLI
33
+ option :warning,
34
+ short: '-w WARNING',
35
+ proc: proc(&:to_f),
36
+ default: 50
37
+
38
+ option :critical,
39
+ short: '-c CRITICAL',
40
+ proc: proc(&:to_f),
41
+ default: 150
42
+
43
+ option :site,
44
+ short: '-s sitename',
45
+ default: '_Total'
46
+
47
+ def run # rubocop:disable all
48
+ io = IO.popen("typeperf -sc 1 \"Web Service(#{config[:site]})\\Current\ Connections\"")
49
+ current_connection = io.readlines[2].split(',')[1].gsub(/"/, '').to_f
50
+ critical "Current Connectio at #{current_connection}" if current_connection > config[:critical]
51
+ warning "Current Connectio at #{current_connection}" if current_connection > config[:warning]
52
+ ok "Current Connection at #{current_connection}"
53
+ end
54
+ end
@@ -0,0 +1,50 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-windows-cpu-load
4
+ #
5
+ # DESCRIPTION:
6
+ #
7
+ # OUTPUT:
8
+ # plain text
9
+ #
10
+ # PLATFORMS:
11
+ # Windows
12
+ #
13
+ # DEPENDENCIES:
14
+ # gem: sensu-plugin
15
+ #
16
+ # USAGE:
17
+ #
18
+ # NOTES:
19
+ # Tested on Windows 2008RC2.
20
+ #
21
+ # LICENSE:
22
+ # Jean-Francois Theroux <me@failshell.io>
23
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
24
+ # for details.
25
+ #
26
+
27
+ require 'sensu-plugin/check/cli'
28
+
29
+ #
30
+ # Check Windows CPU Load
31
+ #
32
+ class CheckWindowsCpuLoad < Sensu::Plugin::Check::CLI
33
+ option :warning,
34
+ short: '-w WARNING',
35
+ default: 85,
36
+ proc: proc(&:to_i)
37
+
38
+ option :critical,
39
+ short: '-c CRITICAL',
40
+ default: 95,
41
+ proc: proc(&:to_i)
42
+
43
+ def run # rubocop:disable all
44
+ io = IO.popen("typeperf -sc 1 \"processor(_total)\\% processor time\"")
45
+ cpu_load = io.readlines[2].split(',')[1].gsub(/"/, '').to_i
46
+ critical "CPU at #{cpu_load}%" if cpu_load > config[:critical]
47
+ warning "CPU at #{cpu_load}%" if cpu_load > config[:warning]
48
+ ok "CPU at #{cpu_load}%"
49
+ end
50
+ end
@@ -0,0 +1,101 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-disk-windows
4
+ #
5
+ # DESCRIPTION:
6
+ # This is mostly copied from the original check-disk.rb plugin and modified
7
+ # to use WMIC. This is our first attempt at writing a plugin for Windows.
8
+ #
9
+ # Uses Windows WMIC facility. Warning/critical levels are percentages only.
10
+
11
+ #
12
+ # OUTPUT:
13
+ # plain text
14
+ #
15
+ # PLATFORMS:
16
+ # Windows
17
+ #
18
+ # DEPENDENCIES:
19
+ # gem: sensu-plugin
20
+ # REQUIRES: ActiveSupport version 4.0 or above.
21
+ #
22
+ # USAGE:
23
+ #
24
+ # NOTES:
25
+ #
26
+ # LICENSE:
27
+ # Copyright 2013 <bp-parks@wiu.edu> <mr-mencel@wiu.edu>
28
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
29
+ # for details.
30
+ #
31
+
32
+ require 'sensu-plugin/check/cli'
33
+
34
+ #
35
+ # Check Disk
36
+ #
37
+ class CheckDisk < Sensu::Plugin::Check::CLI
38
+ option :fstype,
39
+ short: '-t TYPE',
40
+ proc: proc { |a| a.split(',') }
41
+
42
+ option :ignoretype,
43
+ short: '-x TYPE',
44
+ proc: proc { |a| a.split(',') }
45
+
46
+ option :ignoremnt,
47
+ short: '-i MNT',
48
+ proc: proc { |a| a.split(',') }
49
+
50
+ option :warn,
51
+ short: '-w PERCENT',
52
+ proc: proc(&:to_i),
53
+ default: 85
54
+
55
+ option :crit,
56
+ short: '-c PERCENT',
57
+ proc: proc(&:to_i),
58
+ default: 95
59
+
60
+ def initialize
61
+ super
62
+ @crit_fs = []
63
+ @warn_fs = []
64
+ end
65
+
66
+ def read_wmic # rubocop:disable all
67
+ `wmic volume where DriveType=3 list brief`.split("\n").drop(1).each do |line|
68
+ begin
69
+ # #YELLOW
70
+ capacity, type, _fs, _avail, label, mnt = line.split # rubocop:disable Lint/UnderscorePrefixedVariableName
71
+ next if /\S/ !~ line
72
+ next if _avail.nil?
73
+ next if line.include?('System Reserved')
74
+ next if config[:fstype] && !config[:fstype].include?(type)
75
+ next if config[:ignoretype] && config[:ignoretype].include?(type)
76
+ next if config[:ignoremnt] && config[:ignoremnt].include?(mnt)
77
+ rescue
78
+ unknown "malformed line from df: #{line}"
79
+ end
80
+ # If label value is not set, the drive letter will end up in that column. Set mnt to label in that case.
81
+ mnt = label if mnt.nil?
82
+ prct_used = (100 * (1 - (_avail.to_f / capacity.to_f)))
83
+ if prct_used >= config[:crit]
84
+ @crit_fs << "#{mnt} #{prct_used.round(2)}"
85
+ elsif prct_used >= config[:warn]
86
+ @warn_fs << "#{mnt} #{prct_used.round(2)}"
87
+ end
88
+ end
89
+ end
90
+
91
+ def usage_summary
92
+ (@crit_fs + @warn_fs).join(', ')
93
+ end
94
+
95
+ def run
96
+ read_wmic
97
+ critical usage_summary unless @crit_fs.empty?
98
+ warning usage_summary unless @warn_fs.empty?
99
+ ok "All disk usage under #{config[:warn]}%"
100
+ end
101
+ end
@@ -0,0 +1,47 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-process
4
+ #
5
+ # DESCRIPTION:
6
+ # This plugin checks whether a User-inputted process is running or not
7
+ # This checks users tasklist tool to find any process is running or not.
8
+ #
9
+ # OUTPUT:
10
+ # plain text
11
+ #
12
+ # PLATFORMS:
13
+ # Windows
14
+ #
15
+ # DEPENDENCIES:
16
+ # gem: sensu-plugin
17
+ #
18
+ # USAGE:
19
+ #
20
+ # NOTES:
21
+ #
22
+ # LICENSE:
23
+ # Copyright 2013 <jashishtech@gmail.com>
24
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
25
+ # for details.
26
+ #
27
+
28
+ require 'sensu-plugin/check/cli'
29
+
30
+ #
31
+ # Check Database
32
+ #
33
+ class CheckDatabase < Sensu::Plugin::Check::CLI
34
+ option :process, short: '-p process'
35
+
36
+ def run # rubocop:disable all
37
+ temp = system('tasklist|findstr /i ' + config[:process])
38
+ puts temp
39
+ if temp == false
40
+ message config[:process] + ' is not running'
41
+ critical
42
+ else
43
+ message config[:process] + ' is running'
44
+ ok
45
+ end
46
+ end
47
+ end
@@ -0,0 +1,52 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-service-windows
4
+ #
5
+ # DESCRIPTION:
6
+ # Check Named Windows Service Plugin
7
+ # This plugin checks whether a User-inputted service on Windows is running or not
8
+ # This checks users tasklist tool to find any service on Windows is running or not.
9
+
10
+ #
11
+ # OUTPUT:
12
+ # plain text, metric data, etc
13
+ #
14
+ # PLATFORMS:
15
+ # Windows
16
+ #
17
+ # DEPENDENCIES:
18
+ # gem: sensu-plugin
19
+ #
20
+ # USAGE:
21
+ #
22
+ # NOTES:
23
+ #
24
+ # LICENSE:
25
+ # Edited from <jashishtech@gmail.com>
26
+ # Copyright 2014 <jj.asghar@peopleadmin.com>
27
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
28
+ # for details.
29
+ #
30
+
31
+ require 'sensu-plugin/check/cli'
32
+
33
+ #
34
+ # Check Win Services
35
+ #
36
+ class CheckWinService < Sensu::Plugin::Check::CLI
37
+ option :service,
38
+ description: 'Check for a specific service',
39
+ long: '--service SERVICE',
40
+ short: '-s SERVICE'
41
+
42
+ def run # rubocop:disable all
43
+ temp = system('tasklist /svc|findstr /i ' + config[:service])
44
+ if temp == false
45
+ message config[:service] + ' is not running'
46
+ critical
47
+ else
48
+ message config[:service] + ' is running'
49
+ ok
50
+ end
51
+ end
52
+ end
@@ -0,0 +1,204 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # WMI Metrics
4
+ #
5
+ # DESCRIPTION:
6
+ # Collects a variety of system metrics every 10 seconds (by default).
7
+ # Expects a "graphite" handler on the Sensu server, eg:
8
+ #
9
+ # OUTPUT:
10
+ # metric data
11
+ #
12
+ # PLATFORMS:
13
+ # Windows
14
+ #
15
+ # DEPENDENCIES:
16
+ # gem: sensu-plugin
17
+ # gem: socket
18
+ #
19
+ # USAGE:
20
+ #
21
+ # "graphite": {
22
+ # "type": "tcp",
23
+ # "socket": {
24
+ # "host": "graphite.hw-ops.com",
25
+ # "port": 2003
26
+ # },
27
+ # "mutator": "only_check_output"
28
+ # }
29
+ #
30
+ # NOTES:
31
+ # Tested on Windows 2012RC2.
32
+ #
33
+ # LICENSE:
34
+ # Copyright 2014 Heavy Water Operations, LLC.
35
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
36
+ # for details.
37
+ #
38
+
39
+ require 'win32ole'
40
+
41
+ module Sensu
42
+ module Extension
43
+ #
44
+ #
45
+ #
46
+ class WMIMetrics < Check
47
+ def name
48
+ 'wmi_metrics'
49
+ end
50
+
51
+ def description
52
+ 'collects system metrics, using wmi and the graphite plain-text format'
53
+ end
54
+
55
+ def definition
56
+ {
57
+ type: 'metric',
58
+ name: name,
59
+ interval: options[:interval],
60
+ standalone: true,
61
+ handler: options[:handler]
62
+ }
63
+ end
64
+
65
+ def post_init
66
+ @metrics = []
67
+ @wmi = WIN32OLE.connect('winmgmts://')
68
+ end
69
+
70
+ def run
71
+ memory_metrics do
72
+ disk_metrics do
73
+ cpu_metrics do
74
+ network_interface_metrics do
75
+ yield flush_metrics, 0
76
+ end
77
+ end
78
+ end
79
+ end
80
+ end
81
+
82
+ private
83
+
84
+ def options
85
+ return @options if @options
86
+ @options = {
87
+ interval: 10,
88
+ handler: 'graphite',
89
+ add_client_prefix: true,
90
+ path_prefix: 'WMI',
91
+ prefix_at_start: 0
92
+ }
93
+ if settings[:wmi_metrics].is_a?(Hash)
94
+ @options.merge!(settings[:wmi_metrics])
95
+ end
96
+ @options
97
+ end
98
+
99
+ def flush_metrics
100
+ metrics = @metrics.join("\n") + "\n"
101
+ @metrics = []
102
+ metrics
103
+ end
104
+
105
+ def add_metric(*args) # rubocop:disable all
106
+ value = args.pop
107
+ path = []
108
+ path << options[:path_prefix] if options[:prefix_at_start]
109
+ path << settings[:client][:name] if options[:add_client_prefix]
110
+ path << options[:path_prefix] unless options[:prefix_at_start]
111
+ path = (path + args).join('.')
112
+ @metrics << [path, value, Time.now.to_i].join(' ')
113
+ end
114
+
115
+ def formatted_perf_data(provider, &_callback)
116
+ full_provider = 'Win32_PerfFormattedData_' + provider
117
+ EM.next_tick do
118
+ result = []
119
+ begin
120
+ result = @wmi.ExecQuery('select * from ' + full_provider)
121
+ rescue => error
122
+ @logger.debug('wmi query error', error: error.to_s)
123
+ end
124
+ yield result
125
+ end
126
+ end
127
+
128
+ def memory_metrics
129
+ formatted_perf_data('PerfOS_Memory') do |result|
130
+ result.each do |data|
131
+ %w(
132
+ AvailableBytes
133
+ CacheBytes
134
+ CommittedBytes
135
+ ).each do |point|
136
+ add_metric('Memory', point, data.send(point.to_sym))
137
+ end
138
+ end
139
+ yield
140
+ end
141
+ end
142
+
143
+ def disk_metrics
144
+ formatted_perf_data('PerfDisk_LogicalDisk') do |disks|
145
+ disks.each do |data|
146
+ %w(
147
+ AvgDiskQueueLength
148
+ FreeMegabytes
149
+ PercentDiskTime
150
+ PercentFreeSpace
151
+ ).each do |point|
152
+ disk_name = data.Name.gsub(/[^0-9a-z]/i, '')
153
+ add_metric('Disk', disk_name, point, data.send(point.to_sym))
154
+ end
155
+ end
156
+ yield
157
+ end
158
+ end
159
+
160
+ def cpu_metrics
161
+ formatted_perf_data('PerfOS_Processor') do |processors|
162
+ processors.each do |data|
163
+ %w(
164
+ InterruptsPerSec
165
+ PercentIdleTime
166
+ PercentInterruptTime
167
+ PercentPrivilegedTime
168
+ PercentProcessorTime
169
+ PercentUserTime
170
+ ).each do |point|
171
+ cpu_name = data.Name.gsub(/[^0-9a-z]/i, '')
172
+ add_metric('CPU', cpu_name, point, data.send(point.to_sym))
173
+ end
174
+ end
175
+ yield
176
+ end
177
+ end
178
+
179
+ def network_interface_metrics
180
+ formatted_perf_data('Tcpip_NetworkInterface') do |interfaces|
181
+ interfaces.each do |data|
182
+ %w(
183
+ BytesReceivedPerSec
184
+ BytesSentPerSec
185
+ BytesTotalPerSec
186
+ OutputQueueLength
187
+ PacketsOutboundDiscarded
188
+ PacketsOutboundErrors
189
+ PacketsPerSec
190
+ PacketsReceivedDiscarded
191
+ PacketsReceivedErrors
192
+ PacketsReceivedPerSec
193
+ PacketsSentPerSec
194
+ ).each do |point|
195
+ interface_name = data.Name.gsub(/[^0-9a-z]/i, '')
196
+ add_metric('Interface', interface_name, point, data.send(point.to_sym))
197
+ end
198
+ end
199
+ yield
200
+ end
201
+ end
202
+ end
203
+ end
204
+ end
@@ -0,0 +1,51 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # iis-current-connections-metrics
4
+ #
5
+ # DESCRIPTION:
6
+ #
7
+ # OUTPUT:
8
+ # metric data
9
+ #
10
+ # PLATFORMS:
11
+ # Windows
12
+ #
13
+ # DEPENDENCIES:
14
+ # gem: sensu-plugin
15
+ # gem: socket
16
+ #
17
+ # USAGE:
18
+ #
19
+ # NOTES:
20
+ # Tested on Windows 2012RC2.
21
+ #
22
+ # LICENSE:
23
+ # Yohei Kawahara <inokara@gmail.com>
24
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
25
+ # for details.
26
+ #
27
+
28
+ require 'sensu-plugin/metric/cli'
29
+ require 'socket'
30
+
31
+ #
32
+ # IIS Current Connections Metric
33
+ #
34
+ class IisCurrentConnectionsMetric < Sensu::Plugin::Metric::CLI::Graphite
35
+ option :scheme,
36
+ description: 'Metric naming scheme, text to prepend to .$parent.$child',
37
+ long: '--scheme SCHEME',
38
+ default: "#{Socket.gethostname}.iis_current_connections"
39
+
40
+ option :site,
41
+ short: '-s sitename',
42
+ default: '_Total'
43
+
44
+ def run # rubocop:disable all
45
+ io = IO.popen("typeperf -sc 1 \"Web Service(#{config[:site]})\\Current\ Connections\"")
46
+ current_connection = io.readlines[2].split(',')[1].gsub(/"/, '').to_f
47
+
48
+ output [config[:scheme], config[:site]].join('.'), current_connection
49
+ ok
50
+ end
51
+ end
@@ -0,0 +1,51 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # iis-get-requests-metrics
4
+ #
5
+ # DESCRIPTION:
6
+ #
7
+ # OUTPUT:
8
+ # metric data
9
+ #
10
+ # PLATFORMS:
11
+ # Windows
12
+ #
13
+ # DEPENDENCIES:
14
+ # gem: sensu-plugin
15
+ # gem: socket
16
+ #
17
+ # USAGE:
18
+ #
19
+ # NOTES:
20
+ # Tested on Windows 2012RC2.
21
+ #
22
+ # LICENSE:
23
+ # Yohei Kawahara <inokara@gmail.com>
24
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
25
+ # for details.
26
+ #
27
+
28
+ require 'sensu-plugin/metric/cli'
29
+ require 'socket'
30
+
31
+ #
32
+ # IIS Get Requests
33
+ #
34
+ class IisGetRequests < Sensu::Plugin::Metric::CLI::Graphite
35
+ option :scheme,
36
+ description: 'Metric naming scheme, text to prepend to .$parent.$child',
37
+ long: '--scheme SCHEME',
38
+ default: "#{Socket.gethostname}.iis_get_requests"
39
+
40
+ option :site,
41
+ short: '-s sitename',
42
+ default: '_Total'
43
+
44
+ def run # rubocop:disable all
45
+ io = IO.popen("typeperf -sc 1 \"Web Service(#{config[:site]})\\Get\ Requests\/sec\"")
46
+ get_requests = io.readlines[2].split(',')[1].gsub(/"/, '').to_f
47
+
48
+ output [config[:scheme], config[:site]].join('.'), get_requests
49
+ ok
50
+ end
51
+ end
@@ -0,0 +1,65 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # windows-cpu-load-metrics
4
+ #
5
+ # DESCRIPTION:
6
+ # This is metrics which outputs the CPU load in Graphite acceptable format.
7
+ # To get the cpu stats for Windows Server to send over to Graphite.
8
+ # It basically uses the typeperf to get the processor usage at a given particular time.
9
+ #
10
+ # OUTPUT:
11
+ # metric data
12
+ #
13
+ # PLATFORMS:
14
+ # Windows
15
+ #
16
+ # DEPENDENCIES:
17
+ # gem: sensu-plugin
18
+ # gem: socket
19
+ #
20
+ # USAGE:
21
+ #
22
+ # NOTES:
23
+ #
24
+ # LICENSE:
25
+ # Copyright 2013 <jashishtech@gmail.com>
26
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
27
+ # for details.
28
+ #
29
+
30
+ require 'sensu-plugin/metric/cli'
31
+ require 'socket'
32
+
33
+ #
34
+ # Cpu metric
35
+ #
36
+ class CpuMetric < Sensu::Plugin::Metric::CLI::Graphite
37
+ option :scheme,
38
+ description: 'Metric naming scheme, text to prepend to .$parent.$child',
39
+ long: '--scheme SCHEME',
40
+ default: "#{Socket.gethostname}"
41
+
42
+ def acquire_cpu_load
43
+ temp_arr = []
44
+ timestamp = Time.now.utc.to_i
45
+ IO.popen("typeperf -sc 1 \"processor(_total)\\% processor time\" ") { |io| io.each { |line| temp_arr.push(line) } }
46
+ temp = temp_arr[2].split(',')[1]
47
+ cpu_metric = temp[1, temp.length - 3].to_f
48
+ [cpu_metric, timestamp]
49
+ end
50
+
51
+ def run
52
+ values = acquire_cpu_load
53
+ metrics = {
54
+ cpu: {
55
+ loadavgsec: values[0]
56
+ }
57
+ }
58
+ metrics.each do |parent, children|
59
+ children.each do |child, value|
60
+ output [config[:scheme], parent, child].join('.'), value, values[1]
61
+ end
62
+ end
63
+ ok
64
+ end
65
+ end
@@ -0,0 +1,71 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # disk-usage-metrics
4
+ #
5
+ # DESCRIPTION:
6
+ # This plugin collects disk capacity metrics.
7
+ # Created to return values in same format as system/disk-usage-metric
8
+ #
9
+ # OUTPUT:
10
+ # metric data
11
+ #
12
+ # PLATFORMS:
13
+ # Windows
14
+ #
15
+ # DEPENDENCIES:
16
+ # gem: sensu-plugin
17
+ # gem: socket
18
+ #
19
+ # USAGE:
20
+ #
21
+ # NOTES:
22
+ #
23
+ # LICENSE:
24
+ # Copyright 2014 <alex.slynko@wonga.com>
25
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
26
+ # for details.
27
+ #
28
+
29
+ require 'sensu-plugin/metric/cli'
30
+ require 'socket'
31
+
32
+ #
33
+ # Disk Usage Metric
34
+ #
35
+ class DiskUsageMetric < Sensu::Plugin::Metric::CLI::Graphite
36
+ option :scheme,
37
+ description: 'Metric naming scheme, text to prepend to .$parent.$child',
38
+ long: '--scheme SCHEME',
39
+ default: "#{Socket.gethostname}.disk_usage"
40
+
41
+ option :ignore_mnt,
42
+ description: 'Ignore mounts matching pattern(s)',
43
+ short: '-i MNT[,MNT]',
44
+ long: '--ignore-mount',
45
+ proc: proc { |a| a.split(',') }
46
+
47
+ option :include_mnt,
48
+ description: 'Include only mounts matching pattern(s)',
49
+ short: '-I MNT[,MNT]',
50
+ long: '--include-mount',
51
+ proc: proc { |a| a.split(',') }
52
+
53
+ BYTES_TO_MBYTES = 1024 * 1024
54
+
55
+ def run # rubocop:disable all
56
+ `wmic logicaldisk get caption, drivetype, freespace, size`.split(/\n+/).each do |line|
57
+ caption, drivetype, freespace, size = line.split
58
+ next unless drivetype.to_i == 3
59
+ next if config[:ignore_mnt] && config[:ignore_mnt].find { |x| mnt.match(x) }
60
+ next if config[:include_mnt] && !config[:include_mnt].find { |x| mnt.match(x) }
61
+
62
+ caption = "disk_#{caption[0]}"
63
+ freespace = freespace.to_f / BYTES_TO_MBYTES
64
+ size = size.to_f / BYTES_TO_MBYTES
65
+ output [config[:scheme], caption, 'used'].join('.'), (size - freespace).round(2)
66
+ output [config[:scheme], caption, 'avail'].join('.'), freespace.round(2)
67
+ output [config[:scheme], caption, 'used_percentage'].join('.'), ((size - freespace) / size * 100).round
68
+ end
69
+ ok
70
+ end
71
+ end
@@ -0,0 +1,73 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # ram-usage-windows
4
+ #
5
+ # DESCRIPTION:
6
+ # This is metrics which outputs the Ram usage in Graphite acceptable format.
7
+ # To get the cpu stats for Windows Server to send over to Graphite.
8
+ # It basically uses the typeperf(To get available memory) and wmic(Used to get the usable memory size)
9
+ # to get the processor usage at a given particular time.
10
+ #
11
+ #
12
+ # OUTPUT:
13
+ # metric data
14
+ #
15
+ # PLATFORMS:
16
+ # Windows
17
+ #
18
+ # DEPENDENCIES:
19
+ # gem: sensu-plugin
20
+ # gem: socket
21
+ #
22
+ # USAGE:
23
+ #
24
+ # NOTES:
25
+ #
26
+ # LICENSE:
27
+ # Copyright 2013 <jashishtech@gmail.com>
28
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
29
+ # for details.
30
+ #
31
+
32
+ require 'sensu-plugin/metric/cli'
33
+ require 'socket'
34
+
35
+ #
36
+ # ram Metric
37
+ #
38
+ class RamMetric < Sensu::Plugin::Metric::CLI::Graphite
39
+ option :scheme,
40
+ description: 'Metric naming scheme, text to prepend to .$parent.$child',
41
+ long: '--scheme SCHEME',
42
+ default: "#{Socket.gethostname}"
43
+
44
+ def acquire_ram_usage # rubocop:disable all
45
+ temp_arr_1 = []
46
+ temp_arr_2 = []
47
+ timestamp = Time.now.utc.to_i
48
+ IO.popen("typeperf -sc 1 \"Memory\\Available bytes\" ") { |io| io.each { |line| temp_arr_1.push(line) } }
49
+ temp = temp_arr_1[2].split(',')[1]
50
+ ram_available_in_bytes = temp[1, temp.length - 3].to_f
51
+ IO.popen('wmic OS get TotalVisibleMemorySize /Value') { |io| io.each { |line| temp_arr_2.push(line) } }
52
+ total_ram = temp_arr_2[4].split('=')[1].to_f
53
+ total_ram_in_bytes = total_ram * 1000.0
54
+ ram_use_percent = (total_ram_in_bytes - ram_available_in_bytes) * 100.0 / (total_ram_in_bytes)
55
+ [ram_use_percent.round(2), timestamp]
56
+ end
57
+
58
+ def run
59
+ # To get the ram usage
60
+ values = acquire_ram_usage
61
+ metrics = {
62
+ ram: {
63
+ ramUsagePersec: values[0]
64
+ }
65
+ }
66
+ metrics.each do|parent, children|
67
+ children.each do|child, value|
68
+ output [config[:scheme], parent, child].join('.'), value, values[1]
69
+ end
70
+ end
71
+ ok
72
+ end
73
+ end
@@ -0,0 +1,7 @@
1
+ #
2
+ # Set gem version
3
+ #
4
+ module SensuPluginsWindows
5
+ # Gem version
6
+ VERSION = '0.0.1.alpha.2'
7
+ end
metadata ADDED
@@ -0,0 +1,231 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sensu-plugins-windows
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1.alpha.2
5
+ platform: ruby
6
+ authors:
7
+ - Yieldbot, Inc. and contributors
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain:
11
+ - |
12
+ -----BEGIN CERTIFICATE-----
13
+ MIIDgDCCAmigAwIBAgIBATANBgkqhkiG9w0BAQUFADBDMRIwEAYDVQQDDAltYXR0
14
+ am9uZXMxGDAWBgoJkiaJk/IsZAEZFgh5aWVsZGJvdDETMBEGCgmSJomT8ixkARkW
15
+ A2NvbTAeFw0xNTAxMjgyMTAyNTFaFw0xNjAxMjgyMTAyNTFaMEMxEjAQBgNVBAMM
16
+ CW1hdHRqb25lczEYMBYGCgmSJomT8ixkARkWCHlpZWxkYm90MRMwEQYKCZImiZPy
17
+ LGQBGRYDY29tMIIBIjANBgkqhkiG9w0BAQEFAAOCAQ8AMIIBCgKCAQEAyTSzVYnO
18
+ CLgyrIyT1mBQakArQyW8xhi6MlDqyzXHJGeERT790U6EgoBVeS4XoK0ptFZNR8Tf
19
+ zko0w+Nv47TarSCgkPOaxY+mxWnAVR10dOmfeLr7huiMyps+YD56/EF2FqQ3jf/+
20
+ qohENfKD91qy1ieEy+Fn7Pf74ltbNKUdkb9a9eFXQ0DQ4ip5vik7DzjQkUTj4lca
21
+ k6ArwnmHX4YDhZoYtrQJ8jVktN0/+NtA40M5qkCYHNe5tUW25b/tKVYuioxG6b2Z
22
+ oIzaZxRLxf6HVAWpCVRT/F5+/yjigkX4u++eYacfLGleXQzoK7BL65vHGMJygWEE
23
+ 0TKGqFOrl/L0AQIDAQABo38wfTAJBgNVHRMEAjAAMAsGA1UdDwQEAwIEsDAdBgNV
24
+ HQ4EFgQUEf6a8Td7MrSZc8ImbLFZAENPbz0wIQYDVR0RBBowGIEWbWF0dGpvbmVz
25
+ QHlpZWxkYm90LmNvbTAhBgNVHRIEGjAYgRZtYXR0am9uZXNAeWllbGRib3QuY29t
26
+ MA0GCSqGSIb3DQEBBQUAA4IBAQBbzXAYA3BVGw8DZ0YYoY1VHPNEcH5qPIApmHO8
27
+ rvSmuUT0yMEi7u00H/5uHRFf4LleGT/+sTdyXKsNPGT9kdRuQEgwi+vf7Zfvd8aX
28
+ UF/+4VkEYf/8rV8Ere6u2QaWPgApdMV6JjKr1fAwCTd8AuGXNaWItiPPMseSQzLJ
29
+ JKP4hVvbc1d+oS925B1lcBiqn2aYvElbyNAVmQPywNNqkWmvtlqj9ZVJfV5HQLdu
30
+ 8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
31
+ HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
32
+ -----END CERTIFICATE-----
33
+ date: 2015-03-19 00:00:00.000000000 Z
34
+ dependencies:
35
+ - !ruby/object:Gem::Dependency
36
+ name: sensu-plugin
37
+ requirement: !ruby/object:Gem::Requirement
38
+ requirements:
39
+ - - '='
40
+ - !ruby/object:Gem::Version
41
+ version: 1.1.0
42
+ type: :runtime
43
+ prerelease: false
44
+ version_requirements: !ruby/object:Gem::Requirement
45
+ requirements:
46
+ - - '='
47
+ - !ruby/object:Gem::Version
48
+ version: 1.1.0
49
+ - !ruby/object:Gem::Dependency
50
+ name: codeclimate-test-reporter
51
+ requirement: !ruby/object:Gem::Requirement
52
+ requirements:
53
+ - - ">="
54
+ - !ruby/object:Gem::Version
55
+ version: '0'
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - ">="
61
+ - !ruby/object:Gem::Version
62
+ version: '0'
63
+ - !ruby/object:Gem::Dependency
64
+ name: rubocop
65
+ requirement: !ruby/object:Gem::Requirement
66
+ requirements:
67
+ - - '='
68
+ - !ruby/object:Gem::Version
69
+ version: 0.17.0
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - '='
75
+ - !ruby/object:Gem::Version
76
+ version: 0.17.0
77
+ - !ruby/object:Gem::Dependency
78
+ name: rspec
79
+ requirement: !ruby/object:Gem::Requirement
80
+ requirements:
81
+ - - "~>"
82
+ - !ruby/object:Gem::Version
83
+ version: '3.1'
84
+ type: :development
85
+ prerelease: false
86
+ version_requirements: !ruby/object:Gem::Requirement
87
+ requirements:
88
+ - - "~>"
89
+ - !ruby/object:Gem::Version
90
+ version: '3.1'
91
+ - !ruby/object:Gem::Dependency
92
+ name: bundler
93
+ requirement: !ruby/object:Gem::Requirement
94
+ requirements:
95
+ - - "~>"
96
+ - !ruby/object:Gem::Version
97
+ version: '1.7'
98
+ type: :development
99
+ prerelease: false
100
+ version_requirements: !ruby/object:Gem::Requirement
101
+ requirements:
102
+ - - "~>"
103
+ - !ruby/object:Gem::Version
104
+ version: '1.7'
105
+ - !ruby/object:Gem::Dependency
106
+ name: rake
107
+ requirement: !ruby/object:Gem::Requirement
108
+ requirements:
109
+ - - "~>"
110
+ - !ruby/object:Gem::Version
111
+ version: '10.0'
112
+ type: :development
113
+ prerelease: false
114
+ version_requirements: !ruby/object:Gem::Requirement
115
+ requirements:
116
+ - - "~>"
117
+ - !ruby/object:Gem::Version
118
+ version: '10.0'
119
+ - !ruby/object:Gem::Dependency
120
+ name: github-markup
121
+ requirement: !ruby/object:Gem::Requirement
122
+ requirements:
123
+ - - "~>"
124
+ - !ruby/object:Gem::Version
125
+ version: '1.3'
126
+ type: :development
127
+ prerelease: false
128
+ version_requirements: !ruby/object:Gem::Requirement
129
+ requirements:
130
+ - - "~>"
131
+ - !ruby/object:Gem::Version
132
+ version: '1.3'
133
+ - !ruby/object:Gem::Dependency
134
+ name: redcarpet
135
+ requirement: !ruby/object:Gem::Requirement
136
+ requirements:
137
+ - - "~>"
138
+ - !ruby/object:Gem::Version
139
+ version: '3.2'
140
+ type: :development
141
+ prerelease: false
142
+ version_requirements: !ruby/object:Gem::Requirement
143
+ requirements:
144
+ - - "~>"
145
+ - !ruby/object:Gem::Version
146
+ version: '3.2'
147
+ - !ruby/object:Gem::Dependency
148
+ name: yard
149
+ requirement: !ruby/object:Gem::Requirement
150
+ requirements:
151
+ - - "~>"
152
+ - !ruby/object:Gem::Version
153
+ version: '0.8'
154
+ type: :development
155
+ prerelease: false
156
+ version_requirements: !ruby/object:Gem::Requirement
157
+ requirements:
158
+ - - "~>"
159
+ - !ruby/object:Gem::Version
160
+ version: '0.8'
161
+ - !ruby/object:Gem::Dependency
162
+ name: pry
163
+ requirement: !ruby/object:Gem::Requirement
164
+ requirements:
165
+ - - "~>"
166
+ - !ruby/object:Gem::Version
167
+ version: '0.10'
168
+ type: :development
169
+ prerelease: false
170
+ version_requirements: !ruby/object:Gem::Requirement
171
+ requirements:
172
+ - - "~>"
173
+ - !ruby/object:Gem::Version
174
+ version: '0.10'
175
+ description: A set of plugins to monitor Windows OS
176
+ email: "<sensu-users@googlegroups.com>"
177
+ executables:
178
+ - check-iis-current-connections.rb
179
+ - check-windows-cpu-load.rb
180
+ - check-windows-disk.rb
181
+ - check-windows-process.rb
182
+ - check-windows-service.rb
183
+ - extension-wmi-metrics.rb
184
+ - metrics-iis-current-connections.rb
185
+ - metrics-iis-get-requests.rb
186
+ - metrics-windows-cpu-load.rb
187
+ - metrics-windows-disk-usage.rb
188
+ - metrics-windows-ram-usage.rb
189
+ extensions: []
190
+ extra_rdoc_files: []
191
+ files:
192
+ - CHANGELOG.md
193
+ - LICENSE
194
+ - README.md
195
+ - bin/check-iis-current-connections.rb
196
+ - bin/check-windows-cpu-load.rb
197
+ - bin/check-windows-disk.rb
198
+ - bin/check-windows-process.rb
199
+ - bin/check-windows-service.rb
200
+ - bin/extension-wmi-metrics.rb
201
+ - bin/metrics-iis-current-connections.rb
202
+ - bin/metrics-iis-get-requests.rb
203
+ - bin/metrics-windows-cpu-load.rb
204
+ - bin/metrics-windows-disk-usage.rb
205
+ - bin/metrics-windows-ram-usage.rb
206
+ - lib/sensu-plugins-windows.rb
207
+ homepage: https://github.com/sensu-plugins/sensu-plugins-windows
208
+ licenses:
209
+ - MIT
210
+ metadata: {}
211
+ post_install_message:
212
+ rdoc_options: []
213
+ require_paths:
214
+ - lib
215
+ required_ruby_version: !ruby/object:Gem::Requirement
216
+ requirements:
217
+ - - ">="
218
+ - !ruby/object:Gem::Version
219
+ version: 1.9.3
220
+ required_rubygems_version: !ruby/object:Gem::Requirement
221
+ requirements:
222
+ - - ">"
223
+ - !ruby/object:Gem::Version
224
+ version: 1.3.1
225
+ requirements: []
226
+ rubyforge_project:
227
+ rubygems_version: 2.2.2
228
+ signing_key:
229
+ specification_version: 4
230
+ summary: A set of plugins to monitor Windows OS
231
+ test_files: []
metadata.gz.sig ADDED
Binary file