sensu-plugins-dcos 0.1.1 → 0.2.1

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: ca7de35d531d725fb523f4dc16f9208964fc3884
4
- data.tar.gz: 5fae4736ccbd3c71774bca089de48df61ce47f01
3
+ metadata.gz: 07bd997624bf5387753484ba744031370e8ce7a3
4
+ data.tar.gz: 42fca613ad7272657e3f8f9a520e8195721f6075
5
5
  SHA512:
6
- metadata.gz: 82e2e7dd728cea9f0f95397ee9d593a6bd56f14d22c78e928f9ebae1940a1fc85567eb7a66db550478b5fed19977bc1da2f5b9ed486fb7098e451d584fdc7493
7
- data.tar.gz: 44c36776b9e7e3ed093bc479de379c8abbf1b7abb81a53ecbf143ab0f22417d8ec9ee6b3c8f635762acd25b3b0e08019864dde52794c52453cf870d81e63f54b
6
+ metadata.gz: 7a526af3510a72c212c5d3ffea0b9e6c606c69482d9a663625bb52a01c7c352303f39848203aac98762a31f1620a26fb50ecdbb6ccdd14698203ca9f84a06f8e
7
+ data.tar.gz: dc85810f822b53443ff3d17079e06849569eb515f5998663b28b2c8ad000d8c475a5020fbbf9ab5b283c60e79ff4a5392ea64faa3d38c88e8940677cd4da66dc
@@ -6,6 +6,10 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
6
6
 
7
7
  ## [Unreleased]
8
8
 
9
+ ## [0.2.1] - 2017-09-12
10
+ ### Added
11
+ - `check-dcos-jobs-health.rb`: checks the health of a DC/OS jobs exposed by the mesos API endpoint /tasks (@mgaitien)
12
+
9
13
  ## [0.1.1] - 2017-09-09
10
14
  ### Fixed
11
15
  - metrics-dcos-system-health.rb: Small but essential fixes for DC/OS system health metrics collection (@zemmet)
@@ -36,7 +40,7 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
36
40
  - standard `.rubocop.yml`, `CHANGELOG.md`, `Rakefile` files
37
41
 
38
42
  ### Removed
39
- - removed various misc files from trnasfer such as circle-ci stuff (@majormoses)
43
+ - removed various misc files from transfer such as circle-ci stuff (@majormoses)
40
44
 
41
45
 
42
46
  ## [0.0.2] - 2017-08-03
