sensu-plugins-haproxy 1.0.0 → 1.1.0

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: 25e283eb95bb91b28de4bb02fcd2e3cdbc53f4f4
4
- data.tar.gz: 2efdac47dbea6af71901735fa908aeb350f76a21
3
+ metadata.gz: f4c4b50a4503825cb6fdb4b8901ee5e5cfa76c91
4
+ data.tar.gz: 861303a859aab6effdd97d0c9b33f73dd295ea57
5
5
  SHA512:
6
- metadata.gz: 43a8723a40b97903c908b8b5e8bede02baa6c40bd4b0706666c61189181a72370fe7e30d2f12cf27c94b2918edb10d9c2453d7292201603d5fc2ce1360ccc703
7
- data.tar.gz: 7547cf619ee498119d55ffaef3d1f5caaf9e337b47af0e6af62286e0ca28fc2b407c938ba9a6619e46ff44592aeaad8aa1deb423b41aa9d8b5e456d4171e8bb1
6
+ metadata.gz: 25a2e3536955ebc09009987cacaa7fb96d144807c98c9b02d5ef94a7aab51f20a272e4e6993d4c46a6b11cdaa7ec25d4e5f5bd15191dc3c1939f7058209b22f5
7
+ data.tar.gz: 739f898956be7f9abeb0bfb6784b688d65fa42f71fe18cc5b42c358311e6fb17298f4f51d35d4f06f57c8a21fd52a7babf0969f946490e7f2aa77b46599726be
data/CHANGELOG.md CHANGED
@@ -3,8 +3,14 @@ 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
+
6
7
  ## [Unreleased]
7
8
 
9
+ ## [1.1.0] - 2017-01-30
10
+ ### Added
11
+ - `check-haproxy.rb`: added fail on missing service flag (@obazoud)
12
+ - Consider backends in DRAIN status as UP and add flag to include backends in MAINT status (@modax)
13
+
8
14
  ## [1.0.0] - 2016-12-08
9
15
  ### Added
10
16
  - added names of the failed backends to check-haproxy.rb status
@@ -54,7 +60,8 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
54
60
  ### Added
55
61
  - initial release
56
62
 
57
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-haproxy/compare/1.0.0...HEAD
63
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-haproxy/compare/1.1.0...HEAD
64
+ [1.1.0]: https://github.com/sensu-plugins/sensu-plugins-haproxy/compare/1.0.0...1.1.0
58
65
  [1.0.0]: https://github.com/sensu-plugins/sensu-plugins-haproxy/compare/0.1.1...1.0.0
59
66
  [0.1.1]: https://github.com/sensu-plugins/sensu-plugins-haproxy/compare/0.1.0...0.1.1
60
67
  [0.1.0]: https://github.com/sensu-plugins/sensu-plugins-haproxy/compare/0.0.5...0.1.0
data/bin/check-haproxy.rb CHANGED
@@ -102,6 +102,10 @@ class CheckHAProxy < Sensu::Plugin::Check::CLI
102
102
  short: '-A',
103
103
  boolean: true,
104
104
  description: 'Check ALL Services, flag enables'
105
+ option :include_maint,
106
+ long: '--include-maint',
107
+ boolean: false,
108
+ description: 'Include servers in maintanance mode while checking (as DOWN)'
105
109
  option :missing_ok,
106
110
  short: '-m',
107
111
  boolean: true,
@@ -113,6 +117,17 @@ class CheckHAProxy < Sensu::Plugin::Check::CLI
113
117
  short: '-e',
114
118
  boolean: false,
115
119
  description: 'Whether service name specified with -s should be exact match or not'
120
+ option :missing_fail,
121
+ short: '-f',
122
+ boolean: false,
123
+ description: 'fail on missing service'
124
+
125
+ def service_up?(svc)
126
+ svc[:status].start_with?('UP') ||
127
+ svc[:status] == 'OPEN' ||
128
+ svc[:status] == 'no check' ||
129
+ svc[:status].start_with?('DRAIN')
130
+ end
116
131
 
117
132
  def run #rubocop:disable all
118
133
  if config[:service] || config[:all_services]
@@ -123,14 +138,16 @@ class CheckHAProxy < Sensu::Plugin::Check::CLI
123
138
 
124
139
  if services.empty?
125
140
  message "No services matching /#{config[:service]}/"
126
- if config[:missing_ok]
141
+ if config[:missing_fail]
142
+ critical
143
+ elsif config[:missing_ok]
127
144
  ok
128
145
  else
129
146
  warning
130
147
  end
131
148
  else
132
- percent_up = 100 * services.count { |svc| svc[:status] == 'UP' || svc[:status] == 'OPEN' || svc[:status] == 'no check' } / services.size
133
- failed_names = services.reject { |svc| svc[:status] == 'UP' || svc[:status] == 'OPEN' || svc[:status] == 'no check' }.map do |svc|
149
+ percent_up = 100 * services.count { |svc| service_up? svc } / services.size
150
+ failed_names = services.reject { |svc| service_up? svc }.map do |svc|
134
151
  "#{svc[:pxname]}/#{svc[:svname]}#{svc[:check_status].to_s.empty? ? '' : '[' + svc[:check_status] + ']'}"
135
152
  end
136
153
  critical_sessions = services.select { |svc| svc[:slim].to_i > 0 && (100 * svc[:scur].to_f / svc[:slim].to_f) > config[:session_crit_percent] }
@@ -212,6 +229,8 @@ class CheckHAProxy < Sensu::Plugin::Check::CLI
212
229
  end.reject do |svc| # rubocop: disable MultilineBlockChain
213
230
  %w(FRONTEND BACKEND).include?(svc[:svname])
214
231
  end
232
+ end.select do |svc|
233
+ config[:include_maint] || !svc[:status].start_with?('MAINT')
215
234
  end
216
235
  end
217
236
  end
@@ -180,7 +180,7 @@ class HAProxyMetrics < Sensu::Plugin::Metric::CLI::Graphite
180
180
 
181
181
  if line[1] != 'BACKEND' && !line[1].nil?
182
182
  up_by_backend[line[0]] ||= 0
183
- up_by_backend[line[0]] += (line[17] == 'UP') ? 1 : 0
183
+ up_by_backend[line[0]] += line[17].start_with?('UP') ? 1 : 0
184
184
  end
185
185
  end
186
186
 
@@ -1,7 +1,7 @@
1
1
  module SensuPluginsHAProxy
2
2
  module Version
3
3
  MAJOR = 1
4
- MINOR = 0
4
+ MINOR = 1
5
5
  PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-haproxy
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.0
4
+ version: 1.1.0
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-12-09 00:00:00.000000000 Z
11
+ date: 2017-01-31 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin