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.
Files changed (3) hide show
  1. checksums.yaml +4 -4
  2. data/bin/check-nomad-jobs.rb +22 -0
  3. metadata +1 -1
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: afdfb286fceeed74b84c57c85c4b6662383cb76d
4
- data.tar.gz: e1ea7fdc49285e48de0c42b47367f4bc6b566048
3
+ metadata.gz: ab3ce4589077b73d7c20f5eb0f4ef5cb2c0e409f
4
+ data.tar.gz: b42f16813bb3abb3b171d3d25ec33ec05d23b6f6
5
5
  SHA512:
6
- metadata.gz: d90061eac478c51c164c4c56ce9bfbfb52de21113697ae24b712135a7b860add3de3064275874e6a1e7ed7f7dfd94d33f4a7a1956de1464556bf6869b732b88d
7
- data.tar.gz: a63b55b79e8e41ca42496066db4532e6f719befd0894e6b0d45b85f56dec11ef1e047bbdc5af826ce1f903781b56a786ad4f071061a9983f4525fd711d894b77
6
+ metadata.gz: 6fa6c0a67f2f9180c1d6d867dd59e067b0b15abad6534c1b40cc0cacbd904db87846878ea828cf9b9a8bfa4b9b137797992507c48e0633df4ff21387003fba34
7
+ data.tar.gz: 4026056d4fb258c2190f6cf1ed892327a8e9e2289f3e7296df4dab5334d4ab884e0f4a8c1ab16a1db49561542a4ec5380f3e44b90cfcac30228389e99f955787
@@ -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'"
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-edgelab
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.6.1
4
+ version: 1.6.2
5
5
  platform: ruby
6
6
  authors:
7
7
  - Edgelab