sensu-plugins-strongswan 2.0.0 → 2.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 +4 -4
- data/CHANGELOG.md +6 -1
- data/bin/check-strongswan-connection.rb +29 -8
- data/bin/metrics-strongswan-connection.rb +2 -3
- data/lib/sensu-plugins-strongswan/version.rb +1 -1
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6874e8d33f5a7e18a4cacee0a01b7dfb5429bb8655f3ce7fd1422cb3f699154d
|
4
|
+
data.tar.gz: f2ae3f153952899dfd0c1455acc8cdf0b19ecd0daaabbd5e2bc531a8221cade0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
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.
|
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
|
-
|
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
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
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 #{
|
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
|
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.
|
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-
|
11
|
+
date: 2018-03-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|