sensu-plugins-chrony 0.0.7 → 0.0.8

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: 2defe7d9f370b45a0127afc920c1d11e36327928
4
- data.tar.gz: 8d4023c9d8c1b886684b5595628f37bfa4faea4d
3
+ metadata.gz: 9cac8096899909e07539a3cb15728b38b3825ac9
4
+ data.tar.gz: 37a753949e0a60708685275b7319b4474d20004d
5
5
  SHA512:
6
- metadata.gz: 73a41db5635c5f43ce5bb9a13d892f171365a5c48fd258de25c696a30f4bef95a861d2fb051f777db23b4305856cfbcb67019279b9b9cdecc5a98812a4621480
7
- data.tar.gz: b9def55d9374e66b3d2790acf1a450b1729a59d91cb342d7faac45bf5b47c9dfa38e68a35d9498b9f08dc5c9afa0dc5f2ab4d868793979f8be495abb6b79cb8b
6
+ metadata.gz: b34f1d7f6c39d2bcef2cb16273d4917e58062184829e5c71a2dbc3db123764fbf4d2f08de0b244775b26212feb83aaad6f54b90f22522ddfb0df91d998c7ecb5
7
+ data.tar.gz: 2f149cf30bbe0c876e139ba363806ec7a4c680e1cf6a8c4ba5bc5b8f285b96b0969a97b828ac93398c1e70b5b2da38a7f6f1b4907876170c841f53797fdf81ec
data/CHANGELOG.md CHANGED
@@ -5,6 +5,10 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
5
5
 
6
6
  ## Unreleased
7
7
 
8
+ ## [0.0.8] - 2016-04-04
9
+ ### Added
10
+ - adding metrics plugin (@vervas)
11
+
8
12
  ## [0.0.7] - 2016-01-18
9
13
  ### Added
10
14
  - fixing regex
data/README.md CHANGED
@@ -1,9 +1,24 @@
1
1
  # Sensu plugin for monitoring Chrony NTP
2
2
 
3
- A sensu plugin to monitor Chrony NTP.
3
+ A sensu plugin to monitor Chrony NTP. There is also a metrics plugin for collecting things like offset, delay etc.
4
4
 
5
5
  The plugin generates multiple OK/WARN/CRIT/UNKNOWN check events via the sensu client socket (https://sensuapp.org/docs/latest/clients#client-socket-input) so that you do not miss state changes when monitoring offset, stratum and status.
6
6
 
7
+ ## Installation
8
+
9
+ System-wide installation:
10
+
11
+ $ gem install sensu-plugins-chrony
12
+
13
+ Embedded sensu installation:
14
+
15
+ $ /opt/sensu/embedded/bin/gem install sensu-plugins-chrony
16
+
17
+ ## Files
18
+
19
+ * bin/check-chrony.rb
20
+ * bin/metrics-chrony.rb
21
+
7
22
  ## Usage
8
23
 
9
24
  The plugin accepts the following command line options:
@@ -0,0 +1,80 @@
1
+ #! /usr/bin/env ruby
2
+ # encoding: UTF-8
3
+ #
4
+ # metrics-chrony
5
+ #
6
+ # DESCRIPTION:
7
+ #
8
+ # OUTPUT:
9
+ # metric data
10
+ #
11
+ # PLATFORMS:
12
+ # Linux
13
+ #
14
+ # DEPENDENCIES:
15
+ # gem: sensu-plugin
16
+ # gem: socket
17
+ #
18
+ # USAGE:
19
+ #
20
+ # NOTES:
21
+ #
22
+
23
+ require 'sensu-plugin/metric/cli'
24
+ require 'socket'
25
+
26
+ class ChronyMetrics < Sensu::Plugin::Metric::CLI::Graphite
27
+ option :host,
28
+ description: 'Target host',
29
+ short: '-h HOST',
30
+ long: '--host HOST',
31
+ default: 'localhost'
32
+
33
+ option :scheme,
34
+ description: 'Metric naming scheme, text to prepend to metric',
35
+ short: '-s SCHEME',
36
+ long: '--scheme SCHEME',
37
+ default: Socket.gethostname
38
+
39
+ def run
40
+ # #YELLOW
41
+ unless config[:host] == 'localhost'
42
+ config[:scheme] = config[:host]
43
+ end
44
+
45
+ chronystats = get_chronystats(config[:host])
46
+ critical "Failed to get chronycstats from #{config[:host]}" if chronystats.empty?
47
+ metrics = {
48
+ chronystats: chronystats
49
+ }
50
+ metrics.each do |name, stats|
51
+ stats.each do |key, value|
52
+ output([config[:scheme], name, key].join('.'), value)
53
+ end
54
+ end
55
+ ok
56
+ end
57
+
58
+ def get_chronystats(host)
59
+ key_pattern = Regexp.compile(
60
+ [
61
+ "Stratum",
62
+ "Last offset",
63
+ "RMS offset",
64
+ "Frequency",
65
+ "Residual freq",
66
+ "Skew",
67
+ "Root delay",
68
+ "Root dispersion",
69
+ "Update interval"
70
+ ].join('|'))
71
+ num_val_pattern = /[\-\+]?[\d]+(\.[\d]+)?/
72
+ pattern = /^(#{key_pattern})\s*:\s*(#{num_val_pattern}).*$/
73
+
74
+ `chronyc tracking`.scan(pattern).reduce({}) do |hash, parsed|
75
+ key, val, fraction = parsed
76
+ hash[key] = fraction ? val.to_f : val.to_i
77
+ hash
78
+ end
79
+ end
80
+ end
@@ -2,7 +2,7 @@ module SensuPluginsChrony
2
2
  module Version
3
3
  MAJOR = 0
4
4
  MINOR = 0
5
- PATCH = 7
5
+ PATCH = 8
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-chrony
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.7
4
+ version: 0.0.8
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matteo Cerutti
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2016-01-18 00:00:00.000000000 Z
11
+ date: 2016-04-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -28,6 +28,7 @@ description: This plugin provides facilities for monitoring Chrony NTP
28
28
  email: "<matteo.cerutti@hotmail.co.uk>"
29
29
  executables:
30
30
  - check-chrony.rb
31
+ - metrics-chrony.rb
31
32
  extensions: []
32
33
  extra_rdoc_files: []
33
34
  files:
@@ -35,6 +36,7 @@ files:
35
36
  - LICENSE
36
37
  - README.md
37
38
  - bin/check-chrony.rb
39
+ - bin/metrics-chrony.rb
38
40
  - lib/sensu-plugins-chrony.rb
39
41
  - lib/sensu-plugins-chrony/version.rb
40
42
  homepage: https://github.com/m4ce/sensu-plugins-chrony