sensu-plugins-chrony 0.0.10 → 1.0.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 +32 -1
- data/README.md +8 -0
- data/bin/check-chrony.rb +71 -51
- data/bin/metrics-chrony.rb +3 -5
- data/lib/sensu-plugins-chrony/version.rb +2 -2
- metadata +111 -10
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 5c52e1cf5df506dd5cfb30502ba190b8c97426fc
|
4
|
+
data.tar.gz: 2393f9eb54485903e6509feaa3a64ba5dd08501b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: b4db8201cbe5ee253c874ba5b7b68a660877d92a9a11f65bfa4980f872365a445128a1e3fd64af1ffb9e912c49db2135b9e72b8802a5efbc11d5b2a7192c2274
|
7
|
+
data.tar.gz: a23e33888e4c5f321f7784911fa161db0e08688aa2e5b4de2786452ab564f104ea7391494b8bda70f872322632016903c6b95a8d3ca5b87d09ca975e414e7746
|
data/CHANGELOG.md
CHANGED
@@ -1,7 +1,25 @@
|
|
1
1
|
# Change Log
|
2
2
|
This project adheres to [Semantic Versioning](http://semver.org/).
|
3
3
|
|
4
|
-
This CHANGELOG follows the format listed
|
4
|
+
This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md)
|
5
|
+
|
6
|
+
## [Unreleased]
|
7
|
+
|
8
|
+
## [1.0.0] - 2018-01-04
|
9
|
+
### Breaking Change
|
10
|
+
- remove ruby < 2.0 support (@majormoses)
|
11
|
+
- require `sensu-plugin` 2.0 (@majormoses)
|
12
|
+
|
13
|
+
### Added
|
14
|
+
- github templates (@majormoses)
|
15
|
+
- links to changelog guidelines (@majormoses)
|
16
|
+
- badges to README (@majormoses)
|
17
|
+
- various misc development dependencies (@majormoses)
|
18
|
+
|
19
|
+
### Changed
|
20
|
+
- standard gemspec (@majormoses)
|
21
|
+
- appease the cops (@majormoses)
|
22
|
+
- standard Rakefile (@majormoses)
|
5
23
|
|
6
24
|
## [0.0.9] - 2016-04-05
|
7
25
|
### Added
|
@@ -38,3 +56,16 @@ This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachang
|
|
38
56
|
## [0.0.1] - 2015-12-28
|
39
57
|
### Added
|
40
58
|
- Initial release
|
59
|
+
|
60
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-ntp/compare/1.0.0...HEAD
|
61
|
+
[1.0.2]: https://github.com/sensu-plugins/sensu-plugins-ntp/compare/0.0.10...1.0.0
|
62
|
+
[0.0.10]: https://github.com/sensu-plugins/sensu-plugins-ntp/compare/0.0.9...0.0.10
|
63
|
+
[0.0.9]: https://github.com/sensu-plugins/sensu-plugins-ntp/compare/0.0.8...0.0.9
|
64
|
+
[0.0.8]: https://github.com/sensu-plugins/sensu-plugins-ntp/compare/0.0.7...0.0.8
|
65
|
+
[0.0.7]: https://github.com/sensu-plugins/sensu-plugins-ntp/compare/0.0.6...0.0.7
|
66
|
+
[0.0.6]: https://github.com/sensu-plugins/sensu-plugins-ntp/compare/0.0.5...0.0.6
|
67
|
+
[0.0.5]: https://github.com/sensu-plugins/sensu-plugins-ntp/compare/0.0.4...0.0.5
|
68
|
+
[0.0.4]: https://github.com/sensu-plugins/sensu-plugins-ntp/compare/0.0.3...0.0.4
|
69
|
+
[0.0.3]: https://github.com/sensu-plugins/sensu-plugins-ntp/compare/0.0.2...0.0.3
|
70
|
+
[0.0.2]: https://github.com/sensu-plugins/sensu-plugins-ntp/compare/0.0.1...0.0.2
|
71
|
+
[0.0.1]: https://github.com/sensu-plugins/sensu-plugins-ntp/compare/00e3dfb1d044946ec5465f7075dce532bbb60cff...0.0.1
|
data/README.md
CHANGED
@@ -1,5 +1,13 @@
|
|
1
1
|
# Sensu plugin for monitoring Chrony NTP
|
2
2
|
|
3
|
+
|
4
|
+
[](https://travis-ci.org/sensu-plugins/sensu-plugins-chrony)
|
5
|
+
[](https://badge.fury.io/rb/sensu-plugins-chrony)
|
6
|
+
[](https://codeclimate.com/github/sensu-plugins/sensu-plugins-chrony)
|
7
|
+
[](https://codeclimate.com/github/sensu-plugins/sensu-plugins-chrony)
|
8
|
+
[](https://gemnasium.com/sensu-plugins/sensu-plugins-chrony)
|
9
|
+
[](https://slack.sensu.io/badge)
|
10
|
+
|
3
11
|
A sensu plugin to monitor Chrony NTP. There is also a metrics plugin for collecting things like offset, delay etc.
|
4
12
|
|
5
13
|
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.
|
data/bin/check-chrony.rb
CHANGED
@@ -11,48 +11,48 @@ require 'json'
|
|
11
11
|
|
12
12
|
class CheckChrony < Sensu::Plugin::Check::CLI
|
13
13
|
option :chronyc_cmd,
|
14
|
-
:
|
15
|
-
:
|
16
|
-
:
|
17
|
-
:
|
14
|
+
description: 'Path to chronyc executable (default: /usr/bin/chronyc)',
|
15
|
+
short: '-c <PATH>',
|
16
|
+
long: '--chronyc-cmd <PATH>',
|
17
|
+
default: '/usr/bin/chronyc'
|
18
18
|
|
19
19
|
option :warn_offset,
|
20
|
-
:
|
21
|
-
:
|
22
|
-
:
|
23
|
-
:
|
20
|
+
description: 'Warn if OFFSET exceeds current offset (ms)',
|
21
|
+
long: '--warn-offset <OFFSET>',
|
22
|
+
proc: proc(&:to_f),
|
23
|
+
default: 50
|
24
24
|
|
25
25
|
option :crit_offset,
|
26
|
-
:
|
27
|
-
:
|
28
|
-
:
|
29
|
-
:
|
26
|
+
description: 'Critical if OFFSET exceeds current offset (ms)',
|
27
|
+
long: '--crit-offset <OFFSET>',
|
28
|
+
proc: proc(&:to_f),
|
29
|
+
default: 100
|
30
30
|
|
31
31
|
option :warn_stratum,
|
32
|
-
:
|
33
|
-
:
|
34
|
-
:
|
35
|
-
:
|
32
|
+
description: 'Warn if STRATUM exceeds current stratum',
|
33
|
+
long: '--warn-stratum <STRATUM>',
|
34
|
+
proc: proc(&:to_i),
|
35
|
+
default: 10
|
36
36
|
|
37
37
|
option :crit_stratum,
|
38
|
-
:
|
39
|
-
:
|
40
|
-
:
|
41
|
-
:
|
38
|
+
description: 'Critical if STRATUM exceeds current stratum',
|
39
|
+
long: '--crit-stratum <STRATUM>',
|
40
|
+
proc: proc(&:to_i),
|
41
|
+
default: 16
|
42
42
|
|
43
43
|
option :handlers,
|
44
|
-
:
|
45
|
-
:
|
46
|
-
:
|
47
|
-
:
|
44
|
+
description: 'Comma separated list of handlers',
|
45
|
+
long: '--handlers <HANDLER>',
|
46
|
+
proc: proc { |s| s.split(',') },
|
47
|
+
default: []
|
48
48
|
|
49
49
|
option :dryrun,
|
50
|
-
:
|
51
|
-
:
|
52
|
-
:
|
53
|
-
:
|
50
|
+
description: 'Do not send events to sensu client socket',
|
51
|
+
long: '--dryrun',
|
52
|
+
boolean: true,
|
53
|
+
default: false
|
54
54
|
|
55
|
-
def initialize
|
55
|
+
def initialize
|
56
56
|
super
|
57
57
|
end
|
58
58
|
|
@@ -61,27 +61,47 @@ class CheckChrony < Sensu::Plugin::Check::CLI
|
|
61
61
|
puts data.inspect
|
62
62
|
else
|
63
63
|
sock = UDPSocket.new
|
64
|
-
sock.send(data + "\n", 0,
|
64
|
+
sock.send(data + "\n", 0, '127.0.0.1', 3030)
|
65
65
|
end
|
66
66
|
end
|
67
67
|
|
68
68
|
def send_ok(check_name, msg)
|
69
|
-
event = {
|
69
|
+
event = {
|
70
|
+
'name' => check_name,
|
71
|
+
'status' => 0,
|
72
|
+
'output' => "#{self.class.name} OK: #{msg}",
|
73
|
+
'handlers' => config[:handlers]
|
74
|
+
}
|
70
75
|
send_client_socket(event.to_json)
|
71
76
|
end
|
72
77
|
|
73
78
|
def send_warning(check_name, msg)
|
74
|
-
event = {
|
79
|
+
event = {
|
80
|
+
'name' => check_name,
|
81
|
+
'status' => 1,
|
82
|
+
'output' => "#{self.class.name} WARNING: #{msg}",
|
83
|
+
'handlers' => config[:handlers]
|
84
|
+
}
|
75
85
|
send_client_socket(event.to_json)
|
76
86
|
end
|
77
87
|
|
78
88
|
def send_critical(check_name, msg)
|
79
|
-
event = {
|
89
|
+
event = {
|
90
|
+
'name' => check_name,
|
91
|
+
'status' => 2,
|
92
|
+
'output' => "#{self.class.name} CRITICAL: #{msg}",
|
93
|
+
'handlers' => config[:handlers]
|
94
|
+
}
|
80
95
|
send_client_socket(event.to_json)
|
81
96
|
end
|
82
97
|
|
83
98
|
def send_unknown(check_name, msg)
|
84
|
-
event = {
|
99
|
+
event = {
|
100
|
+
'name' => check_name,
|
101
|
+
'status' => 3,
|
102
|
+
'output' => "#{self.class.name} UNKNOWN: #{msg}",
|
103
|
+
'handlers' => config[:handlers]
|
104
|
+
}
|
85
105
|
send_client_socket(event.to_json)
|
86
106
|
end
|
87
107
|
|
@@ -90,19 +110,19 @@ class CheckChrony < Sensu::Plugin::Check::CLI
|
|
90
110
|
offset = nil
|
91
111
|
status = nil
|
92
112
|
|
93
|
-
|
113
|
+
`#{config[:chronyc_cmd]} tracking`.each_line do |line|
|
94
114
|
case line.downcase
|
95
|
-
|
96
|
-
|
97
|
-
|
98
|
-
|
99
|
-
|
100
|
-
|
101
|
-
|
115
|
+
when /^stratum\s*:\s*(\d+)$/
|
116
|
+
stratum = Regexp.last_match(1).to_i
|
117
|
+
when /^last offset\s*:\s*([\-\+]?[.\d]+)\s*seconds$/
|
118
|
+
# convert from seconds to milliseconds
|
119
|
+
offset = Regexp.last_match(1).to_f * 1000
|
120
|
+
when /^leap status\s*:\s*(.*?)$/
|
121
|
+
status = Regexp.last_match(1)
|
102
122
|
end
|
103
123
|
end
|
104
124
|
|
105
|
-
check_name =
|
125
|
+
check_name = 'chrony-stratum'
|
106
126
|
if stratum
|
107
127
|
msg = "NTP stratum is #{stratum}"
|
108
128
|
|
@@ -116,37 +136,37 @@ class CheckChrony < Sensu::Plugin::Check::CLI
|
|
116
136
|
send_ok(check_name, msg)
|
117
137
|
end
|
118
138
|
else
|
119
|
-
send_unknown(check_name,
|
139
|
+
send_unknown(check_name, 'Failed to look up NTP stratum')
|
120
140
|
end
|
121
141
|
|
122
|
-
check_name =
|
142
|
+
check_name = 'chrony-offset'
|
123
143
|
if offset
|
124
144
|
msg = "NTP offset is #{offset.round(4)}ms"
|
125
145
|
|
126
|
-
if offset >= config[:crit_offset]
|
146
|
+
if offset >= config[:crit_offset] || offset <= -config[:crit_offset]
|
127
147
|
msg += ", expected > -#{config[:crit_offset]} and < #{config[:crit_offset]}"
|
128
148
|
send_critical(check_name, msg)
|
129
|
-
elsif offset >= config[:warn_offset]
|
149
|
+
elsif offset >= config[:warn_offset] || offset < -config[:warn_offset]
|
130
150
|
msg += ", expected > -#{config[:crit_offset]} and < #{config[:warn_offset]}"
|
131
151
|
send_critical(check_name, msg)
|
132
152
|
else
|
133
153
|
send_ok(check_name, msg)
|
134
154
|
end
|
135
155
|
else
|
136
|
-
send_unknown(check_name,
|
156
|
+
send_unknown(check_name, 'Failed to look up NTP offset')
|
137
157
|
end
|
138
158
|
|
139
159
|
if status
|
140
160
|
msg = "NTP status is '#{status}'"
|
141
161
|
|
142
|
-
if status !=
|
143
|
-
msg +=
|
162
|
+
if status != 'normal'
|
163
|
+
msg += ', expected \'Normal\''
|
144
164
|
critical(msg)
|
145
165
|
else
|
146
166
|
ok(msg)
|
147
167
|
end
|
148
168
|
else
|
149
|
-
unknown(
|
169
|
+
unknown('Failed to look up NTP status')
|
150
170
|
end
|
151
171
|
end
|
152
172
|
end
|
data/bin/metrics-chrony.rb
CHANGED
@@ -1,5 +1,4 @@
|
|
1
1
|
#! /usr/bin/env ruby
|
2
|
-
# encoding: UTF-8
|
3
2
|
#
|
4
3
|
# metrics-chrony
|
5
4
|
#
|
@@ -42,7 +41,7 @@ class ChronyMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
42
41
|
config[:scheme] = config[:host]
|
43
42
|
end
|
44
43
|
|
45
|
-
chronystats =
|
44
|
+
chronystats = chronystats
|
46
45
|
critical "Failed to get chronycstats from #{config[:host]}" if chronystats.empty?
|
47
46
|
metrics = {
|
48
47
|
config[:scheme] => chronystats
|
@@ -55,17 +54,16 @@ class ChronyMetrics < Sensu::Plugin::Metric::CLI::Graphite
|
|
55
54
|
ok
|
56
55
|
end
|
57
56
|
|
58
|
-
def
|
57
|
+
def chronystats
|
59
58
|
num_val_pattern = /^[-+]?\d+(\.\d+)?\s/
|
60
59
|
|
61
|
-
`chronyc tracking`.each_line.
|
60
|
+
`chronyc tracking`.each_line.each_with_object({}) do |line, hash|
|
62
61
|
key, val = line.split(/\s*:\s*/)
|
63
62
|
matched = val.match(num_val_pattern) || (next hash)
|
64
63
|
number, fraction = matched.to_a
|
65
64
|
number = fraction ? number.to_f : number.to_i
|
66
65
|
number = - number if /slow/ =~ val # for system time
|
67
66
|
hash[snakecase(key)] = number
|
68
|
-
hash
|
69
67
|
end
|
70
68
|
end
|
71
69
|
|
metadata
CHANGED
@@ -1,34 +1,135 @@
|
|
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: 1.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Matteo Cerutti
|
8
|
+
- Sensu-Plugins and contributors
|
8
9
|
autorequire:
|
9
10
|
bindir: bin
|
10
11
|
cert_chain: []
|
11
|
-
date:
|
12
|
+
date: 2018-01-04 00:00:00.000000000 Z
|
12
13
|
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: bundler
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
requirements:
|
18
|
+
- - "~>"
|
19
|
+
- !ruby/object:Gem::Version
|
20
|
+
version: '1.7'
|
21
|
+
type: :development
|
22
|
+
prerelease: false
|
23
|
+
version_requirements: !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "~>"
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
version: '1.7'
|
28
|
+
- !ruby/object:Gem::Dependency
|
29
|
+
name: github-markup
|
30
|
+
requirement: !ruby/object:Gem::Requirement
|
31
|
+
requirements:
|
32
|
+
- - "~>"
|
33
|
+
- !ruby/object:Gem::Version
|
34
|
+
version: '1.3'
|
35
|
+
type: :development
|
36
|
+
prerelease: false
|
37
|
+
version_requirements: !ruby/object:Gem::Requirement
|
38
|
+
requirements:
|
39
|
+
- - "~>"
|
40
|
+
- !ruby/object:Gem::Version
|
41
|
+
version: '1.3'
|
42
|
+
- !ruby/object:Gem::Dependency
|
43
|
+
name: rake
|
44
|
+
requirement: !ruby/object:Gem::Requirement
|
45
|
+
requirements:
|
46
|
+
- - "~>"
|
47
|
+
- !ruby/object:Gem::Version
|
48
|
+
version: '12.0'
|
49
|
+
type: :development
|
50
|
+
prerelease: false
|
51
|
+
version_requirements: !ruby/object:Gem::Requirement
|
52
|
+
requirements:
|
53
|
+
- - "~>"
|
54
|
+
- !ruby/object:Gem::Version
|
55
|
+
version: '12.0'
|
56
|
+
- !ruby/object:Gem::Dependency
|
57
|
+
name: redcarpet
|
58
|
+
requirement: !ruby/object:Gem::Requirement
|
59
|
+
requirements:
|
60
|
+
- - "~>"
|
61
|
+
- !ruby/object:Gem::Version
|
62
|
+
version: '3.2'
|
63
|
+
type: :development
|
64
|
+
prerelease: false
|
65
|
+
version_requirements: !ruby/object:Gem::Requirement
|
66
|
+
requirements:
|
67
|
+
- - "~>"
|
68
|
+
- !ruby/object:Gem::Version
|
69
|
+
version: '3.2'
|
70
|
+
- !ruby/object:Gem::Dependency
|
71
|
+
name: rspec
|
72
|
+
requirement: !ruby/object:Gem::Requirement
|
73
|
+
requirements:
|
74
|
+
- - "~>"
|
75
|
+
- !ruby/object:Gem::Version
|
76
|
+
version: '3.4'
|
77
|
+
type: :development
|
78
|
+
prerelease: false
|
79
|
+
version_requirements: !ruby/object:Gem::Requirement
|
80
|
+
requirements:
|
81
|
+
- - "~>"
|
82
|
+
- !ruby/object:Gem::Version
|
83
|
+
version: '3.4'
|
84
|
+
- !ruby/object:Gem::Dependency
|
85
|
+
name: rubocop
|
86
|
+
requirement: !ruby/object:Gem::Requirement
|
87
|
+
requirements:
|
88
|
+
- - "~>"
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: 0.49.0
|
91
|
+
type: :development
|
92
|
+
prerelease: false
|
93
|
+
version_requirements: !ruby/object:Gem::Requirement
|
94
|
+
requirements:
|
95
|
+
- - "~>"
|
96
|
+
- !ruby/object:Gem::Version
|
97
|
+
version: 0.49.0
|
98
|
+
- !ruby/object:Gem::Dependency
|
99
|
+
name: yard
|
100
|
+
requirement: !ruby/object:Gem::Requirement
|
101
|
+
requirements:
|
102
|
+
- - "~>"
|
103
|
+
- !ruby/object:Gem::Version
|
104
|
+
version: '0.8'
|
105
|
+
type: :development
|
106
|
+
prerelease: false
|
107
|
+
version_requirements: !ruby/object:Gem::Requirement
|
108
|
+
requirements:
|
109
|
+
- - "~>"
|
110
|
+
- !ruby/object:Gem::Version
|
111
|
+
version: '0.8'
|
13
112
|
- !ruby/object:Gem::Dependency
|
14
113
|
name: sensu-plugin
|
15
114
|
requirement: !ruby/object:Gem::Requirement
|
16
115
|
requirements:
|
17
|
-
- -
|
116
|
+
- - "~>"
|
18
117
|
- !ruby/object:Gem::Version
|
19
|
-
version:
|
118
|
+
version: '2.0'
|
20
119
|
type: :runtime
|
21
120
|
prerelease: false
|
22
121
|
version_requirements: !ruby/object:Gem::Requirement
|
23
122
|
requirements:
|
24
|
-
- -
|
123
|
+
- - "~>"
|
25
124
|
- !ruby/object:Gem::Version
|
26
|
-
version:
|
125
|
+
version: '2.0'
|
27
126
|
description: This plugin provides facilities for monitoring Chrony NTP
|
28
|
-
email:
|
127
|
+
email:
|
128
|
+
- "<matteo.cerutti@hotmail.co.uk>"
|
129
|
+
- "<sensu-users@googlegroups.com>"
|
29
130
|
executables:
|
30
|
-
- check-chrony.rb
|
31
131
|
- metrics-chrony.rb
|
132
|
+
- check-chrony.rb
|
32
133
|
extensions: []
|
33
134
|
extra_rdoc_files: []
|
34
135
|
files:
|
@@ -57,7 +158,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
57
158
|
requirements:
|
58
159
|
- - ">="
|
59
160
|
- !ruby/object:Gem::Version
|
60
|
-
version:
|
161
|
+
version: 2.0.0
|
61
162
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
62
163
|
requirements:
|
63
164
|
- - ">="
|
@@ -65,7 +166,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
65
166
|
version: '0'
|
66
167
|
requirements: []
|
67
168
|
rubyforge_project:
|
68
|
-
rubygems_version: 2.
|
169
|
+
rubygems_version: 2.5.2.1
|
69
170
|
signing_key:
|
70
171
|
specification_version: 4
|
71
172
|
summary: Sensu plugins for monitoring Chrony NTP
|