sensu-plugins-nrpe 0.0.1 → 0.0.2

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: 4cacc759dd4190c30893d69efba9887f6f3d9ada
4
- data.tar.gz: 9c91ef4a04036a1682c976180928d82d17582403
3
+ metadata.gz: 3e47916432d40967d18de41b63599144b938009e
4
+ data.tar.gz: 2694ffff657bea897da2ddd51a16d3b6540b2a1e
5
5
  SHA512:
6
- metadata.gz: 1e22001e13007ad2983debee1e15a333c563a65c319f59259d26354f5a79f87fd3dfce2a1a1dab72651bdca9a90cb0893678c3ab4f0f90bfc7180095f6262eec
7
- data.tar.gz: cd6dcd4b7c3bd4a59729a97df65570fc541a877371de440768af6ce4931891bf09094c4453b7b07673305a51e7d006e2c972b2782096557c8aec2dff1ab8f190
6
+ metadata.gz: 3c99b8d6f177b466493d985bd05863678a3cd0301ba6fa5dc132ef363df16ee96095a3c7af33b4a8989b5b33204561b1e638ae9ce0ed32e31ed062dbfbf2effe
7
+ data.tar.gz: bd2a1df7e32a63ae356be8a6b95831b0259e29c5c2cacd820af9b3673aff299e74ee9bae4107943c422918851208d0a6ee8085fee8ce71778a6776a97c4ba500
data/CHANGELOG.md CHANGED
@@ -5,6 +5,15 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
5
5
 
6
6
  ## Unreleased
7
7
 
8
+ ## [0.0.2] - 2016-08-11
9
+
10
+ ### Fixed
11
+ - simplify check-nrpe.rb output due to variances in different nagios plugin check results
12
+
13
+ ### Changed
14
+ - move regex comment from code to header in check-nrpe.rb and metrics-nrpe.rb
15
+ - drop obsolete comparison option
16
+
8
17
  ## 0.0.1 - 2016-08-03
9
18
 
10
19
  ### Added
data/bin/check-nrpe.rb CHANGED
@@ -13,6 +13,9 @@
13
13
  # check-nrpe -H host -c check_plugin -a 'plugin args'
14
14
  # check-nrpe -H host -c check_plugin -a 'plugin args' -m "(P|p)attern to match\.?"
15
15
  #
16
+ # NOTES:
17
+ # regex from https://github.com/naparuba/shinken/blob/master/shinken/misc/perfdata.py
18
+ #
16
19
  # LICENSE:
17
20
  # Copyright (c) 2016 Scott Saunders <scosist@gmail.com>
18
21
  # Based on check-snmp.rb by Deepak Mohan Das <deepakmdass88@gmail.com>
@@ -55,11 +58,6 @@ class CheckNRPE < Sensu::Plugin::Check::CLI
55
58
  short: '-m match',
56
59
  description: 'Regex pattern to match against returned buffer'
57
60
 
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
61
  def run
64
62
  begin
65
63
  request = Nrpeclient::CheckNrpe.new({:host=> "#{config[:host]}", :port=> "#{config[:port]}", :ssl=> config[:ssl]})
@@ -69,11 +67,6 @@ class CheckNRPE < Sensu::Plugin::Check::CLI
69
67
  rescue => e
70
68
  unknown "An unknown error occured: #{e.inspect}"
71
69
  end
72
- operators = { 'le' => :<=, 'ge' => :>= }
73
- symbol = operators[config[:comparison]]
74
- criticals = []
75
- warnings = []
76
- okays = []
77
70
 
78
71
  if config[:match]
79
72
  if response.buffer.to_s =~ /#{config[:match]}/
@@ -82,24 +75,17 @@ class CheckNRPE < Sensu::Plugin::Check::CLI
82
75
  critical "Buffer: #{response.buffer} failed to match Pattern: #{config[:match]}"
83
76
  end
84
77
  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(' ')
78
+ response_captures = response.buffer.scan(/[A-Z ]*?([A-Z]+)\s?[:-]{1}\s(.*)/)
79
+ response_status = response_captures[0][0].downcase
80
+ response_data = response_captures[0][1]
81
+ case response_status
82
+ when "critical"
83
+ critical response_data
84
+ when "warning"
85
+ warning response_data
86
+ else
87
+ ok response_data
101
88
  end
102
- ok okays.join(' ')
103
89
  end
104
90
  end
105
91
  end
data/bin/metrics-nrpe.rb CHANGED
@@ -11,6 +11,9 @@
11
11
  # USAGE:
12
12
  # check-nrpe -H host -c check_plugin -a 'plugin args' -p prefix -s suffix
13
13
  #
14
+ # NOTES:
15
+ # regex from https://github.com/naparuba/shinken/blob/master/shinken/misc/perfdata.py
16
+ #
14
17
  # LICENSE:
15
18
  # Copyright (c) 2016 Scott Saunders <scosist@gmail.com>
16
19
  # Based on metrics-snmp.rb by Double Negative Limited
@@ -74,7 +77,6 @@ class NRPEGraphite < Sensu::Plugin::Metric::CLI::Graphite
74
77
  end
75
78
  config[:host] = config[:host].gsub('.', '_') if config[:graphite]
76
79
  perfdata = response.buffer.split('|')[1].scan(/([^=]+=\S+)/)
77
- # regex from https://github.com/naparuba/shinken/blob/master/shinken/misc/perfdata.py
78
80
  perfdata.each do |pd|
79
81
  metric = /^([^=]+)=([\d\.\-\+eE]+)([\w\/%]*);?([\d\.\-\+eE:~@]+)?;?([\d\.\-\+eE:~@]+)?;?([\d\.\-\+eE]+)?;?([\d\.\-\+eE]+)?;?\s*/.match(pd[0]) # rubocop:disable LineLength
80
82
  if config[:prefix]
@@ -2,7 +2,7 @@ module SensuPluginsNrpe
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- PATCH = 1
5
+ PATCH = 2
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-nrpe
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.1
4
+ version: 0.0.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-08-03 00:00:00.000000000 Z
11
+ date: 2016-08-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin