sensu-plugins-edgelab 1.6.1 → 1.6.2
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/bin/check-nomad-jobs.rb +22 -0
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: ab3ce4589077b73d7c20f5eb0f4ef5cb2c0e409f
|
4
|
+
data.tar.gz: b42f16813bb3abb3b171d3d25ec33ec05d23b6f6
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 6fa6c0a67f2f9180c1d6d867dd59e067b0b15abad6534c1b40cc0cacbd904db87846878ea828cf9b9a8bfa4b9b137797992507c48e0633df4ff21387003fba34
|
7
|
+
data.tar.gz: 4026056d4fb258c2190f6cf1ed892327a8e9e2289f3e7296df4dab5334d4ab884e0f4a8c1ab16a1db49561542a4ec5380f3e44b90cfcac30228389e99f955787
|
data/bin/check-nomad-jobs.rb
CHANGED
@@ -33,6 +33,11 @@ class CheckNomadAllocations < Sensu::Plugin::Check::CLI
|
|
33
33
|
long: '--alloc-restarts-interval SECONDS',
|
34
34
|
default: 3600
|
35
35
|
|
36
|
+
option :client_pending_time,
|
37
|
+
description: 'Pending time limit for a task on a client',
|
38
|
+
long: '--client-pending-time SECONDS',
|
39
|
+
default: 60 * 10
|
40
|
+
|
36
41
|
# Call Nomad api and parse the JSON response
|
37
42
|
def api_call(endpoint)
|
38
43
|
url = config[:nomad] + endpoint
|
@@ -123,6 +128,23 @@ class CheckNomadAllocations < Sensu::Plugin::Check::CLI
|
|
123
128
|
# Batch stay in run DesiredStatus even if task completed successfully.
|
124
129
|
next if job['Type'] == 'batch' && alloc['ClientStatus'] == 'complete'
|
125
130
|
|
131
|
+
if alloc['TaskStates'].nil? && alloc['ClientStatus'] == 'pending'
|
132
|
+
# {"ID" => "6e6d8f0c-0ddb-6083-37ca-50c05b75ceae",
|
133
|
+
# "EvalID" => "aa228c5c-c203-c1f7-3d0c-91ba4aa70c7c",
|
134
|
+
# "Name" => "stuff/periodic-1490196240.tuff[0]",
|
135
|
+
# "NodeID" => "5165a46e-3dea-6346-6ac4-439934e1856e",
|
136
|
+
# "JobID" => "stuff/periodic-1490196240",
|
137
|
+
# "TaskGroup" => "stuff", "DesiredStatus" => "run",
|
138
|
+
# "DesiredDescription" => "", "ClientStatus" => "pending",
|
139
|
+
# "ClientDescription" => "", "TaskStates" => nil,
|
140
|
+
# "CreateIndex" => 326672, "ModifyIndex" => 326672,
|
141
|
+
# "CreateTime" => 1490196240365025270}
|
142
|
+
pending_for = (Time.new - Time.at(alloc['CreateTime'] / 1_000_000_000)).round
|
143
|
+
if pending_for > config[:client_pending_time]
|
144
|
+
failed << "Alloc #{alloc['Name']} is pending on client since #{pending_for} seconds"
|
145
|
+
end
|
146
|
+
end
|
147
|
+
|
126
148
|
alloc['TaskStates'].each do |_, state|
|
127
149
|
if state['State'] == 'dead'
|
128
150
|
failed << "Alloc #{alloc['Name']} is dead but desired status is 'run'"
|