sensu-plugins-edgelab 1.3.1 → 1.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/bin/check-nomad-jobs.rb +39 -1
- metadata +5 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: aa20291918973ec9b435b65626dec763c7b36be2
|
4
|
+
data.tar.gz: 27fc4397fb9b6454d504239f469abe596a465806
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2c3b8052c10cd420be8c30891cd453ef1bac9997c2b5d2c319f6573919f8ad469351d58065b695a6e61253db99fbc0714604f2f1c39fced570d21d11edb15147
|
7
|
+
data.tar.gz: 3b18f436aa32a778743c465ae63fa3fe55019a1a7fbc5fa08808e078b53e02c0efbb82a72e8e0443a1e3281ca3d0fd681342ba67b22707996dc3ecf2918b8e98
|
data/bin/check-nomad-jobs.rb
CHANGED
@@ -17,11 +17,22 @@ class CheckNomadAllocations < Sensu::Plugin::Check::CLI
|
|
17
17
|
description: 'Nomad server URL',
|
18
18
|
long: '--nomad SERVER',
|
19
19
|
default: 'http://localhost:4646'
|
20
|
+
|
20
21
|
option :alloc_starting_time,
|
21
22
|
description: '',
|
22
|
-
long: '--alloc-starting-time',
|
23
|
+
long: '--alloc-starting-time SECONDS',
|
23
24
|
default: 300
|
24
25
|
|
26
|
+
option :alloc_restarts_count,
|
27
|
+
description: 'Limit number of restarts in restarts interval',
|
28
|
+
long: '--alloc-restarts-count COUNT',
|
29
|
+
default: 3
|
30
|
+
|
31
|
+
option :alloc_restarts_interval,
|
32
|
+
description: 'Interval in seconds for the limit number of restarts',
|
33
|
+
long: '--alloc-restarts-interval SECONDS',
|
34
|
+
default: 3600
|
35
|
+
|
25
36
|
# Call Nomad api and parse the JSON response
|
26
37
|
def api_call(endpoint)
|
27
38
|
url = config[:nomad] + endpoint
|
@@ -125,6 +136,32 @@ class CheckNomadAllocations < Sensu::Plugin::Check::CLI
|
|
125
136
|
end
|
126
137
|
end
|
127
138
|
|
139
|
+
# Check that running allocations are not restarting endlessly.
|
140
|
+
def check_restarts(job, failed)
|
141
|
+
allocations = api_call "/v1/job/#{job['ID']}/allocations"
|
142
|
+
now = Time.new.to_i
|
143
|
+
|
144
|
+
allocations.each do |alloc|
|
145
|
+
if %w(running pending).include? alloc['ClientStatus']
|
146
|
+
alloc['TaskStates'].each do |_, state|
|
147
|
+
restarts = 0
|
148
|
+
state['Events'].each do |event|
|
149
|
+
if event['Type'] == 'Restarting'
|
150
|
+
event_time = event['Time'] / 1_000_000_000
|
151
|
+
if (now - event_time) < config[:alloc_restarts_interval].to_i
|
152
|
+
restarts += 1
|
153
|
+
end
|
154
|
+
end
|
155
|
+
end
|
156
|
+
|
157
|
+
if restarts >= config[:alloc_restarts_count].to_i
|
158
|
+
failed << "Alloc #{alloc['Name']} restart #{restarts} times"
|
159
|
+
end
|
160
|
+
end
|
161
|
+
end
|
162
|
+
end
|
163
|
+
end
|
164
|
+
|
128
165
|
def run
|
129
166
|
jobs = api_call '/v1/jobs'
|
130
167
|
if jobs.empty?
|
@@ -136,6 +173,7 @@ class CheckNomadAllocations < Sensu::Plugin::Check::CLI
|
|
136
173
|
jobs.each do |job|
|
137
174
|
check_evaluations job, failed
|
138
175
|
check_allocations job, failed
|
176
|
+
check_restarts job, failed
|
139
177
|
end
|
140
178
|
|
141
179
|
if failed.any?
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: sensu-plugins-edgelab
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.
|
4
|
+
version: 1.4.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Edgelab
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2017-02-
|
11
|
+
date: 2017-02-10 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|
@@ -111,12 +111,12 @@ dependencies:
|
|
111
111
|
description: Sensu plugins developed by Edgelab
|
112
112
|
email:
|
113
113
|
executables:
|
114
|
-
- check-
|
114
|
+
- check-swarm-cluster.rb
|
115
|
+
- metrics-mysql-processes.rb
|
115
116
|
- metrics-swarm-cluster.rb
|
116
117
|
- check-apt-expired-keys.rb
|
117
118
|
- check-nomad-jobs.rb
|
118
|
-
- check-
|
119
|
-
- metrics-mysql-processes.rb
|
119
|
+
- check-nomad-leader.rb
|
120
120
|
extensions: []
|
121
121
|
extra_rdoc_files: []
|
122
122
|
files:
|