sensu-plugins-openbsd 1.0.4 → 1.0.5

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
  SHA256:
3
- metadata.gz: bd40cb0d9456a56d3c2c579ccf59705c18ee8b97502601b24b024b78e4285b2d
4
- data.tar.gz: 1c26b0107bdbfcfe601095896404c9c8625022c51037f708b03141789908ba07
3
+ metadata.gz: 109efa3bb9b2d1773a2cd0cd7728363cdf6c1d9420dd0bb67978afdd59f7c12c
4
+ data.tar.gz: c87f1ba88565e60e0bdf305c745b9b19ef3895d223d84463b1ea9a5133b8748b
5
5
  SHA512:
6
- metadata.gz: d13f4a18db2e1118922b7389c18feb2e85b837bb86046253c533733bfaa0e903ce94c527e2f138a287a460db34bb1ee5f24ef29df4e68693d5c2b21c30ded67f
7
- data.tar.gz: bcb308dc897d9b1375bd435db1bca19936628ee4fe2ff93f731a8cf0842e596b0c21b8790241c0c086f9b5b4ab3231dbf292733d7b45f3163141f3f42a440eca
6
+ metadata.gz: 83c9db762ca15e1fb6c0c96bd97232d42d0ea92f38c80c0b2d477757815b4f9f8e57163fa27591d61f6ad21a1e630474678708cf01f0200fb99ffdf0d22172d3
7
+ data.tar.gz: f227d5db0d317532ccf8b1b6c35969935820c76c6e8e7bdd574a814114d686e221b64152efc9379594451820458c63d1825d7fb0001a6ce29dc31f4a72f5f957
data/README.md CHANGED
@@ -3,6 +3,13 @@
3
3
  [![Build Status](https://travis-ci.org/Sigterm-no/sensu-plugins-openbsd.svg?branch=master)](https://travis-ci.org/Sigterm-no/sensu-plugins-openbsd)
4
4
  [![Gem Version](https://badge.fury.io/rb/sensu-plugins-openbsd.svg)](https://badge.fury.io/rb/sensu-plugins-openbsd)
5
5
 
6
+ ## Checks
7
+
8
+ * `bin/check-bgpd.rb` - A check for OpenBGPd peers health
9
+ * `bin/check-cmd.rb` - A check that runs a choosen command and can regex it's output
10
+ * `bin/check-ntp.rb` - A check that queries ntpctl
11
+ * `bin/check-process.rb` - A check to find running processes
12
+
6
13
  ## Installation
7
14
 
8
15
  [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
data/bin/check-bgpd.rb ADDED
@@ -0,0 +1,53 @@
1
+ #!/usr/bin/env ruby
2
+ #
3
+ # check-bgpd
4
+ #
5
+ # DESCRIPTION:
6
+ #
7
+ # OUTPUT:
8
+ # plain text
9
+ #
10
+ # PLATFORMS:
11
+ # OpenBSD
12
+ #
13
+ # DEPENDENCIES:
14
+ # gem: sensu-plugin
15
+
16
+ require 'sensu-plugin/check/cli'
17
+
18
+ class CheckOpenBGPd < Sensu::Plugin::Check::CLI
19
+ option :warn,
20
+ short: '-w WARN',
21
+ description: 'Percetage of peers in a connecting/not-working state before warning',
22
+ proc: proc(&:to_f),
23
+ default: 50
24
+
25
+ option :crit,
26
+ short: '-c CRIT',
27
+ description: 'Percetage of peers in a connecting/not-working state before critical',
28
+ proc: proc(&:to_f),
29
+ default: 90
30
+
31
+ def run
32
+ begin
33
+ num_peers = `bgpctl show | egrep -v "Connect$|Active$" | tail -n +2 | wc -l`.strip.to_i
34
+ num_issue_peers = `bgpctl show | egrep '(Active|Connect)$' | wc -l`.strip.to_i
35
+ num_fib_routes = `bgpctl show fib | tail -n +6 | wc -l`.strip.to_i
36
+ num_rib_routes = `bgpctl show rib | tail -n +7 | wc -l`.strip.to_i
37
+
38
+ total_peers = num_peers + num_issue_peers
39
+ peers_success_ratio = ((num_peers.to_f / total_peers.to_f) * 100).truncate(2)
40
+
41
+ message = "OpenBGPd running with #{total_peers} peers, "
42
+ message << "#{peers_success_ratio}% (#{num_issue_peers}) in a connecting or errored state, "
43
+ message << "#{num_fib_routes}. Knows FIB routes and #{num_rib_routes} RIB routes."
44
+ rescue StandardError => e
45
+ unknown "OpenBGPd command Failed: #{e}"
46
+ end
47
+
48
+ critical message if num_peers.zero?
49
+ critical message if peers_success_ratio >= config[:crit] || peers_success_ratio <= -config[:crit]
50
+ warning message if peers_success_ratio >= config[:warn] || peers_success_ratio <= -config[:warn]
51
+ ok message
52
+ end
53
+ end
data/bin/check-ntp.rb CHANGED
@@ -76,7 +76,7 @@ class CheckNTP < Sensu::Plugin::Check::CLI
76
76
  # Offset
77
77
  offset = output[/offset (...), clock/, 1].strip
78
78
  rescue StandardError => e
79
- unknown 'NTP command Failed: #{e}'
79
+ unknown "NTP command Failed: #{e}"
80
80
  end
81
81
 
82
82
  if output.include? unsynced
@@ -2,7 +2,7 @@ module SensuPluginsOpenBSD
2
2
  module Version
3
3
  MAJOR = 1
4
4
  MINOR = 0
5
- PATCH = 4
5
+ PATCH = 5
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-openbsd
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.0.4
4
+ version: 1.0.5
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors
@@ -170,12 +170,14 @@ executables:
170
170
  - check-ntp.rb
171
171
  - check-process.rb
172
172
  - check-cmd.rb
173
+ - check-bgpd.rb
173
174
  extensions: []
174
175
  extra_rdoc_files: []
175
176
  files:
176
177
  - CHANGELOG.md
177
178
  - LICENSE
178
179
  - README.md
180
+ - bin/check-bgpd.rb
179
181
  - bin/check-cmd.rb
180
182
  - bin/check-ntp.rb
181
183
  - bin/check-process.rb