sensu-plugins-windows 0.0.5 → 0.0.6

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 302087010158a3d9d47c84419a858097a70605ca
4
- data.tar.gz: a21fe970ec5274211ab64a2d40398af07e06ce0a
3
+ metadata.gz: 2d8fb89ac01ad20dd0fc03e54107e91552f73b05
4
+ data.tar.gz: dd2ffcfc3f3bcc7f6a62224fad80b03868e86178
5
5
  SHA512:
6
- metadata.gz: ba091be233f41ba2366da14d731a6b3b5d13d2b2ea1c1f609000971366c25a39d44d4a5d14f8e520bbb9d05958c7ae312aedca2f0235b2014030cb1ee615a3ee
7
- data.tar.gz: 8ee601cfcbbc244cffb7137b3feb1aaef3a823ad15606f67c0f3666a36ca55102f59fa33eeeb47a3b8fffc69bd3db595f42e45b34a7c2b41de70b8b24d67cd68
6
+ metadata.gz: 74b111980b9841ddd31d8727a3c18008748cc689fdcd553037b98617d87d264a15221e50829f4273f9ca5edb0cbfbcfe761e578540dc76da51a19f5575eec449
7
+ data.tar.gz: 5bbfe81df31292347140722dbb70ae818ebcc9f52288f0e97f317c3918070f5f2d63808f43ad6a7d74e0a7dac25bfd7701acf6ff4e86224013967fc9c3001bd4
checksums.yaml.gz.sig CHANGED
Binary file
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG.md CHANGED
@@ -3,7 +3,13 @@ This project adheres to [Semantic Versioning](http://semver.org/).
3
3
 
4
4
  This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
5
5
 
6
- ## Unreleased][unreleased]
6
+ ## Unreleased
7
+
8
+ ## [0.0.6] - 2015-08-04
9
+ ### Changed
10
+ - updated check-windows-process to use native WMI hooks
11
+ - bump rubocop
12
+ -change binstubs to only be created for ruby files
7
13
 
8
14
  ## [0.0.5] - 2015-07-14
9
15
  ### Changed
@@ -31,3 +37,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
31
37
  ### Added
32
38
  - initial release
33
39
 
40
+ [unreleased]: https://github.com/sensu-plugins/sensu-plugins-ssl/compare/0.0.6...HEAD
41
+ [0.0.6]: https://github.com/sensu-plugins/sensu-plugins-ssl/compare/0.0.5...0.0.6
42
+ [0.0.5]: https://github.com/sensu-plugins/sensu-plugins-ssl/compare/0.0.4...0.0.5
43
+ [0.0.4]: https://github.com/sensu-plugins/sensu-plugins-ssl/compare/0.0.2...0.0.4
44
+ [0.0.2]: https://github.com/sensu-plugins/sensu-plugins-ssl/compare/0.0.1...0.0.2
data/README.md CHANGED
@@ -14,7 +14,8 @@
14
14
  * bin/metrics-windows-disk-usage.rb
15
15
  * bin/metrics-windows-network.rb
16
16
  * bin/metrics-windows-ram-usage.rb
17
- * bin/check-windows-cpu-load.rb
17
+ * bin/metrics-windows-uptime.rb
18
+ * bin/check-windows-cpu-load.rb
18
19
  * bin/check-windows-disk.rb
19
20
  * bin/check-windows-process.rb
20
21
  * bin/check-windows-ram.rb
@@ -24,6 +25,6 @@
24
25
 
25
26
  ## Installation
26
27
 
27
- [Installation and Setup](https://github.com/sensu-plugins/documentation/blob/master/user_docs/installation_instructions.md)
28
+ [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
28
29
 
29
30
  ## Notes
@@ -40,7 +40,7 @@ class CheckWindowsCpuLoad < Sensu::Plugin::Check::CLI
40
40
  default: 95,
41
41
  proc: proc(&:to_i)
42
42
 
43
- def run # rubocop:disable all
43
+ def run
44
44
  io = IO.popen("typeperf -sc 1 \"processor(_total)\\% processor time\"")
45
45
  cpu_load = io.readlines[2].split(',')[1].gsub(/"/, '').to_i
46
46
  critical "CPU at #{cpu_load}%" if cpu_load > config[:critical]
@@ -63,7 +63,7 @@ class CheckDisk < Sensu::Plugin::Check::CLI
63
63
  @warn_fs = []
64
64
  end
65
65
 
66
- def read_wmic # rubocop:disable all
66
+ def read_wmic
67
67
  `wmic volume where DriveType=3 list brief`.split("\n").drop(1).each do |line|
68
68
  begin
69
69
  # #YELLOW
@@ -16,32 +16,78 @@
16
16
  # gem: sensu-plugin
17
17
  #
18
18
  # USAGE:
19
+ # check-windows-process -p <process substr to match> [ -w <warn age> ]
19
20
  #
20
21
  # NOTES:
21
22
  #
22
23
  # LICENSE:
23
- # Copyright 2013 <jashishtech@gmail.com>
24
+ # Copyright 2015 <onetinov@lxrb.com>
24
25
  # Released under the same terms as Sensu (the MIT license); see LICENSE
25
26
  # for details.
26
27
  #
28
+ require 'optparse'
29
+ require 'time'
30
+ require 'win32ole'
27
31
 
28
- require 'sensu-plugin/check/cli'
32
+ options = {}
33
+ parser = OptionParser.new do |opts|
34
+ opts.banner = 'Usage: check-windows-process.rb [options]'
35
+ opts.on('-h', '--help', 'Display this screen') do
36
+ puts opts
37
+ exit
38
+ end
29
39
 
30
- #
31
- # Check Database
32
- #
33
- class CheckDatabase < Sensu::Plugin::Check::CLI
34
- option :process, short: '-p process'
40
+ options[:procname] = ''
41
+ opts.on('-p', '--processname PROCESS', 'Unique process string to search for.') do |p|
42
+ options[:procname] = p
43
+ if p == ''
44
+ STDERR.puts 'Empty string for -p : Expected a string to match against.'
45
+ exit 3
46
+ end
47
+ end
48
+
49
+ options[:warn] = nil
50
+ opts.on('-w', '--warning [SECONDS]', 'Minimum process age in secs - Else warn') do |w|
51
+ begin
52
+ options[:warn] = Integer(w)
53
+ rescue ArgumentError
54
+ STDERR.puts 'Optional -w needs to be a value in seconds'
55
+ exit 3
56
+ end
57
+ end
58
+ end
59
+
60
+ parser.parse!
61
+
62
+ if options[:procname] == ''
63
+ STDERR.puts 'Expected a process to match against.'
64
+ fail OptionParser::MissingArgument
65
+ end
35
66
 
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
67
+ wmi = WIN32OLE.connect('winmgmts://')
68
+
69
+ # Assume Critical error (2) if this loop fails
70
+ status = 2
71
+ wmi.ExecQuery('select * from win32_process').each do |process|
72
+ next unless process.Name.downcase.include? options[:procname].downcase
73
+ if !options[:warn].nil?
74
+ delta_days = DateTime.now - DateTime.parse(process.CreationDate)
75
+ delta_secs = (delta_days * 24 * 60 * 60).to_i
76
+ if delta_secs > options[:warn]
77
+ puts "OK: #{process.Name} running more than #{options[:warn]} seconds."
78
+ status = 0
42
79
  else
43
- message config[:process] + ' is running'
44
- ok
80
+ puts "WARNING: #{process.Name} only running for #{delta_secs} seconds."
81
+ status = 1
45
82
  end
83
+ else
84
+ puts "OK: #{process.Name} running."
85
+ status = 0
46
86
  end
47
87
  end
88
+
89
+ if status == 2
90
+ puts "Critical: #{options[:procname]} not found in winmgmts:root\\cimv2:Win32_Process"
91
+ end
92
+
93
+ exit status
@@ -40,7 +40,7 @@ class CheckWindowsRAMLoad < Sensu::Plugin::Check::CLI
40
40
  default: 95,
41
41
  proc: proc(&:to_i)
42
42
 
43
- def acquire_ram_usage # rubocop:disable all
43
+ def acquire_ram_usage
44
44
  temp_arr_1 = []
45
45
  temp_arr_2 = []
46
46
  IO.popen("typeperf -sc 1 \"Memory\\Available bytes\" ") { |io| io.each { |line| temp_arr_1.push(line) } }
@@ -53,7 +53,7 @@ class CheckWindowsRAMLoad < Sensu::Plugin::Check::CLI
53
53
  ram_use_percent.round(2)
54
54
  end
55
55
 
56
- def run # rubocop:disable all
56
+ def run
57
57
  ram_load = acquire_ram_usage
58
58
  critical "RAM at #{ram_load}%" if ram_load > config[:critical]
59
59
  warning "RAM at #{ram_load}%" if ram_load > config[:warning]
@@ -39,7 +39,7 @@ class CheckWinService < Sensu::Plugin::Check::CLI
39
39
  long: '--service SERVICE',
40
40
  short: '-s SERVICE'
41
41
 
42
- def run # rubocop:disable all
42
+ def run
43
43
  temp = system('tasklist /svc|findstr /i ' + config[:service])
44
44
  if temp == false
45
45
  message config[:service] + ' is not running'
@@ -51,7 +51,7 @@ class DiskUsageMetric < Sensu::Plugin::Metric::CLI::Graphite
51
51
 
52
52
  BYTES_TO_MBYTES = 1024 * 1024
53
53
 
54
- def run # rubocop:disable all
54
+ def run
55
55
  `wmic logicaldisk get caption, drivetype, freespace, size`.split(/\n+/).each do |line|
56
56
  caption, drivetype, freespace, size = line.split
57
57
  next unless drivetype.to_i == 3
@@ -40,7 +40,7 @@ class RamMetric < Sensu::Plugin::Metric::CLI::Graphite
40
40
  long: '--scheme SCHEME',
41
41
  default: "#{Socket.gethostname}"
42
42
 
43
- def acquire_ram_usage # rubocop:disable all
43
+ def acquire_ram_usage
44
44
  temp_arr_1 = []
45
45
  temp_arr_2 = []
46
46
  timestamp = Time.now.utc.to_i
@@ -2,7 +2,7 @@ module SensuPluginsWindows
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- PATCH = 5
5
+ PATCH = 6
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-windows
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.5
4
+ version: 0.0.6
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors
@@ -30,7 +30,7 @@ cert_chain:
30
30
  8sHuVruarogxxKPBzlL2is4EUb6oN/RdpGx2l4254+nyR+abg//Ed27Ym0PkB4lk
31
31
  HP0m8WSjZmFr109pE/sVsM5jtOCvogyujQOjNVGN4gz1wwPr
32
32
  -----END CERTIFICATE-----
33
- date: 2015-07-14 00:00:00.000000000 Z
33
+ date: 2015-08-12 00:00:00.000000000 Z
34
34
  dependencies:
35
35
  - !ruby/object:Gem::Dependency
36
36
  name: sensu-plugin
@@ -47,61 +47,61 @@ dependencies:
47
47
  - !ruby/object:Gem::Version
48
48
  version: 1.2.0
49
49
  - !ruby/object:Gem::Dependency
50
- name: codeclimate-test-reporter
50
+ name: bundler
51
51
  requirement: !ruby/object:Gem::Requirement
52
52
  requirements:
53
53
  - - "~>"
54
54
  - !ruby/object:Gem::Version
55
- version: '0.4'
55
+ version: '1.7'
56
56
  type: :development
57
57
  prerelease: false
58
58
  version_requirements: !ruby/object:Gem::Requirement
59
59
  requirements:
60
60
  - - "~>"
61
61
  - !ruby/object:Gem::Version
62
- version: '0.4'
62
+ version: '1.7'
63
63
  - !ruby/object:Gem::Dependency
64
- name: rubocop
64
+ name: codeclimate-test-reporter
65
65
  requirement: !ruby/object:Gem::Requirement
66
66
  requirements:
67
- - - '='
67
+ - - "~>"
68
68
  - !ruby/object:Gem::Version
69
- version: '0.30'
69
+ version: '0.4'
70
70
  type: :development
71
71
  prerelease: false
72
72
  version_requirements: !ruby/object:Gem::Requirement
73
73
  requirements:
74
- - - '='
74
+ - - "~>"
75
75
  - !ruby/object:Gem::Version
76
- version: '0.30'
76
+ version: '0.4'
77
77
  - !ruby/object:Gem::Dependency
78
- name: rspec
78
+ name: github-markup
79
79
  requirement: !ruby/object:Gem::Requirement
80
80
  requirements:
81
81
  - - "~>"
82
82
  - !ruby/object:Gem::Version
83
- version: '3.1'
83
+ version: '1.3'
84
84
  type: :development
85
85
  prerelease: false
86
86
  version_requirements: !ruby/object:Gem::Requirement
87
87
  requirements:
88
88
  - - "~>"
89
89
  - !ruby/object:Gem::Version
90
- version: '3.1'
90
+ version: '1.3'
91
91
  - !ruby/object:Gem::Dependency
92
- name: bundler
92
+ name: pry
93
93
  requirement: !ruby/object:Gem::Requirement
94
94
  requirements:
95
95
  - - "~>"
96
96
  - !ruby/object:Gem::Version
97
- version: '1.7'
97
+ version: '0.10'
98
98
  type: :development
99
99
  prerelease: false
100
100
  version_requirements: !ruby/object:Gem::Requirement
101
101
  requirements:
102
102
  - - "~>"
103
103
  - !ruby/object:Gem::Version
104
- version: '1.7'
104
+ version: '0.10'
105
105
  - !ruby/object:Gem::Dependency
106
106
  name: rake
107
107
  requirement: !ruby/object:Gem::Requirement
@@ -117,61 +117,61 @@ dependencies:
117
117
  - !ruby/object:Gem::Version
118
118
  version: '10.0'
119
119
  - !ruby/object:Gem::Dependency
120
- name: github-markup
120
+ name: redcarpet
121
121
  requirement: !ruby/object:Gem::Requirement
122
122
  requirements:
123
123
  - - "~>"
124
124
  - !ruby/object:Gem::Version
125
- version: '1.3'
125
+ version: '3.2'
126
126
  type: :development
127
127
  prerelease: false
128
128
  version_requirements: !ruby/object:Gem::Requirement
129
129
  requirements:
130
130
  - - "~>"
131
131
  - !ruby/object:Gem::Version
132
- version: '1.3'
132
+ version: '3.2'
133
133
  - !ruby/object:Gem::Dependency
134
- name: redcarpet
134
+ name: rubocop
135
135
  requirement: !ruby/object:Gem::Requirement
136
136
  requirements:
137
- - - "~>"
137
+ - - '='
138
138
  - !ruby/object:Gem::Version
139
- version: '3.2'
139
+ version: 0.32.1
140
140
  type: :development
141
141
  prerelease: false
142
142
  version_requirements: !ruby/object:Gem::Requirement
143
143
  requirements:
144
- - - "~>"
144
+ - - '='
145
145
  - !ruby/object:Gem::Version
146
- version: '3.2'
146
+ version: 0.32.1
147
147
  - !ruby/object:Gem::Dependency
148
- name: yard
148
+ name: rspec
149
149
  requirement: !ruby/object:Gem::Requirement
150
150
  requirements:
151
151
  - - "~>"
152
152
  - !ruby/object:Gem::Version
153
- version: '0.8'
153
+ version: '3.1'
154
154
  type: :development
155
155
  prerelease: false
156
156
  version_requirements: !ruby/object:Gem::Requirement
157
157
  requirements:
158
158
  - - "~>"
159
159
  - !ruby/object:Gem::Version
160
- version: '0.8'
160
+ version: '3.1'
161
161
  - !ruby/object:Gem::Dependency
162
- name: pry
162
+ name: yard
163
163
  requirement: !ruby/object:Gem::Requirement
164
164
  requirements:
165
165
  - - "~>"
166
166
  - !ruby/object:Gem::Version
167
- version: '0.10'
167
+ version: '0.8'
168
168
  type: :development
169
169
  prerelease: false
170
170
  version_requirements: !ruby/object:Gem::Requirement
171
171
  requirements:
172
172
  - - "~>"
173
173
  - !ruby/object:Gem::Version
174
- version: '0.10'
174
+ version: '0.8'
175
175
  description: Sensu plugins for Windows
176
176
  email: "<sensu-users@googlegroups.com>"
177
177
  executables:
@@ -180,7 +180,6 @@ executables:
180
180
  - metrics-windows-network.rb
181
181
  - metrics-windows-disk-usage.rb
182
182
  - metrics-windows-cpu-load.rb
183
- - extension-wmi-metrics.rb
184
183
  - check-windows-service.rb
185
184
  - check-windows-ram.rb
186
185
  - check-windows-process.rb
@@ -197,7 +196,6 @@ files:
197
196
  - bin/check-windows-process.rb
198
197
  - bin/check-windows-ram.rb
199
198
  - bin/check-windows-service.rb
200
- - bin/extension-wmi-metrics.rb
201
199
  - bin/metrics-windows-cpu-load.rb
202
200
  - bin/metrics-windows-disk-usage.rb
203
201
  - bin/metrics-windows-network.rb
@@ -231,7 +229,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
231
229
  version: '0'
232
230
  requirements: []
233
231
  rubyforge_project:
234
- rubygems_version: 2.4.6
232
+ rubygems_version: 2.4.8
235
233
  signing_key:
236
234
  specification_version: 4
237
235
  summary: Sensu plugins for Windows
metadata.gz.sig CHANGED
Binary file
@@ -1,213 +0,0 @@
1
- #! /usr/bin/env ruby
2
- #
3
- # extension-wmi-metrics.rb
4
- #
5
- # DESCRIPTION:
6
- # Collects a variety of system metrics every 60 seconds (by default).
7
- # Network metrics are accumulated over the time interval.
8
- # Expects a "graphite" handler on the Sensu server, eg:
9
- #
10
- # OUTPUT:
11
- # metric data
12
- #
13
- # PLATFORMS:
14
- # Windows
15
- #
16
- # DEPENDENCIES:
17
- # gem: sensu-plugin
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
- # Changelog
34
- # ----------
35
- # 03/11/2015 - Alan Smith (@cloakedcode) added cumulative metric
36
- # collection for network traffic over interval timespan.
37
- # LICENSE:
38
- # Copyright 2014 Heavy Water Operations, LLC.
39
- # Released under the same terms as Sensu (the MIT license); see LICENSE
40
- # for details.
41
- #
42
-
43
- require 'win32ole'
44
-
45
- module Sensu
46
- module Extension
47
- #
48
- #
49
- #
50
- class WMIMetrics < Check
51
- def name
52
- 'wmi_metrics'
53
- end
54
-
55
- def description
56
- 'collects system metrics, using wmi and the graphite plain-text format'
57
- end
58
-
59
- def definition
60
- {
61
- type: 'metric',
62
- name: name,
63
- interval: options[:interval],
64
- standalone: true,
65
- handler: options[:handler]
66
- }
67
- end
68
-
69
- def post_init
70
- @metrics = {}
71
- @wmi = WIN32OLE.connect('winmgmts://')
72
-
73
- # setup timer for cumulative metrics
74
- EM.add_periodic_timer(1) do
75
- network_interface_metrics do
76
- end
77
- end
78
- true
79
- end
80
-
81
- def run
82
- memory_metrics do
83
- disk_metrics do
84
- cpu_metrics do
85
- yield flush_metrics, 0
86
- end
87
- end
88
- end
89
- end
90
-
91
- private
92
-
93
- def options
94
- return @options if @options
95
- @options = {
96
- interval: 60,
97
- handler: 'graphite',
98
- add_client_prefix: true,
99
- path_prefix: 'WMI'
100
- }
101
- if settings[:wmi_metrics].is_a?(Hash)
102
- @options.merge!(settings[:wmi_metrics])
103
- end
104
- @options
105
- end
106
-
107
- def flush_metrics
108
- metrics = @metrics.map { |k, v| [k, v, Time.now.to_i].join(' ') }
109
- @metrics = {}
110
- metrics.join("\n") + "\n"
111
- end
112
-
113
- def add_metric(*args) # rubocop:disable all
114
- value = args.pop
115
- path = []
116
- path << settings[:client][:name] if options[:add_client_prefix]
117
- path << options[:path_prefix]
118
- path = (path + args).join('.')
119
-
120
- @metrics[path] = 0 if @metrics[path].nil?
121
- @metrics[path] += value.to_i
122
- end
123
-
124
- def formatted_perf_data(provider, &_callback)
125
- full_provider = 'Win32_PerfFormattedData_' + provider
126
- EM.next_tick do
127
- result = []
128
- begin
129
- result = @wmi.ExecQuery('select * from ' + full_provider)
130
- rescue => error
131
- @logger.debug('wmi query error', error: error.to_s)
132
- end
133
- yield result
134
- end
135
- end
136
-
137
- def memory_metrics
138
- formatted_perf_data('PerfOS_Memory') do |result|
139
- result.each do |data|
140
- %w(
141
- AvailableBytes
142
- CacheBytes
143
- CommittedBytes
144
- ).each do |point|
145
- add_metric('Memory', point, data.send(point.to_sym))
146
- end
147
- end
148
- yield
149
- end
150
- end
151
-
152
- def disk_metrics
153
- formatted_perf_data('PerfDisk_LogicalDisk') do |disks|
154
- disks.each do |data|
155
- %w(
156
- AvgDiskQueueLength
157
- FreeMegabytes
158
- PercentDiskTime
159
- PercentFreeSpace
160
- ).each do |point|
161
- disk_name = data.Name.gsub(/[^0-9a-z]/i, '')
162
- add_metric('Disk', disk_name, point, data.send(point.to_sym))
163
- end
164
- end
165
- yield
166
- end
167
- end
168
-
169
- def cpu_metrics
170
- formatted_perf_data('PerfOS_Processor') do |processors|
171
- processors.each do |data|
172
- %w(
173
- InterruptsPerSec
174
- PercentIdleTime
175
- PercentInterruptTime
176
- PercentPrivilegedTime
177
- PercentProcessorTime
178
- PercentUserTime
179
- ).each do |point|
180
- cpu_name = data.Name.gsub(/[^0-9a-z]/i, '')
181
- add_metric('CPU', cpu_name, point, data.send(point.to_sym))
182
- end
183
- end
184
- yield
185
- end
186
- end
187
-
188
- def network_interface_metrics
189
- formatted_perf_data('Tcpip_NetworkInterface') do |interfaces|
190
- interfaces.each do |data|
191
- %w(
192
- BytesReceivedPerSec
193
- BytesSentPerSec
194
- BytesTotalPerSec
195
- OutputQueueLength
196
- PacketsOutboundDiscarded
197
- PacketsOutboundErrors
198
- PacketsPerSec
199
- PacketsReceivedDiscarded
200
- PacketsReceivedErrors
201
- PacketsReceivedPerSec
202
- PacketsSentPerSec
203
- ).each do |point|
204
- interface_name = data.Name.gsub(/[^0-9a-z]/i, '')
205
- add_metric('Interface', interface_name, point, data.send(point.to_sym))
206
- end
207
- end
208
- yield
209
- end
210
- end
211
- end
212
- end
213
- end