sensu-plugins-chrony 0.0.7 → 0.0.8
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 +4 -0
- data/README.md +16 -1
- data/bin/metrics-chrony.rb +80 -0
- data/lib/sensu-plugins-chrony/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 9cac8096899909e07539a3cb15728b38b3825ac9
|
4
|
+
data.tar.gz: 37a753949e0a60708685275b7319b4474d20004d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b34f1d7f6c39d2bcef2cb16273d4917e58062184829e5c71a2dbc3db123764fbf4d2f08de0b244775b26212feb83aaad6f54b90f22522ddfb0df91d998c7ecb5
|
7
|
+
data.tar.gz: 2f149cf30bbe0c876e139ba363806ec7a4c680e1cf6a8c4ba5bc5b8f285b96b0969a97b828ac93398c1e70b5b2da38a7f6f1b4907876170c841f53797fdf81ec
|
data/CHANGELOG.md
CHANGED
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
|
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.
|
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-
|
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
|