sensu-plugins-strongswan 2.0.0 → 2.1.0

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
  SHA256:
3
- metadata.gz: fb9cfc67e98f78796ff984105ea1c6d1ecfc56a2f4d4e54f15d5e787e41b2341
4
- data.tar.gz: dbe509551b2d89bee847ab44df19fb294a96f3480f925aaba327b31782449952
3
+ metadata.gz: 6874e8d33f5a7e18a4cacee0a01b7dfb5429bb8655f3ce7fd1422cb3f699154d
4
+ data.tar.gz: f2ae3f153952899dfd0c1455acc8cdf0b19ecd0daaabbd5e2bc531a8221cade0
5
5
  SHA512:
6
- metadata.gz: bd0a02e6ed04ef147bde40d780e1624adc6b8cd463d388797f8ad4097fd1768cf2d14977da523f9e174b731005d85a0db9ef4950253185ead459b90115dd2560
7
- data.tar.gz: 59940dd6fd07b3a199645134aba922cdca164e242f33e086f77f0a311e8be610006e727dd9a761ec38ee64b3b608240b96077f1d378e3ed22f9d8a4763dfd885
6
+ metadata.gz: 8d9959de1a83620f7fe43400886c7be11e0ca7250d04095861173c9e270883f377087068c106c6b65af35fe28db07e0cb96f2f9f6da9243ce74f5569c9d0e1f1
7
+ data.tar.gz: 6d1ea2931b01f1136154cb20ff9c3da158802de5e1f6b6e8712b02f8481ea2bac4292107acabcf490b03957e37b1c75591b1e57b27d5f8d1c48c2e274858d019
data/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
5
5
 
6
6
  ## [Unreleased]
7
7
 
8
+ ## [2.1.0] - 2018-03-17
9
+ ### Added
10
+ - Added ability to check all existing connection and get metrics from all connections (@yuri-zubov)
11
+
8
12
  ## [2.0.0] - 2018-03-07
9
13
  ### Breaking Changes
10
14
  - Dropping ruby `< 2.3` support (@yuri-zubov)
@@ -50,7 +54,8 @@ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins
50
54
  ### Added
51
55
  - add check-strongswan.rb and metrics-strongswan.rb plugins
52
56
 
53
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-strongswan/compare/2.0.0...HEAD
57
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-strongswan/compare/2.1.0...HEAD
58
+ [2.1.0]: https://github.com/sensu-plugins/sensu-plugins-strongswan/compare/2.0.0...2.1.0
54
59
  [2.0.0]: https://github.com/sensu-plugins/sensu-plugins-strongswan/compare/1.2.0...2.0.0
55
60
  [1.2.0]: https://github.com/sensu-plugins/sensu-plugins-strongswan/compare/1.1.0...1.2.0
56
61
  [1.1.0]: https://github.com/sensu-plugins/sensu-plugins-strongswan/compare/1.0.0...1.1.0
@@ -27,23 +27,44 @@
27
27
  #
28
28
 
29
29
  require 'sensu-plugin/check/cli'
30
+ require 'open3'
31
+ require 'set'
30
32
 
31
33
  # check strongswan connection status
32
34
  class CheckStrongswanConnection < Sensu::Plugin::Check::CLI
33
35
  option :connection,
34
36
  description: 'Connection name to check',
35
37
  short: '-c NAME',
36
- long: '--connection NAME',
37
- required: true
38
+ long: '--connection NAME'
39
+
40
+ def run_ipsec_statusall
41
+ stdout, stderr, result = Open3.capture3("ipsec statusall #{config[:connection]}")
42
+ unknown stderr unless result.success?
43
+ stdout
44
+ end
38
45
 
39
46
  def run
40
- output = `ipsec statusall #{config[:connection]}`
41
- if output.include?('INSTALLED, TUNNEL,')
42
- ok "the connection #{config[:connection]} is up"
43
- elsif !output.include?(config[:connection])
44
- warning "the connection #{config[:connection]} doesn't exist"
47
+ ipsec_status = run_ipsec_statusall
48
+ connection_names = Set.new
49
+ established_connection_name = Set.new
50
+ ipsec_status.each_line do |line|
51
+ if line.match(/^Connections:/) .. line.match(/^Security Associations/)
52
+ result = line.match(/^(?<name>(.*)):.*local/)
53
+ connection_names << result[:name] if result
54
+ end
55
+
56
+ if line.match(/^Security Associations/) .. false
57
+ result = line.match(/^(?<name>(.*))\{.*INSTALLED, TUNNEL,/)
58
+ established_connection_name << result[:name] if result
59
+ end
60
+ end
61
+
62
+ if connection_names.empty?
63
+ warning "the connection(s) #{config[:connection]} doesn't exist"
64
+ elsif connection_names == established_connection_name
65
+ ok "the connection(s) #{connection_names.to_a.join(', ')} is up"
45
66
  else
46
- critical "the connection #{config[:connection]} is down"
67
+ critical "the connection #{(connection_names - established_connection_name).to_a.join(', ')} is down"
47
68
  end
48
69
  end
49
70
  end
@@ -41,8 +41,7 @@ class MetricsStrongswanStrongswanConnection < Sensu::Plugin::Metric::CLI::Graphi
41
41
  option :connection,
42
42
  description: 'Connection name to check',
43
43
  short: '-c NAME',
44
- long: '--connection NAME',
45
- required: true
44
+ long: '--connection NAME'
46
45
 
47
46
  def run_ipsec_statusall
48
47
  stdout, result = Open3.capture2("ipsec statusall #{config[:connection]}")
@@ -55,7 +54,7 @@ class MetricsStrongswanStrongswanConnection < Sensu::Plugin::Metric::CLI::Graphi
55
54
 
56
55
  found = false
57
56
  ipsec_status.each_line do |line|
58
- result = line.match(/(?<name>.*)\{.*(?<bytes_i>\d+)\ bytes_i.*\ (?<bytes_o>\d+)\ bytes_o/)
57
+ result = line.match(/(?<name>.*)\{.* (?<bytes_i>\d+)\ bytes_i.*\ (?<bytes_o>\d+)\ bytes_o/)
59
58
  next unless result
60
59
 
61
60
  found = true
@@ -1,7 +1,7 @@
1
1
  module SensuPluginsStrongswan
2
2
  module Version
3
3
  MAJOR = 2
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-strongswan
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.0.0
4
+ version: 2.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: 2018-03-08 00:00:00.000000000 Z
11
+ date: 2018-03-17 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin