sensu-plugins-nrpe 0.0.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 4cacc759dd4190c30893d69efba9887f6f3d9ada
4
+ data.tar.gz: 9c91ef4a04036a1682c976180928d82d17582403
5
+ SHA512:
6
+ metadata.gz: 1e22001e13007ad2983debee1e15a333c563a65c319f59259d26354f5a79f87fd3dfce2a1a1dab72651bdca9a90cb0893678c3ab4f0f90bfc7180095f6262eec
7
+ data.tar.gz: cd6dcd4b7c3bd4a59729a97df65570fc541a877371de440768af6ce4931891bf09094c4453b7b07673305a51e7d006e2c972b2782096557c8aec2dff1ab8f190
data/CHANGELOG.md ADDED
@@ -0,0 +1,11 @@
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
7
+
8
+ ## 0.0.1 - 2016-08-03
9
+
10
+ ### Added
11
+ - initial release
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,30 @@
1
+ ## Sensu-Plugins-NRPE
2
+
3
+ [![Build Status](https://travis-ci.org/sensu-plugins/sensu-plugins-nrpe.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-nrpe)
4
+ [![Gem Version](https://badge.fury.io/rb/sensu-plugins-nrpe.svg)](http://badge.fury.io/rb/sensu-plugins-nrpe)
5
+ [![Code Climate](https://codeclimate.com/github/sensu-plugins/sensu-plugins-nrpe/badges/gpa.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-nrpe)
6
+ [![Test Coverage](https://codeclimate.com/github/sensu-plugins/sensu-plugins-nrpe/badges/coverage.svg)](https://codeclimate.com/github/sensu-plugins/sensu-plugins-nrpe)
7
+ [![Dependency Status](https://gemnasium.com/sensu-plugins/sensu-plugins-nrpe.svg)](https://gemnasium.com/sensu-plugins/sensu-plugins-nrpe)
8
+ [![Codeship Status for sensu-plugins/sensu-plugins-nrpe](https://codeship.com/projects/c7145640-e8a4-0132-3bde-62885e5c211b/status?branch=master)](https://codeship.com/projects/82852)
9
+
10
+ ## Functionality
11
+
12
+ **check-nrpe**
13
+
14
+ Check NRPE plugin data based on the nrpeclient gem.
15
+
16
+ **metrics-nrpe**
17
+
18
+ Output graphite metrics for NRPE plugin data based on the nrpeclient gem.
19
+
20
+ ## Files
21
+ * bin/check-nrpe.rb
22
+ * bin/metrics-nrpe.rb
23
+
24
+ ## Usage
25
+
26
+ ## Installation
27
+
28
+ [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
29
+
30
+ ## Notes
data/bin/check-nrpe.rb ADDED
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env ruby
2
+ # Check NRPE
3
+ # ===
4
+ #
5
+ # This is a simple NRPE check script for Sensu, We need to supply details like
6
+ # Server, port, NRPE plugin, and plugin arguments
7
+ #
8
+ # DEPENDENCIES:
9
+ # gem: sensu-plugin
10
+ # gem: nrpeclient
11
+ #
12
+ # USAGE:
13
+ # check-nrpe -H host -c check_plugin -a 'plugin args'
14
+ # check-nrpe -H host -c check_plugin -a 'plugin args' -m "(P|p)attern to match\.?"
15
+ #
16
+ # LICENSE:
17
+ # Copyright (c) 2016 Scott Saunders <scosist@gmail.com>
18
+ # Based on check-snmp.rb by Deepak Mohan Das <deepakmdass88@gmail.com>
19
+ #
20
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
21
+ # for details.
22
+
23
+ require 'sensu-plugin/check/cli'
24
+ require 'nrpeclient'
25
+
26
+ # Class that checks the return from querying NRPE.
27
+ class CheckNRPE < Sensu::Plugin::Check::CLI
28
+ option :host,
29
+ short: '-H host',
30
+ boolean: true,
31
+ default: '127.0.0.1',
32
+ required: true
33
+
34
+ option :check,
35
+ short: '-c check_plugin',
36
+ boolean: true,
37
+ default: '',
38
+ required: true
39
+
40
+ option :args,
41
+ short: '-a args',
42
+ default: ''
43
+
44
+ option :port,
45
+ short: '-P port',
46
+ description: 'port to use (default:5666)',
47
+ default: '5666'
48
+
49
+ option :ssl,
50
+ short: '-S use ssl',
51
+ description: 'enable ssl (default:true)',
52
+ default: true
53
+
54
+ option :match,
55
+ short: '-m match',
56
+ description: 'Regex pattern to match against returned buffer'
57
+
58
+ option :comparison,
59
+ short: '-o comparison operator',
60
+ description: 'Operator used to compare data with warning/critial values. Can be set to "le" (<=), "ge" (>=).',
61
+ default: 'ge'
62
+
63
+ def run
64
+ begin
65
+ request = Nrpeclient::CheckNrpe.new({:host=> "#{config[:host]}", :port=> "#{config[:port]}", :ssl=> config[:ssl]})
66
+ response = request.send_command("#{config[:check]}", "#{config[:args]}")
67
+ rescue Errno::ETIMEDOUT
68
+ unknown "#{config[:host]} not responding"
69
+ rescue => e
70
+ unknown "An unknown error occured: #{e.inspect}"
71
+ end
72
+ operators = { 'le' => :<=, 'ge' => :>= }
73
+ symbol = operators[config[:comparison]]
74
+ criticals = []
75
+ warnings = []
76
+ okays = []
77
+
78
+ if config[:match]
79
+ if response.buffer.to_s =~ /#{config[:match]}/
80
+ ok
81
+ else
82
+ critical "Buffer: #{response.buffer} failed to match Pattern: #{config[:match]}"
83
+ end
84
+ else
85
+ perfdata = response.buffer.split('|')[1].scan(/([^=]+=\S+)/)
86
+ # regex from https://github.com/naparuba/shinken/blob/master/shinken/misc/perfdata.py
87
+ perfdata.each do |pd|
88
+ metric = /^([^=]+)=([\d\.\-\+eE]+)([\w\/%]*);?([\d\.\-\+eE:~@]+)?;?([\d\.\-\+eE:~@]+)?;?([\d\.\-\+eE]+)?;?([\d\.\-\+eE]+)?;?\s*/.match(pd[0]) # rubocop:disable LineLength
89
+ criticals << "Critical state detected for #{config[:check]} on #{metric[1].strip}, value: #{metric[2].to_f}#{metric[3].strip}." if "#{metric[2]}".to_f.send(symbol, "#{metric[5]}".to_f)
90
+ # #YELLOW
91
+ warnings << "Warning state detected for #{config[:check]} on #{metric[1].strip}, value: #{metric[2].to_f}#{metric[3].strip}." if ("#{metric[2]}".to_f.send(symbol, "#{metric[4]}".to_f)) && !("#{metric[2]}".to_f.send(symbol, "#{metric[5]}".to_f)) # rubocop:disable LineLength
92
+ unless "#{metric[2]}".to_f.send(symbol, "#{metric[4]}".to_f)
93
+ okays << "All is well for #{config[:check]} on #{metric[1].strip}, value: #{metric[2].to_f}#{metric[3].strip}."
94
+ end
95
+ end
96
+ unless criticals.empty?
97
+ critical criticals.join(' ')
98
+ end
99
+ unless warnings.empty?
100
+ warning warnings.join(' ')
101
+ end
102
+ ok okays.join(' ')
103
+ end
104
+ end
105
+ end
@@ -0,0 +1,88 @@
1
+ #!/usr/bin/env ruby
2
+ # NRPE Metrics
3
+ # ===
4
+ #
5
+ # This is a simple script to collect metrics from an NRPE plugin
6
+ #
7
+ # DEPENDENCIES:
8
+ # gem: sensu-plugin
9
+ # gem: nrpeclient
10
+ #
11
+ # USAGE:
12
+ # check-nrpe -H host -c check_plugin -a 'plugin args' -p prefix -s suffix
13
+ #
14
+ # LICENSE:
15
+ # Copyright (c) 2016 Scott Saunders <scosist@gmail.com>
16
+ # Based on metrics-snmp.rb by Double Negative Limited
17
+ #
18
+ # Released under the same terms as Sensu (the MIT license); see LICENSE
19
+ # for details.
20
+
21
+ require 'sensu-plugin/metric/cli'
22
+ require 'nrpeclient'
23
+
24
+ # Class that collects and outputs NRPE metrics in graphite format
25
+ class NRPEGraphite < Sensu::Plugin::Metric::CLI::Graphite
26
+ option :host,
27
+ short: '-H host',
28
+ boolean: true,
29
+ default: '127.0.0.1',
30
+ required: true
31
+
32
+ option :check,
33
+ short: '-c check_plugin',
34
+ boolean: true,
35
+ default: '',
36
+ required: true
37
+
38
+ option :args,
39
+ short: '-a args',
40
+ default: ''
41
+
42
+ option :prefix,
43
+ short: '-p prefix',
44
+ description: 'prefix to attach to graphite path'
45
+
46
+ option :suffix,
47
+ short: '-s suffix',
48
+ description: 'suffix to attach to graphite path',
49
+ required: true
50
+
51
+ option :port,
52
+ short: '-P port',
53
+ description: 'port to use (default:5666)',
54
+ default: '5666'
55
+
56
+ option :ssl,
57
+ short: '-S use ssl',
58
+ description: 'enable ssl (default:true)',
59
+ default: true
60
+
61
+ option :graphite,
62
+ short: '-g',
63
+ description: 'Replace dots with underscores in hostname',
64
+ boolean: true
65
+
66
+ def run
67
+ begin
68
+ request = Nrpeclient::CheckNrpe.new({:host=> "#{config[:host]}", :port=> "#{config[:port]}", :ssl=> config[:ssl]})
69
+ response = request.send_command("#{config[:check]}", "#{config[:args]}")
70
+ rescue Errno::ETIMEDOUT
71
+ unknown "#{config[:host]} not responding"
72
+ rescue => e
73
+ unknown "An unknown error occured: #{e.inspect}"
74
+ end
75
+ config[:host] = config[:host].gsub('.', '_') if config[:graphite]
76
+ perfdata = response.buffer.split('|')[1].scan(/([^=]+=\S+)/)
77
+ # regex from https://github.com/naparuba/shinken/blob/master/shinken/misc/perfdata.py
78
+ perfdata.each do |pd|
79
+ metric = /^([^=]+)=([\d\.\-\+eE]+)([\w\/%]*);?([\d\.\-\+eE:~@]+)?;?([\d\.\-\+eE:~@]+)?;?([\d\.\-\+eE]+)?;?([\d\.\-\+eE]+)?;?\s*/.match(pd[0]) # rubocop:disable LineLength
80
+ if config[:prefix]
81
+ output "#{config[:prefix]}.#{config[:host]}.#{config[:suffix]}.#{metric[1].strip}", metric[2].to_f
82
+ else
83
+ output "#{config[:host]}.#{config[:suffix]}.#{metric[1].strip}", metric[2].to_f
84
+ end
85
+ end
86
+ ok
87
+ end
88
+ end
@@ -0,0 +1 @@
1
+ require 'sensu-plugins-nrpe/version'
@@ -0,0 +1,9 @@
1
+ module SensuPluginsNrpe
2
+ module Version
3
+ MAJOR = 0
4
+ MINOR = 0
5
+ PATCH = 1
6
+
7
+ VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
+ end
9
+ end
metadata ADDED
@@ -0,0 +1,215 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sensu-plugins-nrpe
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
+ date: 2016-08-03 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sensu-plugin
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: nrpeclient
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.3
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.1.3
41
+ - !ruby/object:Gem::Dependency
42
+ name: codeclimate-test-reporter
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '0.4'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '0.4'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rubocop
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: 0.40.0
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: 0.40.0
69
+ - !ruby/object:Gem::Dependency
70
+ name: rspec
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '3.1'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '3.1'
83
+ - !ruby/object:Gem::Dependency
84
+ name: bundler
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '1.7'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '1.7'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '10.0'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '10.0'
111
+ - !ruby/object:Gem::Dependency
112
+ name: github-markup
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '1.3'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '1.3'
125
+ - !ruby/object:Gem::Dependency
126
+ name: redcarpet
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: '3.2'
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: '3.2'
139
+ - !ruby/object:Gem::Dependency
140
+ name: yard
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '0.8'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '0.8'
153
+ - !ruby/object:Gem::Dependency
154
+ name: pry
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.10'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.10'
167
+ description: |-
168
+ This plugin provides native NRPE instrumentation
169
+ for monitoring and metrics collection, based on
170
+ the nrpeclient gem.
171
+ email: "<sensu-users@googlegroups.com>"
172
+ executables:
173
+ - check-nrpe.rb
174
+ - metrics-nrpe.rb
175
+ extensions: []
176
+ extra_rdoc_files: []
177
+ files:
178
+ - CHANGELOG.md
179
+ - LICENSE
180
+ - README.md
181
+ - bin/check-nrpe.rb
182
+ - bin/metrics-nrpe.rb
183
+ - lib/sensu-plugins-nrpe.rb
184
+ - lib/sensu-plugins-nrpe/version.rb
185
+ homepage: https://github.com/sensu-plugins/sensu-plugins-nrpe
186
+ licenses:
187
+ - MIT
188
+ metadata:
189
+ maintainer: sensu-plugin
190
+ development_status: active
191
+ production_status: unstable - testing recommended
192
+ release_draft: 'false'
193
+ release_prerelease: 'false'
194
+ post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
195
+ in /etc/default/sensu
196
+ rdoc_options: []
197
+ require_paths:
198
+ - lib
199
+ required_ruby_version: !ruby/object:Gem::Requirement
200
+ requirements:
201
+ - - ">="
202
+ - !ruby/object:Gem::Version
203
+ version: 1.9.3
204
+ required_rubygems_version: !ruby/object:Gem::Requirement
205
+ requirements:
206
+ - - ">="
207
+ - !ruby/object:Gem::Version
208
+ version: '0'
209
+ requirements: []
210
+ rubyforge_project:
211
+ rubygems_version: 2.2.2
212
+ signing_key:
213
+ specification_version: 4
214
+ summary: Sensu plugins for NRPE
215
+ test_files: []