sensu-plugins-dcos 0.0.1 → 0.0.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/CHANGELOG.md +8 -4
- data/README.md +1 -0
- data/bin/check-dcos-component-health.rb +95 -0
- data/lib/sensu-plugins-dcos/common.rb +4 -4
- data/lib/sensu-plugins-dcos/version.rb +1 -1
- metadata +4 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d59fc68efa3e25906528db2a05013a96efe3e07d
|
4
|
+
data.tar.gz: 0478823b7d1a93b33b0adcb723816ae053dd169f
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 8f731f5374cc18cfc8ee963223aa3dea6cc200cd7099727750f58e3476067f712bf98b83850f00f97eae3c3715c1685544d32c593402d7a6323d91ccaca56546
|
7
|
+
data.tar.gz: 3cdf8e82100867b083729130c8205acf232b30a17db46d539281681834645b9d61b6146eed4445c859b439da0486978d0e7f6b30402312d04a3e5b2fc5fc4cba
|
data/CHANGELOG.md
CHANGED
@@ -4,13 +4,17 @@ This project adheres to [Semantic Versioning](http://semver.org/).
|
|
4
4
|
This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
|
5
5
|
|
6
6
|
## [Unreleased]
|
7
|
-
### Changed
|
8
|
-
- standard rake, travis, CHANGELOG, and rubocop files.
|
9
7
|
|
8
|
+
## [0.0.2] - 2017-08-03
|
9
|
+
### Added
|
10
|
+
- New DC/OS Component Health check
|
11
|
+
- Extending get_value function to provide the ability to override field names
|
10
12
|
## [0.0.1] - 2017-04-18
|
11
13
|
|
12
14
|
### Added
|
13
15
|
- Initial release
|
14
16
|
|
15
|
-
|
16
|
-
[
|
17
|
+
|
18
|
+
[Unreleased]: https://github.com/sensu-plugins/sensu-plugins-dcos/compare/0.0.2...HEAD
|
19
|
+
[0.0.2]: https://github.com/sensu-plugins/sensu-plugins-dcos/compare/0.0.1...0.0.2
|
20
|
+
[0.0.1]:https://github.com/sensu-plugins/sensu-plugins-dcos/compare/9c72afb596622f6c1a51f95281f52bd53791ede9...0.0.1
|
data/README.md
CHANGED
@@ -0,0 +1,95 @@
|
|
1
|
+
#! /usr/bin/env ruby
|
2
|
+
#
|
3
|
+
# check-dcos-component-health
|
4
|
+
#
|
5
|
+
# DESCRIPTION:
|
6
|
+
# This plugin checks the health of a DC/OS components exposed by the system/health/v1/units API endpoint
|
7
|
+
#
|
8
|
+
# OUTPUT:
|
9
|
+
# Plain text
|
10
|
+
#
|
11
|
+
# PLATFORMS:
|
12
|
+
# Linux
|
13
|
+
#
|
14
|
+
# DEPENDENCIES:
|
15
|
+
# gem: sensu-plugin
|
16
|
+
#
|
17
|
+
# USAGE:
|
18
|
+
# check-dcos-component-health.rb -u 'http://127.0.0.1:1050/system/health/v1/units' -c 'exhibitor.service'
|
19
|
+
#
|
20
|
+
# You can also run an ultimate health report to see if there are nay filing units::
|
21
|
+
# check-dcos-component-health.rb -u 'http://127.0.0.1:1050/system/health/v1/units'
|
22
|
+
#
|
23
|
+
# NOTES:
|
24
|
+
#
|
25
|
+
# LICENCE:
|
26
|
+
# PTC http://www.ptc.com/
|
27
|
+
# Copyright 2017 PTC Inc.
|
28
|
+
#
|
29
|
+
# Licensed under the Apache License, Version 2.0 (the "License");
|
30
|
+
# you may not use this file except in compliance with the License.
|
31
|
+
# You may obtain a copy of the License at
|
32
|
+
#
|
33
|
+
# http://www.apache.org/licenses/LICENSE-2.0
|
34
|
+
#
|
35
|
+
# Unless required by applicable law or agreed to in writing, software
|
36
|
+
# distributed under the License is distributed on an "AS IS" BASIS,
|
37
|
+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
38
|
+
# See the License for the specific language governing permissions and
|
39
|
+
# limitations under the License.
|
40
|
+
|
41
|
+
require 'sensu-plugin/check/cli'
|
42
|
+
require 'json'
|
43
|
+
require 'net/http'
|
44
|
+
require 'uri'
|
45
|
+
require 'sensu-plugins-dcos'
|
46
|
+
|
47
|
+
#
|
48
|
+
# Check DCOS System Health API
|
49
|
+
#
|
50
|
+
|
51
|
+
class CheckDcosComponentHealth < Sensu::Plugin::Check::CLI
|
52
|
+
include Common
|
53
|
+
|
54
|
+
option :url,
|
55
|
+
description: 'URL',
|
56
|
+
short: '-u URL',
|
57
|
+
long: '--url URL',
|
58
|
+
default: 'http://127.0.0.1:1050/system/health/v1/units'
|
59
|
+
|
60
|
+
option :component,
|
61
|
+
description: 'Component ID',
|
62
|
+
short: '-c COMPONENT',
|
63
|
+
long: '--component COMPONENT',
|
64
|
+
default: nil
|
65
|
+
|
66
|
+
option :filter,
|
67
|
+
description: 'Filter by Tags',
|
68
|
+
short: '-f TAG_NAME:TAG_VALUE',
|
69
|
+
long: '--filter TAG_NAME:TAG_VALUE',
|
70
|
+
default: nil
|
71
|
+
|
72
|
+
def run
|
73
|
+
if config[:component]
|
74
|
+
value = get_value(config[:url], config[:component], config[:filter], 'id', 'health', 'units')
|
75
|
+
message "#{config[:component]} = #{value}"
|
76
|
+
if value == 0
|
77
|
+
ok
|
78
|
+
else
|
79
|
+
critical
|
80
|
+
end
|
81
|
+
else
|
82
|
+
failed = 0
|
83
|
+
resource = get_data(config[:url])
|
84
|
+
resource['units'].each do |unit|
|
85
|
+
failed += unit['health']
|
86
|
+
end
|
87
|
+
message "components.unhealthy = #{failed}"
|
88
|
+
if failed == 0
|
89
|
+
ok
|
90
|
+
else
|
91
|
+
critical
|
92
|
+
end
|
93
|
+
end
|
94
|
+
end
|
95
|
+
end
|
@@ -32,15 +32,15 @@ module Common
|
|
32
32
|
critical 'Invalid JSON'
|
33
33
|
end
|
34
34
|
|
35
|
-
def get_value(url, metric, filter)
|
35
|
+
def get_value(url, metric, filter, name_field = 'name', value_field = 'value', root_field = 'datapoints') # rubocop:disable Metrics/ParameterLists
|
36
36
|
resource = get_data(url)
|
37
37
|
return {} if resource.nil? || resource.empty?
|
38
38
|
if filter
|
39
39
|
filter = filter.split(':')
|
40
|
-
value = resource[
|
41
|
-
value.select { |data| data[
|
40
|
+
value = resource[root_field].select { |data| data['tags'] == { filter[0] => filter[1] } }
|
41
|
+
value.select { |data| data[name_field] == metric }.first[value_field]
|
42
42
|
else
|
43
|
-
resource[
|
43
|
+
resource[root_field].select { |data| data[name_field] == metric }.first[value_field]
|
44
44
|
end
|
45
45
|
end
|
46
46
|
end
|
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.0.
|
4
|
+
version: 0.0.2
|
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-
|
11
|
+
date: 2017-08-03 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: sensu-plugin
|
@@ -239,6 +239,7 @@ description: |-
|
|
239
239
|
for monitoring and metrics collection.
|
240
240
|
email: "<sensu-users@googlegroups.com>"
|
241
241
|
executables:
|
242
|
+
- check-dcos-component-health.rb
|
242
243
|
- check-dcos-container-count.rb
|
243
244
|
- check-dcos-ping.rb
|
244
245
|
- check-dcos-metrics.rb
|
@@ -251,6 +252,7 @@ files:
|
|
251
252
|
- CHANGELOG.md
|
252
253
|
- LICENSE
|
253
254
|
- README.md
|
255
|
+
- bin/check-dcos-component-health.rb
|
254
256
|
- bin/check-dcos-container-count.rb
|
255
257
|
- bin/check-dcos-container-metrics.rb
|
256
258
|
- bin/check-dcos-metrics.rb
|