Skip to content

Commit 036caf6

Browse files
Yuri Zubovmajormoses
authored andcommitted
Added VertX health check and metrics
1 parent 95d52b3 commit 036caf6

16 files changed

Lines changed: 1333 additions & 17 deletions

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,3 +16,4 @@ mkmf.log
1616
.DS_Store
1717
.idea/*
1818
*.gem
19+
.ruby-version

.rubocop.yml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,3 +28,11 @@ RegexpLiteral:
2828

2929
Style/Documentation:
3030
Enabled: false
31+
32+
Style/FrozenStringLiteralComment:
33+
Enabled: false
34+
35+
Metrics/BlockLength:
36+
Exclude:
37+
- 'test/**/*.rb'
38+
- 'sensu-plugins-java.gemspec'

.travis.yml

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ cache:
44
install:
55
- bundle install
66
rvm:
7-
- 2.0
87
- 2.1
98
- 2.2
109
- 2.3.0
@@ -27,7 +26,6 @@ deploy:
2726
on:
2827
tags: true
2928
all_branches: true
30-
rvm: 2.0
3129
rvm: 2.1
3230
rvm: 2.2
3331
rvm: 2.3.0

CHANGELOG.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,17 @@ This project adheres to [Semantic Versioning](http://semver.org/).
44
This CHANGELOG follows the format listed at [Keep A Changelog](http://keepachangelog.com/)
55

66
## [Unreleased]
7+
### Breaking Changes
8+
- dropped ruby 2.1 support (@yuri-zubov sponsored by Actility, https://www.actility.com)
9+
- added `rest-client` as a dependency which requires you to have a local c compiler present to install this plugin (@yuri-zubov sponsored by Actility, https://www.actility.com)
10+
11+
### Security
12+
- updated yard dependency to `~> 0.9.11` per: https://nvd.nist.gov/vuln/detail/CVE-2017-17042 (@yuri-zubov sponsored by Actility, https://www.actility.com)
13+
- updated rubocop dependency to `~> 0.51.0` per: https://cve.mitre.org/cgi-bin/cvename.cgi?name=CVE-2017-8418. (@yuri-zubov sponsored by Actility, https://www.actility.com)
14+
15+
### Added
16+
- Added ability to get metrics from VertX (@yuri-zubov sponsored by Actility, https://www.actility.com)
17+
- Added health-check VertX (@yuri-zubov sponsored by Actility, https://www.actility.com)
718

819
## [1.3.0] - 2017-09-05
920
### Added

Rakefile

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,9 @@ require 'yard'
77
require 'yard/rake/yardoc_task'
88

99
YARD::Rake::YardocTask.new do |t|
10-
OTHER_PATHS = %w().freeze
10+
OTHER_PATHS = %w[].freeze
1111
t.files = ['lib/**/*.rb', 'bin/**/*.rb', OTHER_PATHS]
12-
t.options = %w(--markup-provider=redcarpet --markup=markdown --main=README.md --files CHANGELOG.md)
12+
t.options = %w[--markup-provider=redcarpet --markup=markdown --main=README.md --files CHANGELOG.md]
1313
end
1414

1515
RuboCop::RakeTask.new
@@ -35,4 +35,4 @@ task :check_binstubs do
3535
end
3636
end
3737

38-
task default: [:spec, :make_bin_executable, :yard, :rubocop, :check_binstubs]
38+
task default: %i[spec make_bin_executable yard rubocop check_binstubs]

bin/check-java-heap-pcnt.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env ruby
22

3-
bin_dir = File.expand_path(File.dirname(__FILE__))
4-
shell_script_path = File.join(bin_dir, File.basename($PROGRAM_NAME, '.rb') + '.sh')
3+
shell_script_path = File.join(__dir__, File.basename($PROGRAM_NAME, '.rb') + '.sh')
54

65
exec shell_script_path, *ARGV

bin/check-vertx-health.rb

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
#! /usr/bin/env ruby
2+
#
3+
# check-vertx-health
4+
#
5+
# DESCRIPTION:
6+
# check-vertx-health simple way to expose health checks for VertX
7+
#
8+
# OUTPUT:
9+
# plain text
10+
#
11+
# PLATFORMS:
12+
# Linux
13+
#
14+
# DEPENDENCIES:
15+
# gem: rest-client
16+
#
17+
#
18+
# USAGE:
19+
#
20+
#
21+
# NOTES:
22+
#
23+
# LICENSE:
24+
# Zubov Yuri <yury.zubau@gmail.com> sponsored by Actility, https://www.actility.com
25+
# Released under the same terms as Sensu (the MIT license); see LICENSE
26+
# for details.
27+
#
28+
require 'sensu-plugin/check/cli'
29+
require 'rest-client'
30+
require 'json'
31+
32+
class CheckVertXHealth < Sensu::Plugin::Check::CLI
33+
include CommonVertX
34+
35+
option :endpoint,
36+
short: '-p ENDPOINT',
37+
long: '--endpointn ENDPOINT',
38+
description: 'VertX Endpoint',
39+
default: 'http://localhost:8080/rest/health'
40+
41+
def check_health
42+
response = request
43+
44+
result = JSON.parse(response)
45+
result['outcome']
46+
end
47+
48+
def run
49+
result = check_health
50+
51+
if result == 'UP'
52+
ok 'VertX is UP'
53+
elsif result == 'DOWN'
54+
warning 'VertX is DOWN'
55+
end
56+
rescue StandardError => e
57+
critical e.message
58+
end
59+
end

bin/metrics-java-heap-graphite.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env ruby
22

3-
bin_dir = File.expand_path(File.dirname(__FILE__))
4-
shell_script_path = File.join(bin_dir, File.basename($PROGRAM_NAME, '.rb') + '.sh')
3+
shell_script_path = File.join(__dir__, File.basename($PROGRAM_NAME, '.rb') + '.sh')
54

65
exec shell_script_path, *ARGV

bin/metrics-jstat.rb

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#!/usr/bin/env ruby
22

3-
bin_dir = File.expand_path(File.dirname(__FILE__))
4-
shell_script_path = File.join(bin_dir, File.basename($PROGRAM_NAME, '.rb') + '.py')
3+
shell_script_path = File.join(__dir__, File.basename($PROGRAM_NAME, '.rb') + '.py')
54

65
exec shell_script_path, *ARGV

bin/metrics-vertx.rb

Lines changed: 61 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,61 @@
1+
#! /usr/bin/env ruby
2+
#
3+
# metrics-vertx
4+
#
5+
# DESCRIPTION:
6+
# metrics-vertx get metrics from VertX
7+
#
8+
# OUTPUT:
9+
# metric-data
10+
#
11+
# PLATFORMS:
12+
# Linux
13+
#
14+
# DEPENDENCIES:
15+
# gem: rest-clien
16+
#
17+
# USAGE:
18+
#
19+
#
20+
# NOTES:
21+
#
22+
# LICENSE:
23+
# Zubov Yuri <yury.zubau@gmail.com> sponsored by Actility, https://www.actility.com
24+
# Released under the same terms as Sensu (the MIT license); see LICENSE
25+
# for details.
26+
#
27+
28+
require 'sensu-plugin/metric/cli'
29+
require 'rest-client'
30+
require 'json'
31+
32+
class MetricsVertX < Sensu::Plugin::Metric::CLI::Graphite
33+
include CommonVertX
34+
35+
option :endpoint,
36+
short: '-p ENDPOINT',
37+
long: '--endpointn ENDPOINT',
38+
description: 'VertX Endpoint',
39+
default: 'http://localhost:8080/rest/metrics'
40+
41+
option :scheme,
42+
description: 'Metric naming scheme, text to prepend to metric',
43+
short: '-S SCHEME',
44+
long: '--scheme SCHEME',
45+
default: "#{Socket.gethostname}.vertx"
46+
47+
def metrics
48+
response = request
49+
JSON.parse(response)
50+
end
51+
52+
def run
53+
metrics.each do |key, metrics|
54+
type_of_metric = metrics.delete('type')
55+
metrics.each do |metric_name, value|
56+
output("#{config[:scheme]}.#{key}.#{type_of_metric}.#{metric_name}", value)
57+
end
58+
end
59+
ok
60+
end
61+
end

0 commit comments

Comments
 (0)