sensu-plugins-jolokia 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 ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 93058f4b727ddbce4388ba5d004d4e7b42b89611
4
+ data.tar.gz: 64f0bdc47f4b5feb49573c7776d08c7336a07fc3
5
+ SHA512:
6
+ metadata.gz: 13dde2f340aa993ed18718d50bc90e46c6516c8ca2cae2bf0e08c764eb8e06b1fbdc4971395240eb9b3a841a19770575de77792f2b003f8024ee023dfdff66db
7
+ data.tar.gz: 639208c3ee61437a54902f4784a6e9dedc590225715737de3403b4e3a495648411d428249a905ba6a1c95ce84c932230dfcbc3ef86352110bbb5964dee3fe7de
data/CHANGELOG.md ADDED
@@ -0,0 +1,6 @@
1
+ #Change Log
2
+ This project adheres to [Semantic Versioning](http://semver.org/).
3
+
4
+ ## 0.0.1 - 2016-08-09
5
+ ### Added
6
+ - Initial release
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2016 Sensu-Plugins
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,34 @@
1
+ ## sensu-plugins-jolokia
2
+
3
+ [![Build Status](https://travis-ci.org/smbambling/sensu-plugins-jolokia.svg?branch=master)](https://travis-ci.org/sensu-plugins/sensu-plugins-jolokia)
4
+ [![Gem Version](https://badge.fury.io/rb/sensu-plugins-jolokia.svg)](http://badge.fury.io/rb/sensu-plugins-jolokia)
5
+ [![Code Climate](https://codeclimate.com/github/smbambling/sensu-plugins-jolokia/badges/gpa.svg)](https://codeclimate.com/github/smbambling/sensu-plugins-jolokia)
6
+ [![Test Coverage](https://codeclimate.com/github/smbambling/sensu-plugins-jolokia/badges/coverage.svg)](https://codeclimate.com/github/smbambling/sensu-plugins-jolokia)
7
+ [![Dependency Status](https://gemnasium.com/smbambling/sensu-plugins-jolokia.svg)](https://gemnasium.com/smbambling/sensu-plugins-jolokia)
8
+
9
+ ## Functionality
10
+
11
+ **check-java-app-deployment**
12
+
13
+ Check current runtime status/deploymnet status of a application:
14
+ A deployment represents anything that can be deployed:
15
+ Such as EJB-JAR, WAR, EAR, any kind of standard archive such as RAR or JBoss-specific deployment)
16
+
17
+ **check-jvm-memory-pcnt**
18
+
19
+ Check the percentage of JVM HEAP or NonHEAP Memory against a warning/critical threshold
20
+
21
+ **check-joloki-key**
22
+
23
+ Check against a sepcified jolokia key and alert on a warning/critical threshold
24
+
25
+ ## Files
26
+ * check-java-app-deployment.rb
27
+ * check-jvm-memory-pcnt.rb
28
+ * check-jolokia-key.rb
29
+
30
+ ## Usage
31
+
32
+ ## Installation
33
+
34
+ [Installation and Setup](http://sensu-plugins.io/docs/installation_instructions.html)
@@ -0,0 +1,81 @@
1
+ #! /usr/bin/env ruby
2
+ require 'sensu-plugin/check/cli'
3
+ require 'jolokia'
4
+
5
+ # check-java-app-deployment
6
+ #
7
+ # DESCRIPTION: Check current runtime status/deploymnet status of a application:
8
+ # A deployment represents anything that can be deployed:
9
+ # Such as EJB-JAR, WAR, EAR, any kind of standard archive such as RAR or JBoss-specific deployment)
10
+ #
11
+ # OUTPUT:
12
+ # plain text
13
+ #
14
+ # Possible status modes are OK, FAILED, and STOPPED.
15
+ # FAILED indicates a dependency is missing or a service could not start.
16
+ # STOPPED indicates that the deployment was not enabled or was manually stopped."
17
+ #
18
+ # PLATFORMS:
19
+ # Linux
20
+ #
21
+ # DEPENDENCIES:
22
+ # gem: sensu-plugin
23
+ # gem: jolokia
24
+ #
25
+ # USAGE:
26
+ # Specify Usage (Options):
27
+ # ./check-java-app-deployment.rb -u http://localhost:8080/jolokia -a 'jolokia-war-agent.war'
28
+ #
29
+ # http://www.rubydoc.info/gems/jolokia/0.1.0
30
+ # *:type=Connector,*
31
+
32
+ class CheckJavaAppDeploymnet < Sensu::Plugin::Check::CLI
33
+ option :url,
34
+ description: 'URL of the Jolokia Agent to the constructor for creating the client',
35
+ short: '-u URL',
36
+ long: '--url URL',
37
+ default: 'http://localhost:8080/jolokia'
38
+
39
+ option :apps,
40
+ description: 'A comma seperated list of application paths to verify are in a OK state',
41
+ short: '-a VALUE',
42
+ long: '--applications VALUE',
43
+ required: true
44
+
45
+ def run
46
+ # Create an instance of Jolokia::Client to comunicate with the Jolokia Agent
47
+
48
+ jolokia = Jolokia.new(url: config[:url])
49
+
50
+ # Create array from apps option
51
+ apps = config[:apps].split(',')
52
+
53
+ # Empty array for app status
54
+ apps_with_errors = []
55
+
56
+ apps.each do
57
+ # Perform actions read or execute the operations of the MBeans
58
+ begin
59
+ jolokia_response = jolokia.request(
60
+ :post,
61
+ type: 'read',
62
+ mbean: "jboss.as:deployment=#{app}",
63
+ attribute: 'status'
64
+ )
65
+ rescue StandardError => e
66
+ puts ''
67
+ unknown e.message
68
+ end
69
+
70
+ unless jolokia_response['value'] == 'OK'
71
+ apps_with_errors << app
72
+ end
73
+ end
74
+
75
+ if apps_with_errors.any?
76
+ critical "The appliations #{apps_with_errors} are NOT deployed"
77
+ else
78
+ ok "The applications #{apps} are deployed"
79
+ end
80
+ end
81
+ end
@@ -0,0 +1,74 @@
1
+ #! /usr/bin/env ruby
2
+ require 'sensu-plugin/check/cli'
3
+ require 'jolokia'
4
+
5
+ # http://www.rubydoc.info/gems/jolokia/0.1.0
6
+ # *:type=Connector,*
7
+
8
+ class CheckJolokiaKey < Sensu::Plugin::Check::CLI
9
+ option :url,
10
+ description: 'URL of the Jolokia Agent to the constructor for creating the client',
11
+ short: '-u URL',
12
+ long: '--url URL',
13
+ default: 'http://localhost:8080/jolokia'
14
+
15
+ option :type,
16
+ description: 'Call type?',
17
+ short: '-t TYPE',
18
+ long: '--type TYPE',
19
+ default: 'read'
20
+
21
+ option :mbean,
22
+ description: 'MBean to execute operations against',
23
+ short: '-m MBEAN',
24
+ long: '--mbean MBEAN',
25
+ required: true
26
+
27
+ option :attribute,
28
+ description: 'MBean attribute name',
29
+ short: '-a ATTRIBUTE',
30
+ long: '--attribute ATTRIBUTE',
31
+ required: true
32
+
33
+ option :inner_key,
34
+ description: 'The inner "key" returned from a value',
35
+ short: '-i INNER_KEY',
36
+ long: '--inner_key INNER_KEY'
37
+
38
+ option :warn,
39
+ description: 'The warning value when comparing against a key',
40
+ short: '-w VALUE',
41
+ long: '--warning VALUE',
42
+ required: true
43
+
44
+ option :crit,
45
+ description: 'The critical value when comparigin against a key',
46
+ short: '-c VALUE',
47
+ long: '--critical VALUE',
48
+ required: true
49
+
50
+ def run
51
+ # Create an instance of Jolokia::Client to comunicate with the Jolokia Agent
52
+ jolokia = Jolokia.new(url: config[:url])
53
+
54
+ # Perform actions read or execute the operations of the MBeans
55
+ begin
56
+ jolokia_response = jolokia.request(
57
+ :post,
58
+ type: config[:type],
59
+ mbean: config[:mbean],
60
+ attribute: config[:attribute],
61
+ path: config[:inner_key]
62
+ )
63
+ rescue StandardError => e
64
+ puts ''
65
+ unknown e.message
66
+ end
67
+
68
+ if jolokia_response['value'].to_i > config[:crit].to_i
69
+ critical "#{config[:attribute]} #{config[:inner_key]} : #{jolokia_response['value']}"
70
+ elsif jolokia_response['value'].to_i > config[:warn].to_i
71
+ warning "#{config[:attribute]} #{config[:inner_key]} : #{jolokia_response['value']}"
72
+ end
73
+ end
74
+ end
@@ -0,0 +1,93 @@
1
+ #! /usr/bin/env ruby
2
+ require 'sensu-plugin/check/cli'
3
+ require 'jolokia'
4
+
5
+ # check-jvm-heap-pcnt
6
+ #
7
+ # DESCRIPTION: Check the percentage of Java JVM HEAP Memory:
8
+ #
9
+ # OUTPUT:
10
+ # plain text
11
+ #
12
+ # PLATFORMS:
13
+ # Linux
14
+ #
15
+ # DEPENDENCIES:
16
+ # gem: sensu-plugin
17
+ # gem: jolokia
18
+ #
19
+ # USAGE:
20
+ # Specify Usage (Options):
21
+ # ./check-jvm-heap-pcnt.rb -w 90 -c 95'
22
+ #
23
+ # http://www.rubydoc.info/gems/jolokia/0.1.0
24
+ # *:type=Connector,*
25
+
26
+ class CheckJvmMemoryPcnt < Sensu::Plugin::Check::CLI
27
+ option :url,
28
+ description: 'URL of the Jolokia Agent to the constructor for creating the client',
29
+ short: '-u URL',
30
+ long: '--url URL',
31
+ default: 'http://localhost:8080/jolokia'
32
+
33
+ option :type,
34
+ description: 'The type of memory [NonHeap/Heap] to query',
35
+ short: '-t VALUE',
36
+ long: '--type VALUE',
37
+ in: %w(heap nonheap),
38
+ required: true
39
+
40
+ option :warn,
41
+ description: 'The warning value when comparing against commited percent used',
42
+ short: '-w VALUE',
43
+ long: '--warning VALUE',
44
+ required: true
45
+
46
+ option :crit,
47
+ description: 'The critical value when comparing against commited percent used',
48
+ short: '-c VALUE',
49
+ long: '--critical VALUE',
50
+ required: true
51
+
52
+ def run
53
+ # Create an instance of Jolokia::Client to comunicate with the Jolokia Agent
54
+
55
+ jolokia = Jolokia.new(url: config[:url])
56
+
57
+ # Select the correct attribute to query based on the type option
58
+ if config[:type] == 'heap'
59
+ attr = 'HeapMemoryUsage'
60
+ elsif config[:type] == 'nonheap'
61
+ attr = 'NonHeapMemoryUsage'
62
+ else
63
+ unknown 'The type [-t/--type] option was not set use: < heap / nonheap >'
64
+ end
65
+
66
+ # Perform actions read or execute the operations of the MBeans
67
+ begin
68
+ jolokia_response = jolokia.request(
69
+ :post,
70
+ type: 'read',
71
+ mbean: 'java.lang:type=Memory',
72
+ attribute: attr.to_s
73
+ )
74
+ rescue StandardError => e
75
+ puts ''
76
+ unknown e.message
77
+ end
78
+
79
+ max = (jolokia_response['value']['max'])
80
+ committed = (jolokia_response['value']['committed'])
81
+ pct_committed = (committed.to_f / max.to_f * 100).to_i
82
+ used = (jolokia_response['value']['used'])
83
+ pct_used = (used.to_f / max.to_f * 100).to_i
84
+
85
+ if pct_committed > config[:crit].to_i
86
+ critical "Java #{config[:type].upcase} Memory: Committed #{pct_committed}%, Used #{pct_used}%"
87
+ elsif pct_committed > config[:warn].to_i
88
+ warning "Java #{config[:type].upcase} Memory: Committed #{pct_committed}%, Used #{pct_used}%"
89
+ else
90
+ ok "Java #{config[:type].upcase} Memory: Committed #{pct_committed}%, Used #{pct_used}%"
91
+ end
92
+ end
93
+ end
@@ -0,0 +1,9 @@
1
+ module SensuPluginsJolokia
2
+ module Version
3
+ MAJOR = 0
4
+ MINOR = 0
5
+ PATCH = 2
6
+
7
+ VER_STRING = [MAJOR, MINOR, PATCH].compact.join('.')
8
+ end
9
+ end
@@ -0,0 +1 @@
1
+ require 'sensu-plugins-jolokia/version'
metadata ADDED
@@ -0,0 +1,214 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: sensu-plugins-jolokia
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.2
5
+ platform: ruby
6
+ authors:
7
+ - Sensu-Plugins and contributors
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2016-08-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: sensu-plugin
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '1.2'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '1.2'
27
+ - !ruby/object:Gem::Dependency
28
+ name: jolokia
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 0.1.0
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 0.1.0
41
+ - !ruby/object:Gem::Dependency
42
+ name: bundler
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - "~>"
46
+ - !ruby/object:Gem::Version
47
+ version: '1.7'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - "~>"
53
+ - !ruby/object:Gem::Version
54
+ version: '1.7'
55
+ - !ruby/object:Gem::Dependency
56
+ name: codeclimate-test-reporter
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - "~>"
60
+ - !ruby/object:Gem::Version
61
+ version: '0.4'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - "~>"
67
+ - !ruby/object:Gem::Version
68
+ version: '0.4'
69
+ - !ruby/object:Gem::Dependency
70
+ name: github-markup
71
+ requirement: !ruby/object:Gem::Requirement
72
+ requirements:
73
+ - - "~>"
74
+ - !ruby/object:Gem::Version
75
+ version: '1.3'
76
+ type: :development
77
+ prerelease: false
78
+ version_requirements: !ruby/object:Gem::Requirement
79
+ requirements:
80
+ - - "~>"
81
+ - !ruby/object:Gem::Version
82
+ version: '1.3'
83
+ - !ruby/object:Gem::Dependency
84
+ name: pry
85
+ requirement: !ruby/object:Gem::Requirement
86
+ requirements:
87
+ - - "~>"
88
+ - !ruby/object:Gem::Version
89
+ version: '0.10'
90
+ type: :development
91
+ prerelease: false
92
+ version_requirements: !ruby/object:Gem::Requirement
93
+ requirements:
94
+ - - "~>"
95
+ - !ruby/object:Gem::Version
96
+ version: '0.10'
97
+ - !ruby/object:Gem::Dependency
98
+ name: rake
99
+ requirement: !ruby/object:Gem::Requirement
100
+ requirements:
101
+ - - "~>"
102
+ - !ruby/object:Gem::Version
103
+ version: '10.5'
104
+ type: :development
105
+ prerelease: false
106
+ version_requirements: !ruby/object:Gem::Requirement
107
+ requirements:
108
+ - - "~>"
109
+ - !ruby/object:Gem::Version
110
+ version: '10.5'
111
+ - !ruby/object:Gem::Dependency
112
+ name: redcarpet
113
+ requirement: !ruby/object:Gem::Requirement
114
+ requirements:
115
+ - - "~>"
116
+ - !ruby/object:Gem::Version
117
+ version: '3.2'
118
+ type: :development
119
+ prerelease: false
120
+ version_requirements: !ruby/object:Gem::Requirement
121
+ requirements:
122
+ - - "~>"
123
+ - !ruby/object:Gem::Version
124
+ version: '3.2'
125
+ - !ruby/object:Gem::Dependency
126
+ name: rubocop
127
+ requirement: !ruby/object:Gem::Requirement
128
+ requirements:
129
+ - - "~>"
130
+ - !ruby/object:Gem::Version
131
+ version: 0.40.0
132
+ type: :development
133
+ prerelease: false
134
+ version_requirements: !ruby/object:Gem::Requirement
135
+ requirements:
136
+ - - "~>"
137
+ - !ruby/object:Gem::Version
138
+ version: 0.40.0
139
+ - !ruby/object:Gem::Dependency
140
+ name: rspec
141
+ requirement: !ruby/object:Gem::Requirement
142
+ requirements:
143
+ - - "~>"
144
+ - !ruby/object:Gem::Version
145
+ version: '3.4'
146
+ type: :development
147
+ prerelease: false
148
+ version_requirements: !ruby/object:Gem::Requirement
149
+ requirements:
150
+ - - "~>"
151
+ - !ruby/object:Gem::Version
152
+ version: '3.4'
153
+ - !ruby/object:Gem::Dependency
154
+ name: yard
155
+ requirement: !ruby/object:Gem::Requirement
156
+ requirements:
157
+ - - "~>"
158
+ - !ruby/object:Gem::Version
159
+ version: '0.8'
160
+ type: :development
161
+ prerelease: false
162
+ version_requirements: !ruby/object:Gem::Requirement
163
+ requirements:
164
+ - - "~>"
165
+ - !ruby/object:Gem::Version
166
+ version: '0.8'
167
+ description: Sensu plugins for Jolokia
168
+ email: "<sensu-users@googlegroups.com>"
169
+ executables:
170
+ - check-java-app-deployment.rb
171
+ - check-joloika-key.rb
172
+ - check-jvm-memory-pcnt.rb
173
+ extensions: []
174
+ extra_rdoc_files: []
175
+ files:
176
+ - CHANGELOG.md
177
+ - LICENSE
178
+ - README.md
179
+ - bin/check-java-app-deployment.rb
180
+ - bin/check-joloika-key.rb
181
+ - bin/check-jvm-memory-pcnt.rb
182
+ - lib/sensu-plugins-jolokia.rb
183
+ - lib/sensu-plugins-jolokia/version.rb
184
+ homepage: https://github.com/sensu-plugins/sensu-plugins-jolokia
185
+ licenses:
186
+ - MIT
187
+ metadata:
188
+ maintainer: sensu-plugin
189
+ development_status: active
190
+ production_status: unstable - testing recommended
191
+ release_draft: 'false'
192
+ release_prerelease: 'false'
193
+ post_install_message: You can use the embedded Ruby by setting EMBEDDED_RUBY=true
194
+ in /etc/default/sensu
195
+ rdoc_options: []
196
+ require_paths:
197
+ - lib
198
+ required_ruby_version: !ruby/object:Gem::Requirement
199
+ requirements:
200
+ - - ">="
201
+ - !ruby/object:Gem::Version
202
+ version: 2.0.0
203
+ required_rubygems_version: !ruby/object:Gem::Requirement
204
+ requirements:
205
+ - - ">="
206
+ - !ruby/object:Gem::Version
207
+ version: '0'
208
+ requirements: []
209
+ rubyforge_project:
210
+ rubygems_version: 2.4.5.1
211
+ signing_key:
212
+ specification_version: 4
213
+ summary: Sensu plugins for jolokia
214
+ test_files: []