sensu-plugins-tomcat 0.1.1 → 0.2.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
- SHA1:
3
- metadata.gz: 30c3379221831241e30f59f1f3bae3a9628f72af
4
- data.tar.gz: 5c8044b42b0928eeef060da305c5bca12b5da71b
2
+ SHA256:
3
+ metadata.gz: 4c477350a971edfc09651df6c5f8afc7a3044a0ed92899c83a961901d43388d6
4
+ data.tar.gz: 7fb8697f83894e93747e5cadf5ca7f4e11ff24eb13f4b112c1c0454ad0e96f4b
5
5
  SHA512:
6
- metadata.gz: 8526341ec362f072f18908fec4f7d1d2a5e5ce9487e616ff651b73053871a8e76fb5892c02b2d43daf1d7eb301947a2e7bfed463b92d1fe7b447a094df981ee6
7
- data.tar.gz: c5e1c3593a210dbf7bf7ddc582ffb51e5ef7e3fad7491abb5c02e0bd38c6966e08d6a3c648ec64363d7be8fa78558b699407de128d433e589c72361980ab814a
6
+ metadata.gz: 5648422e52b2e4e90bf0884b933f42d7c850556824d7140dc8a09fd3c5ecf872055e14c574bfd33651bdeb459aa5a6f997e785bf83ad068b54a16445460b3822
7
+ data.tar.gz: fb8e7c320467b8f2f6b394012e37bb90279ed8d4692018e511bddeebf9c8cc2daa18d509db5b933f866f842a30cb46fe0d5d7ec4c5e24688b778b567ff1e4a92
@@ -1,7 +1,17 @@
1
- #Change Log
1
+ # Change Log
2
2
  This project adheres to [Semantic Versioning](http://semver.org/).
3
3
 
4
+ This CHANGELOG follows the format listed [here](https://github.com/sensu-plugins/community/blob/master/HOW_WE_CHANGELOG.md)
5
+
4
6
  ## Unreleased
7
+
8
+ ## [0.2.0] - 2017-12-22
9
+ ### Added
10
+ - metrics-tomcat-jmxproxy.rb: Support querying metrics from the jmxproxy servlet (@luyseyal)
11
+
12
+ ### Changed
13
+ - updated changelog gudelines and PR templates (@majormoses)
14
+
5
15
  ## [0.1.1] 2017-06
6
16
  ### Fixed
7
17
  - Corrected long option value for passwords - from "passowrd" to "password"
@@ -17,5 +27,6 @@ This project adheres to [Semantic Versioning](http://semver.org/).
17
27
  ### Added
18
28
  - Initial release
19
29
 
20
- [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-tomcat/compare/0.1.1...HEAD
30
+ [Unreleased]: https://github.com/sensu-plugins/sensu-plugins-tomcat/compare/0.2.0...HEAD
31
+ [0.2.0]: https://github.com/sensu-plugins/sensu-plugins-tomcat/compare/0.1.1...0.2.0
21
32
  [0.1.1]: https://github.com/sensu-plugins/sensu-plugins-tomcat/compare/0.1.0...0.1.1
data/README.md CHANGED
@@ -16,9 +16,14 @@ Check current runtime status/deploymnet status of a application:
16
16
 
17
17
  Check the percentage of JVM Memory
18
18
 
19
+ **metrics-tomcat-jmxproxy**
20
+
21
+ Return value of JMX attribute to Graphite via Tomcat's JMXProxy
22
+
19
23
  ## Files
20
24
  * check-tomcat-app-deployment.rb
21
25
  * check-tomcat-heap-pcnt.rb
26
+ * metrics-tomcat-jmxproxy.rb
22
27
 
23
28
  ## Usage
24
29
 
@@ -0,0 +1,138 @@
1
+ #! /usr/bin/env ruby
2
+ #
3
+ # metrics-tomcat-jmxproxy
4
+ #
5
+ # DESCRIPTION:
6
+ # Return value of JMX attribute to Graphite via Tomcat's JMXProxy
7
+ #
8
+ # OUTPUT:
9
+ # plain text
10
+ #
11
+ # PLATFORMS:
12
+ # Linux
13
+ #
14
+ # DEPENDENCIES:
15
+ # gem: addressable
16
+ # gem: sensu-plugin
17
+ # gem: unirest
18
+ #
19
+ # USAGE:
20
+ # Basic Usage:
21
+ # ./metrics-tomcat-jmxproxy.rb
22
+ # --url http://localhost:8080
23
+ # --account admin
24
+ # --password password
25
+ # --bean 'java.lang:type=MemoryPool,name=Compressed Class Space'
26
+ # --attribute PeakUsage
27
+ # --key used
28
+ # --scheme my.scheme
29
+ #
30
+ # my.scheme.PeakUsage.used 2523848 1513887865
31
+ #
32
+ # NOTES:
33
+ #
34
+ # See http://localhost:8080/docs/manager-howto.html for security information
35
+
36
+ require 'addressable/uri'
37
+ require 'sensu-plugin/metric/cli'
38
+ require 'unirest'
39
+
40
+ class MetricsTomcatJMXProxy < Sensu::Plugin::Metric::CLI::Graphite
41
+ option :url,
42
+ description: 'URL of the Tomcat Manager',
43
+ short: '-u URL',
44
+ long: '--url URL',
45
+ required: true
46
+
47
+ option :account,
48
+ description: 'Username of the Tomcat User that has the manager-jmx role',
49
+ short: '-a USERNAME',
50
+ long: '--account USERNAME',
51
+ required: true
52
+
53
+ option :password,
54
+ description: 'Tomcat User password',
55
+ short: '-p PASSWORD',
56
+ long: '--password PASSWORD',
57
+ required: true
58
+
59
+ option :bean,
60
+ description: 'Full name of the MBean to query',
61
+ short: '-b VALUE',
62
+ long: '--bean VALUE',
63
+ required: true
64
+
65
+ option :attribute,
66
+ description: 'MBean attribute to return. Default metric name',
67
+ short: '-l VALUE',
68
+ long: '--attribute VALUE',
69
+ required: true
70
+
71
+ option :attrkey,
72
+ description: 'Key of a CompositeData MBean attribute. Optional',
73
+ short: '-k VALUE',
74
+ long: '--key VALUE',
75
+ required: false
76
+
77
+ option :scheme,
78
+ description: 'Metric naming scheme. Defaults to hostname',
79
+ short: '-s SCHEME',
80
+ long: '--scheme SCHEME',
81
+ default: Socket.gethostname.to_s
82
+
83
+ option :metric,
84
+ description: 'Override attribute name metric',
85
+ short: '-M METRIC',
86
+ long: '--metric METRIC',
87
+ required: false
88
+
89
+ option :timeout,
90
+ description: 'HTTP request timeout in seconds. Default: 5',
91
+ short: '-T TIMEOUT',
92
+ long: '--timeout TIMEOUT',
93
+ default: 5,
94
+ required: false
95
+
96
+ def run
97
+ uri = Addressable::URI.parse("#{config[:url]}/manager/jmxproxy?get=#{config[:bean]}&att=#{config[:attribute]}")
98
+ fq_metric = config[:scheme] + '.' + (config[:metric] || config[:attribute])
99
+
100
+ if config[:attrkey]
101
+ uri.query += "&key=#{config[:attrkey]}"
102
+ fq_metric += '.' + config[:attrkey].to_s
103
+ end
104
+
105
+ uri.normalize!
106
+ fq_metric.downcase!
107
+
108
+ # Fetch attribute from Tomcat
109
+ Unirest.timeout(config[:timeout])
110
+ response = Unirest.get uri.to_s, auth: { user: @config[:account].to_s, password: @config[:password].to_s }
111
+
112
+ if response.code != 200
113
+ critical "Failed to obtain response from Tomcat\n"\
114
+ "HTTP Response Code: #{response.code}\n"\
115
+ "URL: #{uri}\n"
116
+ else
117
+ # Supported formats:
118
+ # OK - Attribute get 'java.lang:type=Memory' - Verbose = false
119
+ # OK - Attribute get 'java.lang:type=Memory' - HeapMemoryUsage - key 'used' = 1234
120
+ # Error - Error message here\nstacktrace\nstacktrace\n...
121
+ #
122
+ # FIXME support CompositeData
123
+ # OK - Attribute get 'java.lang:type=Memory' - HeapMemoryUsage = javax.management.openmbean.CompositeDataSupport(...)
124
+
125
+ fields = response.raw_body.split(' - ')
126
+
127
+ if fields[0] != 'OK'
128
+ trunc_error = fields[1].split("\n")
129
+ critical "#{fields[0]} #{trunc_error[0].chomp}"
130
+ end
131
+
132
+ output(fq_metric, fields[-1].split(' = ', 2)[1].chomp)
133
+ ok
134
+ end
135
+ rescue Errno::ECONNREFUSED
136
+ critical "Could not connect to Tomcat on #{config[:url]}"
137
+ end
138
+ end
@@ -1,8 +1,8 @@
1
1
  module SensuPluginsTomcat
2
2
  module Version
3
3
  MAJOR = 0
4
- MINOR = 1
5
- PATCH = 1
4
+ MINOR = 2
5
+ PATCH = 0
6
6
 
7
7
  VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
8
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: sensu-plugins-tomcat
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.1
4
+ version: 0.2.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Sensu-Plugins and contributors
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2017-06-05 00:00:00.000000000 Z
11
+ date: 2017-12-22 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: sensu-plugin
@@ -25,19 +25,19 @@ dependencies:
25
25
  - !ruby/object:Gem::Version
26
26
  version: '1.2'
27
27
  - !ruby/object:Gem::Dependency
28
- name: unirest
28
+ name: addressable
29
29
  requirement: !ruby/object:Gem::Requirement
30
30
  requirements:
31
- - - '='
31
+ - - "~>"
32
32
  - !ruby/object:Gem::Version
33
- version: 1.1.2
33
+ version: 2.3.8
34
34
  type: :runtime
35
35
  prerelease: false
36
36
  version_requirements: !ruby/object:Gem::Requirement
37
37
  requirements:
38
- - - '='
38
+ - - "~>"
39
39
  - !ruby/object:Gem::Version
40
- version: 1.1.2
40
+ version: 2.3.8
41
41
  - !ruby/object:Gem::Dependency
42
42
  name: crack
43
43
  requirement: !ruby/object:Gem::Requirement
@@ -53,33 +53,33 @@ dependencies:
53
53
  - !ruby/object:Gem::Version
54
54
  version: 0.4.3
55
55
  - !ruby/object:Gem::Dependency
56
- name: bundler
56
+ name: unirest
57
57
  requirement: !ruby/object:Gem::Requirement
58
58
  requirements:
59
- - - "~>"
59
+ - - '='
60
60
  - !ruby/object:Gem::Version
61
- version: '1.7'
62
- type: :development
61
+ version: 1.1.2
62
+ type: :runtime
63
63
  prerelease: false
64
64
  version_requirements: !ruby/object:Gem::Requirement
65
65
  requirements:
66
- - - "~>"
66
+ - - '='
67
67
  - !ruby/object:Gem::Version
68
- version: '1.7'
68
+ version: 1.1.2
69
69
  - !ruby/object:Gem::Dependency
70
- name: codeclimate-test-reporter
70
+ name: bundler
71
71
  requirement: !ruby/object:Gem::Requirement
72
72
  requirements:
73
73
  - - "~>"
74
74
  - !ruby/object:Gem::Version
75
- version: '0.4'
75
+ version: '1.7'
76
76
  type: :development
77
77
  prerelease: false
78
78
  version_requirements: !ruby/object:Gem::Requirement
79
79
  requirements:
80
80
  - - "~>"
81
81
  - !ruby/object:Gem::Version
82
- version: '0.4'
82
+ version: '1.7'
83
83
  - !ruby/object:Gem::Dependency
84
84
  name: github-markup
85
85
  requirement: !ruby/object:Gem::Requirement
@@ -164,6 +164,20 @@ dependencies:
164
164
  - - "~>"
165
165
  - !ruby/object:Gem::Version
166
166
  version: '3.4'
167
+ - !ruby/object:Gem::Dependency
168
+ name: simplecov
169
+ requirement: !ruby/object:Gem::Requirement
170
+ requirements:
171
+ - - "~>"
172
+ - !ruby/object:Gem::Version
173
+ version: 0.15.1
174
+ type: :development
175
+ prerelease: false
176
+ version_requirements: !ruby/object:Gem::Requirement
177
+ requirements:
178
+ - - "~>"
179
+ - !ruby/object:Gem::Version
180
+ version: 0.15.1
167
181
  - !ruby/object:Gem::Dependency
168
182
  name: yard
169
183
  requirement: !ruby/object:Gem::Requirement
@@ -183,6 +197,7 @@ email: "<sensu-users@googlegroups.com>"
183
197
  executables:
184
198
  - check-tomcat-app-deployment.rb
185
199
  - check-tomcat-heap-pcnt.rb
200
+ - metrics-tomcat-jmxproxy.rb
186
201
  extensions: []
187
202
  extra_rdoc_files: []
188
203
  files:
@@ -191,6 +206,7 @@ files:
191
206
  - README.md
192
207
  - bin/check-tomcat-app-deployment.rb
193
208
  - bin/check-tomcat-heap-pcnt.rb
209
+ - bin/metrics-tomcat-jmxproxy.rb
194
210
  - lib/sensu-plugins-tomcat.rb
195
211
  - lib/sensu-plugins-tomcat/version.rb
196
212
  homepage: https://github.com/sensu-plugins/sensu-plugins-tomcat
@@ -219,7 +235,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
219
235
  version: '0'
220
236
  requirements: []
221
237
  rubyforge_project:
222
- rubygems_version: 2.4.5
238
+ rubygems_version: 2.7.3
223
239
  signing_key:
224
240
  specification_version: 4
225
241
  summary: Sensu plugins for tomcat