sensu-plugins-load-checks 0.0.1

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: ef88dba16b787e0e9e33a2757ff5d61ddb5e7e39
4
+ data.tar.gz: 11959ba538b491ef80006e79e158add2f6baebad
5
+ SHA512:
6
+ metadata.gz: efbffb672b3ce44129118ec428cb1ac49f169a38de3819628884f7ccf3393f2dd824a769962ec19a0b61441a0f1e8a8de11431ab8ecd2216c7e1d1c99881eadd
7
+ data.tar.gz: 34930e5e14365a69f06499ec8aff3b605b588adf84d4853518f3c1017b3c6d0a54dcf538327c041ab431605974c51e50f4160fefa87522b4a48c7a639c1cb7fd
checksums.yaml.gz.sig ADDED
Binary file
data.tar.gz.sig ADDED
@@ -0,0 +1,4 @@
1
+ ��^�6F�o��x�%�m�^��X���ӎ�0#1Cqch(�e��`~�[k���
2
+ >_���n�P�M���T���b �˦�{㐤�~�Xm���G�a��z�|^Y`s�j���G�G
3
+ �ܱ�a3'���T<�u�(4�*�߇%OF�2�����dD���E�[+��e��IY�^d�`�|�f�i�S��rbVW
4
+ �Ӌ-�ZŚN�ĭ6R��a�0㊅�n�q�8f?oy�-u�g�����,
data/CHANGELOG.md ADDED
@@ -0,0 +1,12 @@
1
+ #Change Log
2
+ This project adheres to [Semantic Versioning](http://semver.org/).
3
+
4
+ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
5
+
6
+ ## Unreleased][unreleased]
7
+
8
+ ## 0.0.1 - 2015-05-21
9
+
10
+ ### Added
11
+ - initial release
12
+
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 Sensu-Plugins
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,22 @@
1
+ ## Sensu-Plugins-load-checks
2
+
3
+ [![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-load-checks.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-load-checks)
4
+ [![Gem Version](https://badge.fury.io/rb/sensu-plugins-load-checks.svg)](http://badge.fury.io/rb/sensu-plugins-load-checks)
5
+ [![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-load-checks/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-load-checks)
6
+ [![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-load-checks/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-load-checks)
7
+ [![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-load-checks.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-load-checks)
8
+ [ ![Codeship Status for sensu-plugins/sensu-plugins-load-checks](https://codeship.com/projects/5de2a3e0-db96-0132-e4a4-0eed4ec53b27/status?branch=master)](https://codeship.com/projects/79666)
9
+
10
+ ## Functionality
11
+
12
+ ## Files
13
+ * bin/check-load.rb
14
+ * bin/metircs-load.rb
15
+
16
+ ## Usage
17
+
18
+ ## Installation
19
+
20
+ [Installation and Setup](https://github.com/sensu-plugins/documentation/blob/master/user_docs/installation_instructions.md)
21
+
22
+ ## Notes
data/bin/check-load.rb ADDED
@@ -0,0 +1,94 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-load
4
+ #
5
+ # DESCRIPTION:
6
+ #
7
+ # OUTPUT:
8
+ # plain text
9
+ #
10
+ # PLATFORMS:
11
+ # Linux
12
+ #
13
+ # DEPENDENCIES:
14
+ # gem: sensu-plugin
15
+ #
16
+ # USAGE:
17
+ #
18
+ # NOTES:
19
+ #
20
+ # LICENSE:
21
+ # Copyright 2012 Sonian, Inc <chefs@sonian.net>
22
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
23
+ # for details.
24
+ #
25
+
26
+ # round(n) doesn't exist in ruby < 1.9
27
+ class Float
28
+ alias_method :oldround, :round
29
+
30
+ def round(precision = nil)
31
+ if precision.nil?
32
+ return self
33
+ else
34
+ return ((self * 10**precision).oldround.to_f) / (10**precision)
35
+ end
36
+ end
37
+ end
38
+
39
+ require 'sensu-plugin/check/cli'
40
+
41
+ class LoadAverage
42
+ def initialize(per_core = false)
43
+ @cores = per_core ? cpu_count : 1
44
+ @avg = File.read('/proc/loadavg').split.take(3).map { |a| (a.to_f / @cores).round(2) } rescue nil # rubocop:disable RescueModifier
45
+ end
46
+
47
+ def cpu_count
48
+ `grep -sc ^processor /proc/cpuinfo`.to_i rescue 0
49
+ end
50
+
51
+ def failed?
52
+ @avg.nil? || @cores.zero?
53
+ end
54
+
55
+ def exceed?(thresholds)
56
+ @avg.zip(thresholds).any? { |a, t| a > t }
57
+ end
58
+
59
+ def to_s
60
+ @avg.join(', ')
61
+ end
62
+ end
63
+
64
+ class CheckLoad < Sensu::Plugin::Check::CLI
65
+ option :warn,
66
+ short: '-w L1,L5,L15',
67
+ long: '--warn L1,L5,L15',
68
+ description: 'Load WARNING threshold, 1/5/15 min average',
69
+ proc: proc { |a| a.split(',').map(&:to_f) },
70
+ default: [10, 20, 30]
71
+
72
+ option :crit,
73
+ short: '-c L1,L5,L15',
74
+ long: '--crit L1,L5,L15',
75
+ description: 'Load CRITICAL threshold, 1/5/15 min average',
76
+ proc: proc { |a| a.split(',').map(&:to_f) },
77
+ default: [25, 50, 75]
78
+
79
+ option :per_core,
80
+ short: '-p',
81
+ long: '--per-core',
82
+ description: 'Divide load average results by cpu/core count',
83
+ boolean: 'true',
84
+ default: false
85
+
86
+ def run
87
+ avg = LoadAverage.new(config[:per_core])
88
+ warning 'Could not read load average from /proc' if avg.failed?
89
+ message "Load average: #{avg}"
90
+ critical if avg.exceed?(config[:crit])
91
+ warning if avg.exceed?(config[:warn])
92
+ ok
93
+ end
94
+ end
@@ -0,0 +1,100 @@
1
+ #! /usr/bin/env ruby
2
+ # encoding: UTF-8
3
+ # <script name>
4
+ #
5
+ # DESCRIPTION:
6
+ # This plugin uses uptime to collect load metrics
7
+ # Basically copied from sensu-community-plugins/plugins/system/vmstat-metrics.rb
8
+ #
9
+ # Load per processor
10
+ # ------------------
11
+ #
12
+ # Optionally, with `--per-core`, this plugin will calculate load per
13
+ # processor from the raw load average by dividing load average by the number
14
+ # of processors.
15
+ #
16
+ # The number of CPUs is determined by reading `/proc/cpuinfo`. This makes the
17
+ # feature Linux specific. Other OSs can be supported by adding OS # detection
18
+ # and a method to determine the number of CPUs.
19
+ #
20
+ # OUTPUT:
21
+ # metric data
22
+ #
23
+ # PLATFORMS:
24
+ # Linux, Windows, BSD, Solaris, etc
25
+ #
26
+ # DEPENDENCIES:
27
+ # gem: sensu-plugin
28
+ # gem: socket
29
+ #
30
+ # USAGE:
31
+ #
32
+ # NOTES:
33
+ #
34
+ # LICENSE:
35
+ # Copyright 2012 Sonian, Inc <chefs@sonian.net>
36
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
37
+ # for details.
38
+ #
39
+
40
+ require 'sensu-plugin/metric/cli'
41
+ require 'socket'
42
+
43
+ if RUBY_VERSION < '1.9.0'
44
+ require 'bigdecimal'
45
+
46
+ class Float
47
+ def round(val = 0)
48
+ BigDecimal.new(to_s).round(val).to_f
49
+ end
50
+ end
51
+ end
52
+
53
+ class LoadStat < Sensu::Plugin::Metric::CLI::Graphite
54
+ option :scheme,
55
+ description: 'Metric naming scheme, text to prepend to .$parent.$child',
56
+ long: '--scheme SCHEME',
57
+ default: "#{Socket.gethostname}"
58
+
59
+ option :per_core,
60
+ description: 'Divide load average results by cpu/core count',
61
+ short: '-p',
62
+ long: '--per-core',
63
+ boolean: true,
64
+ default: false
65
+
66
+ def number_of_cores
67
+ @cores ||= File.readlines('/proc/cpuinfo').count { |l| l =~ /^processor\s+:/ }
68
+ end
69
+
70
+ def run
71
+ result = `uptime`.gsub(',', '').split(' ')
72
+ result = result[-3..-1]
73
+
74
+ timestamp = Time.now.to_i
75
+ if config[:per_core]
76
+ metrics = {
77
+ load_avg: {
78
+ one: (result[0].to_f / number_of_cores).round(2),
79
+ five: (result[1].to_f / number_of_cores).round(2),
80
+ fifteen: (result[2].to_f / number_of_cores).round(2)
81
+ }
82
+ }
83
+ else
84
+ metrics = {
85
+ load_avg: {
86
+ one: result[0],
87
+ five: result[1],
88
+ fifteen: result[2]
89
+ }
90
+ }
91
+ end
92
+
93
+ metrics.each do |parent, children|
94
+ children.each do |child, value|
95
+ output [config[:scheme], parent, child].join('.'), value, timestamp
96
+ end
97
+ end
98
+ ok
99
+ end
100
+ end
@@ -0,0 +1,14 @@
1
+ require 'sensu-plugins-load-checks/version'
2
+
3
+ # Load the defaults
4
+
5
+ #
6
+ # Default class
7
+ #
8
+ module SensuPluginsLoadChecks
9
+ class << self
10
+ end
11
+
12
+ class << self
13
+ end
14
+ end
@@ -0,0 +1,28 @@
1
+ require 'json'
2
+
3
+ # encoding: utf-8
4
+ module SensuPluginsLoadChecks
5
+ # This defines the version of the gem
6
+ module Version
7
+ MAJOR = 0
8
+ MINOR = 0
9
+ PATCH = 1
10
+
11
+ VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
12
+
13
+ NAME = 'sensu-plugins-load-checks'
14
+ BANNER = "#{NAME} v%s"
15
+
16
+ module_function
17
+
18
+ def version
19
+ format(BANNER, VER_STRING)
20
+ end
21
+
22
+ def json_version
23
+ {
24
+ 'version' => VER_STRING
25
+ }.to_json
26
+ end
27
+ end
28
+ end
metadata ADDED
@@ -0,0 +1,218 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sensu-plugins-load-checks
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.1
5
+ platform: ruby
6
+ authors:
7
+ - Sensu-Plugins 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-05-22 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.4'
56
+ type: :development
57
+ prerelease: false
58
+ version_requirements: !ruby/object:Gem::Requirement
59
+ requirements:
60
+ - - "~>"
61
+ - !ruby/object:Gem::Version
62
+ version: '0.4'
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.30'
70
+ type: :development
71
+ prerelease: false
72
+ version_requirements: !ruby/object:Gem::Requirement
73
+ requirements:
74
+ - - "~>"
75
+ - !ruby/object:Gem::Version
76
+ version: '0.30'
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: Sensu plugins for load-checks
176
+ email: "<sensu-users@googlegroups.com>"
177
+ executables: []
178
+ extensions: []
179
+ extra_rdoc_files: []
180
+ files:
181
+ - CHANGELOG.md
182
+ - LICENSE
183
+ - README.md
184
+ - bin/check-load.rb
185
+ - bin/metrics-load.rb
186
+ - lib/sensu-plugins-load-checks.rb
187
+ - lib/sensu-plugins-load-checks/version.rb
188
+ homepage: https://github.com/sensu-plugins/sensu-plugins-load-checks
189
+ licenses:
190
+ - MIT
191
+ metadata:
192
+ maintainer: ''
193
+ development_status: active
194
+ production_status: unstable - testing reccomended
195
+ release_draft: 'false'
196
+ release_prerelease: 'false'
197
+ post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
198
+ in /etc/default/sensu
199
+ rdoc_options: []
200
+ require_paths:
201
+ - lib
202
+ required_ruby_version: !ruby/object:Gem::Requirement
203
+ requirements:
204
+ - - ">="
205
+ - !ruby/object:Gem::Version
206
+ version: 1.9.3
207
+ required_rubygems_version: !ruby/object:Gem::Requirement
208
+ requirements:
209
+ - - ">="
210
+ - !ruby/object:Gem::Version
211
+ version: '0'
212
+ requirements: []
213
+ rubyforge_project:
214
+ rubygems_version: 2.4.6
215
+ signing_key:
216
+ specification_version: 4
217
+ summary: Sensu plugins for load checks
218
+ test_files: []
metadata.gz.sig ADDED
@@ -0,0 +1 @@
1
+ [�}�OY�o 2�9{�`i��Z_|�"� ��������Y�2$@�ƪ2�]��T甈Zea����˿��{��b�iO�_:��h�wlçٝ�^&s�t��XE%�G�t��N��@Xpac@sM_m�b��;7��9��P:O̍ �>/~\��$�?q�U�z4m�,L����]�w �&��V-�e�%�Ȯ�j���ŧQ1kK�il�%顯:B����ԭ�3z~.����0`#"Sbu��ac"49���S�]<