@@ -48,7 +52,8 @@ Which is based on [Keep A Changelog](http://keepachangelog.com/)
48
52
  ### Added
49
53
  - Initial release
50
54
 
51
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-dcos/compare/0.1.1...HEAD
55
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-dcos/compare/0.2.1...HEAD
56
+ [0.2.1]: https://github.com/sensu-plugins/sensu-plugins-dcos/compare/0.1.1...0.2.1
52
57
  [0.1.1]: https://github.com/sensu-plugins/sensu-plugins-dcos/compare/0.1.0...0.1.1
53
58
  [0.1.0]: https://github.com/sensu-plugins/sensu-plugins-dcos/compare/0.0.4...0.1.0
54
59
  [0.0.4]: https://github.com/sensu-plugins/sensu-plugins-dcos/compare/0.0.3...0.0.4
data/README.md CHANGED
@@ -66,6 +66,13 @@ The `check-dcos-ping.rb` will return `OK` if the host reports itself as heathy o
66
66
  check-dcos-ping.rb -h 'http://127.0.0.1:61001/system/v1/metrics/v0/ping'
67
67
  ```
68
68
 
69
+ ### Jobs Health Check
70
+
71
+ The `check-dcos-jobs-health.rb` will return `OK` if the job is successfully executed for the last 15 minutes or `CRITICAL` if the tasks return FAILED or KILLED or the job is stuck take longer than (15 minutes - threshold )
72
+ ```
73
+ check-dcos-jobs-health.rb -u 'http://leader.mesos:5050/tasks' -p jobname -w 1000 -t 200
74
+ ```
75
+
69
76
  ## Installation
70
77
 
71
78
  [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
@@ -0,0 +1,93 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # check-dcos-jobs-health
4
+ #
5
+ # DESCRIPTION:
6
+ # This plugin checks the health of a DC/OS jobs exposed by the mesos API endpoint /tasks
7
+ #
8
+ # OUTPUT:
9
+ # Plain text
10
+ #
11
+ # PLATFORMS:
12
+ # Linux
13
+ #
14
+ # DEPENDENCIES:
15
+ # gem: sensu-plugin
16
+ #
17
+ # USAGE:
18
+ # check-dcos-jobs-health.rb -u 'http://leader.mesos:5050/tasks' -p 'cron.jobname' -w 1000.0000
19
+ #
20
+ # NOTES:
21
+ #
22
+ # LICENCE:
23
+ # PTC http://www.ptc.com/
24
+ # Copyright 2017 PTC Inc.
25
+ #
26
+ # Licensed under the Apache License, Version 2.0 (the "License");
27
+ # you may not use this file except in compliance with the License.
28
+ # You may obtain a copy of the License at
29
+ #
30
+ # http://www.apache.org/licenses/LICENSE-2.0
31
+ #
32
+ # Unless required by applicable law or agreed to in writing, software
33
+ # distributed under the License is distributed on an "AS IS" BASIS,
34
+ # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
35
+ # See the License for the specific language governing permissions and
36
+ # limitations under the License.
37
+
38
+ require 'sensu-plugin/check/cli'
39
+ require 'json'
40
+ require 'net/http'
41
+ require 'uri'
42
+ require 'sensu-plugins-dcos'
43
+
44
+ #
45
+ # Check DCOS System Health API
46
+ #
47
+
48
+ class CheckDcosJobsHealth < Sensu::Plugin::Check::CLI
49
+ include Common
50
+
51
+ option :url,
52
+ description: 'URL',
53
+ short: '-u URL',
54
+ long: '--url URL',
55
+ default: 'http://leader.mesos:5050/tasks'
56
+
57
+ option :pattern,
58
+ description: 'Pattern',
59
+ short: '-p pattern',
60
+ long: '--pattern PATTERN',
61
+ default: 'cron'
62
+
63
+ option :window,
64
+ description: 'Window/history for tasks',
65
+ short: '-w time',
66
+ long: '--window time',
67
+ default: 1000.0000
68
+
69
+ option :threshold,
70
+ description: 'Threshold for a running task - the Window',
71
+ short: '-t float',
72
+ long: '--threshold float',
73
+ default: 200.0000
74
+
75
+ def run
76
+ t = Time.now.to_f.round(4)
77
+ resource = get_data(config[:url])
78
+ resource['tasks'].each do |unit|
79
+ if unit['id'] =~ /#{config[:pattern].sub('.', '.*')}/ && unit['statuses'][0]['timestamp'] > t - config[:window].to_f.round(4)
80
+ if unit['state'] =~ /RUNNING/
81
+ if t - unit['statuses'][0]['timestamp'] > (config[:window].to_f.round(4) - config[:threshold].to_f.round(4))
82
+ message "JOB: #{unit['id']} is taking too long to finish..."
83
+ critical
84
+ end
85
+ elsif unit['state'] =~ /FAILED|KILLED/
86
+ message "JOB: #{unit['id']}"
87
+ critical
88
+ end
89
+ end
90
+ end
91
+ ok
92
+ end
93
+ end
@@ -3,7 +3,7 @@
3
3
  module SensuPluginsDcos
4
4
  module Version
5
5
  MAJOR = 0
6
- MINOR = 1
6
+ MINOR = 2
7
7
  PATCH = 1
8
8
 
9
9
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-dcos
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - PTC and contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-09-09 00:00:00.000000000 Z
11
+ date: 2017-09-12 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -279,6 +279,7 @@ executables:
279
279
  - check-dcos-container-count.rb
280
280
  - check-dcos-container-metrics.rb
281
281
  - check-dcos-component-health.rb
282
+ - check-dcos-jobs-health.rb
282
283
  - metrics-dcos-system-health.rb
283
284
  - check-dcos-ping.rb
284
285
  - metrics-dcos-containers.rb
@@ -291,6 +292,7 @@ files:
291
292
  - bin/check-dcos-component-health.rb
292
293
  - bin/check-dcos-container-count.rb
293
294
  - bin/check-dcos-container-metrics.rb
295
+ - bin/check-dcos-jobs-health.rb
294
296
  - bin/check-dcos-metrics.rb
295
297
  - bin/check-dcos-node-health.rb
296
298
  - bin/check-dcos-ping.rb