rboss 0.2.0 → 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.
- data/README.md +3 -3
- data/bin/twiddle +74 -170
- data/lib/rboss/twiddle/base_monitor.rb +1 -2
- data/lib/rboss/twiddle/mbean.rb +59 -5
- data/lib/rboss/twiddle/monitor.rb +74 -12
- data/lib/rboss/twiddle/twiddle.rb +3 -1
- data/lib/rboss/version.rb +1 -1
- metadata +2 -3
- data/lib/rboss/twiddle/scanner.rb +0 -92
data/README.md
CHANGED
@@ -21,16 +21,16 @@ Simply do a "cd" to your JBoss Home and use it
|
|
21
21
|
|
22
22
|
You can scan resources like: datasources, queues, connectors, webapps, ...
|
23
23
|
|
24
|
-
twiddle --
|
24
|
+
twiddle --datasource --webapp
|
25
25
|
twiddle --all
|
26
26
|
|
27
27
|
If you don't need to scan for resources, you can specify them for monitoring:
|
28
28
|
|
29
|
-
twiddle --
|
29
|
+
twiddle --webapp jmx-console,admin-console
|
30
30
|
|
31
31
|
Combine with "watch" to get a simple and instantly monitoring:
|
32
32
|
|
33
|
-
watch --interval=1 twiddle --
|
33
|
+
watch --interval=1 twiddle --webapp jmx-console,admin-console
|
34
34
|
|
35
35
|
Retrieve property values with --get:
|
36
36
|
|
data/bin/twiddle
CHANGED
@@ -22,95 +22,84 @@
|
|
22
22
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
23
|
# THE SOFTWARE.
|
24
24
|
|
25
|
-
|
25
|
+
require_relative '../lib/rboss'
|
26
26
|
require 'optparse'
|
27
27
|
require 'yaml'
|
28
28
|
|
29
29
|
params = {}
|
30
|
-
|
31
|
-
|
30
|
+
mbeans = {}
|
31
|
+
commands = {}
|
32
|
+
no_details = false
|
32
33
|
params[:jboss_home] = Dir.pwd unless ENV["JBOSS_HOME"]
|
33
34
|
exec_file = nil
|
34
|
-
|
35
|
+
defaults = JBoss::Twiddle::Monitor::defaults
|
35
36
|
|
36
37
|
opts = OptionParser::new
|
37
38
|
opts.on('-j', '--jboss-home PATH', 'Defines the JBOSS_HOME variable') do |home|
|
38
39
|
params[:jboss_home] = home
|
39
40
|
end
|
40
|
-
opts.on('-s', '--
|
41
|
+
opts.on('-s', '--server URL', 'Defines the JBoss server') do |server|
|
41
42
|
params[:jboss_server] = server
|
42
43
|
end
|
43
|
-
opts.on('--
|
44
|
+
opts.on('--host HOST', 'Defines the JBoss host') do |host|
|
44
45
|
params[:jboss_host] = host
|
45
46
|
end
|
46
|
-
opts.on('--
|
47
|
+
opts.on('--port PORT', 'Defines the JBoss jnp port') do |port|
|
47
48
|
params[:jboss_port] = port
|
48
49
|
end
|
49
50
|
opts.on('-e', '--exec-file PATH',
|
50
51
|
'Defines the ruby file to exec using the vars twiddle and monitor') do |path|
|
51
52
|
exec_file = File.expand_path path
|
52
53
|
end
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
:datasources,
|
62
|
-
:webapps,
|
63
|
-
:connectors,
|
64
|
-
:queues,
|
65
|
-
:ejbs
|
66
|
-
].each do |option|
|
67
|
-
resources[option] = :all
|
54
|
+
|
55
|
+
opts.on('--all', "Detail all mapped mbeans") do
|
56
|
+
defaults.each do |mbean_id, mbean|
|
57
|
+
if mbean[:scan]
|
58
|
+
mbeans[mbean_id] = :all
|
59
|
+
elsif mbean[:detail]
|
60
|
+
mbeans[mbean_id] = true
|
61
|
+
end
|
68
62
|
end
|
69
63
|
end
|
70
|
-
|
71
|
-
|
72
|
-
|
73
|
-
|
74
|
-
|
75
|
-
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
|
81
|
-
|
82
|
-
|
83
|
-
end
|
84
|
-
opts.on('--ejbs [name_a, name_b, name_c, ...]', Array,
|
85
|
-
'Defines the EJBs to show or scan if not specified') do |ejbs|
|
86
|
-
resources[:ejbs] = ejbs || :all
|
87
|
-
end
|
88
|
-
opts.on('--queues [name_a, name_b, name_c, ...]', Array,
|
89
|
-
'Defines the JMS queues to show or scan if not specified') do |queues|
|
90
|
-
resources[:queues] = queues || :all
|
91
|
-
end
|
92
|
-
opts.on('--webapps [name_a, name_b, name_c, ...]', Array,
|
93
|
-
'Defines the webapps to show or scan if not specified') do |webapps|
|
94
|
-
resources[:webapps] = webapps || :all
|
95
|
-
end
|
96
|
-
opts.on('--system-properties [name_a, name_b, name_c, ...]', Array,
|
97
|
-
'Defines the System properties to show or scan if not specified') do |properties|
|
98
|
-
resources[:system_properties] = properties || :all
|
64
|
+
|
65
|
+
defaults.each do |mbean_id, mbean|
|
66
|
+
command = mbean_id.to_s.gsub /_/, '-'
|
67
|
+
if mbean[:scan]
|
68
|
+
opts.on("--#{command} [name_a,name_b,...]", Array,
|
69
|
+
"Detail this mbeam based on the given names (no names for scan)") do |names|
|
70
|
+
mbeans[mbean_id] = names || :all
|
71
|
+
end
|
72
|
+
elsif mbean[:detail]
|
73
|
+
opts.on("--#{command}", "Detail this mbeam") do
|
74
|
+
mbeans[mbean_id] = true
|
75
|
+
end
|
76
|
+
end
|
99
77
|
end
|
100
|
-
|
78
|
+
|
79
|
+
opts.on('--set mbean_id[:resource_name],property,value', Array,
|
101
80
|
'Sets a value to a resource that the monitor knows') do |set|
|
102
|
-
|
81
|
+
commands[:set] = set
|
103
82
|
end
|
104
|
-
opts.on('--get
|
83
|
+
opts.on('--get mbean_id[:resource_name],property', Array,
|
105
84
|
'Gets a value to a resource that the monitor knows') do |get|
|
106
|
-
|
85
|
+
commands[:get] = get
|
107
86
|
end
|
108
|
-
opts.on('--invoke
|
87
|
+
opts.on('--invoke mbean_id[:resource_name],method,[,args...]', Array,
|
109
88
|
'Invokes a resoruce method') do |invoke|
|
110
|
-
|
89
|
+
commands[:invoke] = invoke
|
111
90
|
end
|
112
|
-
opts.on(
|
113
|
-
|
91
|
+
opts.on("-l", "--list", "List the mbeans mappings") do
|
92
|
+
defaults.each do |mbean_id, mbean|
|
93
|
+
puts " - #{mbean_id}"
|
94
|
+
[:description, :pattern].each do |detail|
|
95
|
+
puts " - #{detail} : #{mbean[detail]}"
|
96
|
+
end
|
97
|
+
puts
|
98
|
+
end
|
99
|
+
exit
|
100
|
+
end
|
101
|
+
opts.on('--no-detail', 'Do not detail mbeans that needs a name') do
|
102
|
+
no_details = true
|
114
103
|
end
|
115
104
|
opts.on('-u', '--jmx-user USER', 'Defines the JMX User') do |user|
|
116
105
|
params[:jmx_user] = user
|
@@ -126,38 +115,36 @@ opts.parse!(ARGV) rescue abort 'Invalid Option! Use --help or -h for usage help.
|
|
126
115
|
twiddle = JBoss::Twiddle::Invoker::new params
|
127
116
|
monitor = twiddle.monitor
|
128
117
|
|
129
|
-
if
|
118
|
+
if mbeans.empty? and commands.empty? and not exec_file
|
130
119
|
puts opts
|
131
120
|
exit
|
132
121
|
end
|
133
122
|
|
134
123
|
eval File.read(exec_file), binding, exec_file if exec_file
|
135
124
|
|
136
|
-
puts (eval eval_expression, binding) if eval_expression
|
137
|
-
|
138
125
|
def extract resource
|
139
126
|
mbean, name = resource.split(/:/)
|
140
127
|
end
|
141
128
|
|
142
|
-
if
|
143
|
-
array =
|
129
|
+
if commands[:set]
|
130
|
+
array = commands[:set]
|
144
131
|
raise "Wrong number of arguments" if array.size != 3
|
145
132
|
mbean, name = extract array[0]
|
146
133
|
puts twiddle.set :mbean => mbean.to_sym,
|
147
|
-
|
148
|
-
|
149
|
-
|
134
|
+
:name => name,
|
135
|
+
:property => array[1],
|
136
|
+
:value => array[2]
|
150
137
|
end
|
151
|
-
if
|
152
|
-
array =
|
138
|
+
if commands[:get]
|
139
|
+
array = commands[:get]
|
153
140
|
raise "Wrong number of arguments" if array.size != 2
|
154
141
|
mbean, name = extract array[0]
|
155
142
|
puts twiddle.get :mbean => mbean.to_sym,
|
156
143
|
:name => name,
|
157
144
|
:property => array[1]
|
158
145
|
end
|
159
|
-
if
|
160
|
-
array =
|
146
|
+
if commands[:invoke]
|
147
|
+
array = commands[:invoke]
|
161
148
|
raise "Wrong number of arguments" if array.size < 2
|
162
149
|
mbean, name = extract array[0]
|
163
150
|
puts twiddle.invoke :mbean => mbean.to_sym,
|
@@ -166,108 +153,25 @@ if resources[:invoke]
|
|
166
153
|
:args => array[2..-1]
|
167
154
|
end
|
168
155
|
|
169
|
-
|
170
|
-
puts "
|
171
|
-
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
puts " - #{monitor.server_info[property]}"
|
176
|
-
end
|
177
|
-
end
|
178
|
-
if resources[:system_properties]
|
179
|
-
puts "System Properties:"
|
180
|
-
properties = resources[:system_properties]
|
181
|
-
if properties == :all
|
182
|
-
properties = monitor.system_properties.showAll
|
183
|
-
puts properties
|
184
|
-
else
|
185
|
-
properties.each do |property|
|
186
|
-
puts " - #{property}=#{monitor.system_properties.get(property)}"
|
187
|
-
end
|
188
|
-
end
|
189
|
-
end
|
190
|
-
if resources[:deployments]
|
191
|
-
puts "Deployments:"
|
192
|
-
monitor.deployments.each do |deployment|
|
193
|
-
puts " - #{deployment}"
|
194
|
-
end
|
195
|
-
end
|
196
|
-
if resources[:connectors]
|
197
|
-
puts "Connectors:"
|
198
|
-
connectors = resources[:connectors]
|
199
|
-
connectors = monitor.connectors if connectors == :all
|
200
|
-
connectors.each do |connector|
|
201
|
-
monitor.with connector do
|
202
|
-
puts " - #{connector}"
|
203
|
-
unless list_only
|
204
|
-
monitor.properties[:connector].each do |property|
|
205
|
-
puts " - #{monitor.connector[property]}"
|
206
|
-
end
|
207
|
-
monitor.properties[:request].each do |property|
|
208
|
-
puts " - #{monitor.request[property]}"
|
209
|
-
end
|
210
|
-
end
|
156
|
+
mbeans.each do |mbean_id, resources|
|
157
|
+
puts " - #{defaults[mbean_id][:description]}"
|
158
|
+
if resources.is_a? TrueClass
|
159
|
+
details = monitor.mbean(mbean_id).detail
|
160
|
+
details.each do |name, value|
|
161
|
+
puts " - #{name}=#{value}"
|
211
162
|
end
|
212
|
-
|
213
|
-
|
214
|
-
|
215
|
-
puts "Datasources:"
|
216
|
-
datasources = resources[:datasources]
|
217
|
-
datasources = monitor.datasources if datasources == :all
|
218
|
-
datasources.each do |datasource|
|
219
|
-
monitor.with datasource do
|
220
|
-
puts " - #{datasource}"
|
221
|
-
unless list_only
|
222
|
-
monitor.properties[:datasource].each do |property|
|
223
|
-
puts " - #{monitor.datasource[property]}"
|
224
|
-
end
|
225
|
-
end
|
163
|
+
elsif no_details
|
164
|
+
monitor.mbean(mbean_id).scan.each do |name|
|
165
|
+
puts " - #{name}"
|
226
166
|
end
|
227
|
-
|
228
|
-
|
229
|
-
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
webapps.each do |webapp|
|
234
|
-
monitor.with webapp do
|
235
|
-
puts " - #{webapp}"
|
236
|
-
unless list_only
|
237
|
-
monitor.properties[:webapp].each do |property|
|
238
|
-
puts " - #{monitor.webapp[property]}"
|
239
|
-
end
|
240
|
-
end
|
241
|
-
end
|
242
|
-
end
|
243
|
-
end
|
244
|
-
if resources[:ejbs]
|
245
|
-
puts "EJBs:"
|
246
|
-
ejbs = resources[:ejbs]
|
247
|
-
ejbs = monitor.ejbs if ejbs == :all
|
248
|
-
ejbs.each do |ejb|
|
249
|
-
monitor.with ejb do
|
250
|
-
puts " - #{ejb}"
|
251
|
-
unless list_only
|
252
|
-
monitor.properties[:ejb].each do |property|
|
253
|
-
puts " - #{monitor.ejb[property]}"
|
254
|
-
end
|
255
|
-
end
|
256
|
-
end
|
257
|
-
end
|
258
|
-
end
|
259
|
-
if resources[:queues]
|
260
|
-
puts "Queues:"
|
261
|
-
queues = resources[:queues]
|
262
|
-
queues = monitor.queues if queues == :all
|
263
|
-
queues.each do |queue|
|
264
|
-
monitor.with queue do
|
265
|
-
puts " - #{queue}"
|
266
|
-
unless list_only
|
267
|
-
monitor.properties[:queue].each do |property|
|
268
|
-
puts " - #{monitor.queue[property]}"
|
269
|
-
end
|
167
|
+
else
|
168
|
+
details = monitor.mbean(mbean_id).detail resources
|
169
|
+
details.each do |resource, detail|
|
170
|
+
puts " - #{resource}"
|
171
|
+
detail.each do |name, value|
|
172
|
+
puts " - #{name}=#{value}"
|
270
173
|
end
|
271
174
|
end
|
272
175
|
end
|
273
176
|
end
|
177
|
+
|
@@ -21,14 +21,13 @@
|
|
21
21
|
# THE SOFTWARE.
|
22
22
|
|
23
23
|
require_relative 'monitor'
|
24
|
-
require_relative 'scanner'
|
25
24
|
require_relative 'twiddle'
|
26
25
|
|
27
26
|
module JBoss
|
28
27
|
module Twiddle
|
29
28
|
|
30
29
|
class BaseMonitor
|
31
|
-
include JBoss::Twiddle::Monitor
|
30
|
+
include JBoss::Twiddle::Monitor
|
32
31
|
|
33
32
|
def initialize twiddle
|
34
33
|
@twiddle = twiddle
|
data/lib/rboss/twiddle/mbean.rb
CHANGED
@@ -26,12 +26,50 @@ module JBoss
|
|
26
26
|
class MBean
|
27
27
|
|
28
28
|
attr_reader :pattern
|
29
|
-
attr_accessor :resource, :twiddle
|
29
|
+
attr_accessor :resource, :twiddle, :description
|
30
|
+
|
31
|
+
@@__default__detail__resource__ = proc do |resources|
|
32
|
+
resouces = _parse_resource_ resources
|
33
|
+
details = {}
|
34
|
+
resouces.each do |resource|
|
35
|
+
with resource do
|
36
|
+
details[resource] = {}
|
37
|
+
@properties.each do |property|
|
38
|
+
details[resource][property] = self[property].value
|
39
|
+
end
|
40
|
+
end
|
41
|
+
end
|
42
|
+
details
|
43
|
+
end
|
44
|
+
|
45
|
+
@@__default__detail__ = proc do
|
46
|
+
details = {}
|
47
|
+
@properties.each do |property|
|
48
|
+
details[property] = self[property].value
|
49
|
+
end
|
50
|
+
details
|
51
|
+
end
|
30
52
|
|
31
53
|
def initialize params
|
32
54
|
@pattern = params[:pattern]
|
33
55
|
@twiddle = params[:twiddle]
|
34
|
-
@
|
56
|
+
@properties = params[:properties]
|
57
|
+
@description = params[:description]
|
58
|
+
if params[:scan]
|
59
|
+
(class << self
|
60
|
+
self
|
61
|
+
end).send :define_method, :scan, ¶ms[:scan]
|
62
|
+
end
|
63
|
+
if params[:detail]
|
64
|
+
(class << self
|
65
|
+
self
|
66
|
+
end).send :define_method,
|
67
|
+
:detail,
|
68
|
+
&(params[:detail].is_a?(TrueClass) ?
|
69
|
+
(params[:scan] ?
|
70
|
+
@@__default__detail__resource__ : @@__default__detail__)
|
71
|
+
: params[:detail])
|
72
|
+
end
|
35
73
|
end
|
36
74
|
|
37
75
|
def with resource
|
@@ -43,20 +81,24 @@ module JBoss
|
|
43
81
|
self
|
44
82
|
end
|
45
83
|
|
84
|
+
def resourced?
|
85
|
+
@pattern['#{resource}']
|
86
|
+
end
|
87
|
+
|
46
88
|
def [] property
|
47
89
|
resource = @resource
|
48
|
-
env = @env
|
49
90
|
query = eval("\"#{pattern}\"")
|
50
91
|
result = @twiddle.execute(:get, query, property)
|
92
|
+
|
51
93
|
def result.value
|
52
94
|
self.split(/=/)[1]
|
53
95
|
end
|
96
|
+
|
54
97
|
result
|
55
98
|
end
|
56
99
|
|
57
100
|
def []= property, value
|
58
101
|
resource = @resource
|
59
|
-
env = @env
|
60
102
|
query = eval("\"#{pattern}\"")
|
61
103
|
@twiddle.execute :set, query, property, value
|
62
104
|
end
|
@@ -67,7 +109,6 @@ module JBoss
|
|
67
109
|
|
68
110
|
def _invoke_ method, *args, &block
|
69
111
|
resource = @resource
|
70
|
-
env = @env
|
71
112
|
query = eval("\"#{pattern} #{method}\"")
|
72
113
|
return_value = @twiddle.execute :invoke, query, args
|
73
114
|
if block_given?
|
@@ -76,6 +117,19 @@ module JBoss
|
|
76
117
|
return_value
|
77
118
|
end
|
78
119
|
|
120
|
+
def _query_ query, &block
|
121
|
+
result = @twiddle.execute(:query, query)
|
122
|
+
return [] unless result
|
123
|
+
result = result.split /\s+/
|
124
|
+
block ? result.collect(&block) : result
|
125
|
+
end
|
126
|
+
|
127
|
+
def _parse_resource_ resources
|
128
|
+
return scan if resources == :all
|
129
|
+
return [resources] unless resources.respond_to? :each
|
130
|
+
resources
|
131
|
+
end
|
132
|
+
|
79
133
|
end
|
80
134
|
|
81
135
|
end
|
@@ -28,50 +28,113 @@ module JBoss
|
|
28
28
|
module Monitor
|
29
29
|
|
30
30
|
def defaults
|
31
|
-
{
|
31
|
+
@defaults ||= {
|
32
32
|
:webapp => {
|
33
|
+
:description => 'Deployed webapps',
|
33
34
|
:pattern => 'jboss.web:type=Manager,host=localhost,path=/#{resource}',
|
34
|
-
:properties => %W(activeSessions maxActive)
|
35
|
+
:properties => %W(activeSessions maxActive),
|
36
|
+
:scan => proc do
|
37
|
+
_query_ "jboss.web:type=Manager,*" do |path|
|
38
|
+
path.gsub! "jboss.web:type=Manager,path=/", ""
|
39
|
+
path.gsub! /,host=.+/, ''
|
40
|
+
path
|
41
|
+
end
|
42
|
+
end,
|
43
|
+
:detail => true
|
35
44
|
},
|
36
45
|
:web_deployment => {
|
46
|
+
:description => 'Deployed webapp control',
|
37
47
|
:pattern => 'jboss.web.deployment:war=/#{resource}'
|
38
48
|
},
|
39
49
|
:connector => {
|
50
|
+
:description => 'JBossWeb connector',
|
40
51
|
:pattern => 'jboss.web:type=ThreadPool,name=#{resource}',
|
41
|
-
:properties => %W(maxThreads currentThreadCount currentThreadsBusy)
|
52
|
+
:properties => %W(maxThreads currentThreadCount currentThreadsBusy),
|
53
|
+
:scan => proc do
|
54
|
+
_query_ "jboss.web:type=ThreadPool,*" do |path|
|
55
|
+
path.gsub "jboss.web:type=ThreadPool,name=", ""
|
56
|
+
end
|
57
|
+
end,
|
58
|
+
:detail => true
|
59
|
+
},
|
60
|
+
:engine => {
|
61
|
+
:description => 'JBossWeb engine',
|
62
|
+
:pattern => 'jboss.web:type=Engine',
|
63
|
+
:properties => %W(jvmRoute name defaultHost),
|
64
|
+
:detail => true
|
42
65
|
},
|
43
66
|
:server_info => {
|
67
|
+
:description => 'JBoss running info',
|
44
68
|
:pattern => 'jboss.system:type=ServerInfo',
|
45
69
|
:properties => %W(ActiveThreadCount MaxMemory FreeMemory AvailableProcessors
|
46
|
-
HostAddress JavaVendor JavaVersion OSName OSArch)
|
70
|
+
HostAddress JavaVendor JavaVersion OSName OSArch),
|
71
|
+
:detail => true
|
47
72
|
},
|
48
73
|
:server => {
|
74
|
+
:description => 'JBoss specifications',
|
49
75
|
:pattern => 'jboss.system:type=Server',
|
50
|
-
:properties => %W(VersionNumber StartDate)
|
76
|
+
:properties => %W(VersionNumber StartDate),
|
77
|
+
:detail => true
|
51
78
|
},
|
52
79
|
:system_properties => {
|
80
|
+
:description => 'System properties',
|
53
81
|
:pattern => 'jboss:name=SystemProperties,type=Service'
|
54
82
|
},
|
55
83
|
:request => {
|
84
|
+
:description => 'JBossWeb connector requests',
|
56
85
|
:pattern => 'jboss.web:type=GlobalRequestProcessor,name=#{resource}',
|
57
|
-
:properties => %W(requestCount errorCount maxTime)
|
86
|
+
:properties => %W(requestCount errorCount maxTime),
|
87
|
+
:scan => proc do
|
88
|
+
_query_ "jboss.web:type=ThreadPool,*" do |path|
|
89
|
+
path.gsub "jboss.web:type=ThreadPool,name=", ""
|
90
|
+
end
|
91
|
+
end,
|
92
|
+
:detail => true
|
58
93
|
},
|
59
94
|
:datasource => {
|
95
|
+
:description => 'Datasource',
|
60
96
|
:pattern => 'jboss.jca:service=ManagedConnectionPool,name=#{resource}',
|
61
|
-
:properties => %W(MinSize MaxSize AvailableConnectionCount
|
97
|
+
:properties => %W(MinSize MaxSize AvailableConnectionCount
|
98
|
+
InUseConnectionCount ConnectionCount),
|
99
|
+
:scan => proc do
|
100
|
+
_query_ "jboss.jca:service=ManagedConnectionPool,*" do |path|
|
101
|
+
path.gsub "jboss.jca:service=ManagedConnectionPool,name=", ""
|
102
|
+
end
|
103
|
+
end,
|
104
|
+
:detail => true
|
62
105
|
},
|
63
106
|
:queue => {
|
107
|
+
:description => 'JMS Queue',
|
64
108
|
:pattern => 'jboss.messaging.destination:service=Queue,name=#{resource}',
|
65
109
|
:properties => %W(Name JNDIName MessageCount DeliveringCount
|
66
|
-
ScheduledMessageCount MaxSize FullSize Clustered ConsumerCount)
|
110
|
+
ScheduledMessageCount MaxSize FullSize Clustered ConsumerCount),
|
111
|
+
:scan => proc do
|
112
|
+
_query_ "jboss.messaging.destination:service=Queue,*" do |path|
|
113
|
+
path.gsub "jboss.messaging.destination:service=Queue,name=", ""
|
114
|
+
end
|
115
|
+
end,
|
116
|
+
:detail => true
|
67
117
|
},
|
68
118
|
:ejb => {
|
119
|
+
:description => 'EJB',
|
69
120
|
:pattern => 'jboss.j2ee:#{resource},service=EJB3',
|
70
|
-
:properties => %W(CreateCount RemoveCount CurrentSize AvailableCount)
|
121
|
+
:properties => %W(CreateCount RemoveCount CurrentSize AvailableCount),
|
122
|
+
:scan => proc do
|
123
|
+
result = _query_ "jboss.j2ee:*"
|
124
|
+
(result.find_all do |path|
|
125
|
+
path["service=EJB3"] && path["name="] && path["jar="]
|
126
|
+
end).collect do |path|
|
127
|
+
path.gsub("jboss.j2ee:", '').gsub(/,?service=EJB3/, '')
|
128
|
+
end
|
129
|
+
end,
|
130
|
+
:detail => true
|
71
131
|
}
|
72
132
|
}
|
133
|
+
@defaults
|
73
134
|
end
|
74
135
|
|
136
|
+
module_function :defaults
|
137
|
+
|
75
138
|
def properties mbean_id = nil
|
76
139
|
@properties ||= {}
|
77
140
|
return properties[mbean_id] if mbean_id
|
@@ -97,8 +160,7 @@ module JBoss
|
|
97
160
|
end
|
98
161
|
|
99
162
|
def monitor mbean_id, params
|
100
|
-
mbeans[mbean_id] = JBoss::MBean::new
|
101
|
-
properties[mbean_id] = params[:properties]
|
163
|
+
mbeans[mbean_id] = JBoss::MBean::new params.merge(:twiddle => @twiddle)
|
102
164
|
end
|
103
165
|
|
104
166
|
def with resource
|
@@ -126,7 +188,7 @@ module JBoss
|
|
126
188
|
mbean
|
127
189
|
end
|
128
190
|
|
129
|
-
def method_missing
|
191
|
+
def method_missing method, *args, &block
|
130
192
|
mbean_id = method
|
131
193
|
mbean = mbeans[mbean_id]
|
132
194
|
resource = args[0] || @current_resource
|
data/lib/rboss/version.rb
CHANGED
metadata
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
name: rboss
|
3
3
|
version: !ruby/object:Gem::Version
|
4
4
|
prerelease:
|
5
|
-
version: 0.2.
|
5
|
+
version: 0.2.1
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
8
8
|
- Ataxexe
|
@@ -10,7 +10,7 @@ autorequire:
|
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
12
|
|
13
|
-
date: 2011-08-
|
13
|
+
date: 2011-08-19 00:00:00 Z
|
14
14
|
dependencies: []
|
15
15
|
|
16
16
|
description: |-
|
@@ -67,7 +67,6 @@ files:
|
|
67
67
|
- lib/rboss/twiddle/base_monitor.rb
|
68
68
|
- lib/rboss/twiddle/mbean.rb
|
69
69
|
- lib/rboss/twiddle/monitor.rb
|
70
|
-
- lib/rboss/twiddle/scanner.rb
|
71
70
|
- lib/rboss/twiddle/twiddle.rb
|
72
71
|
- lib/rboss/utils.rb
|
73
72
|
- lib/rboss/version.rb
|
@@ -1,92 +0,0 @@
|
|
1
|
-
# The MIT License
|
2
|
-
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
4
|
-
#
|
5
|
-
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
|
-
# of this software and associated documentation files (the "Software"), to deal
|
7
|
-
# in the Software without restriction, including without limitation the rights
|
8
|
-
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
9
|
-
# copies of the Software, and to permit persons to whom the Software is
|
10
|
-
# furnished to do so, subject to the following conditions:
|
11
|
-
#
|
12
|
-
# The above copyright notice and this permission notice shall be included in
|
13
|
-
# all copies or substantial portions of the Software.
|
14
|
-
#
|
15
|
-
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
-
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
17
|
-
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
18
|
-
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
19
|
-
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
20
|
-
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
|
-
# THE SOFTWARE.
|
22
|
-
|
23
|
-
require "set"
|
24
|
-
|
25
|
-
module JBoss
|
26
|
-
module Twiddle
|
27
|
-
module Scanner
|
28
|
-
|
29
|
-
def webapps
|
30
|
-
_query_ "jboss.web:type=Manager,*" do |path|
|
31
|
-
path.gsub! "jboss.web:type=Manager,path=/", ""
|
32
|
-
path.gsub! /,host=.+/, ''
|
33
|
-
path
|
34
|
-
end
|
35
|
-
end
|
36
|
-
|
37
|
-
def datasources
|
38
|
-
_query_ "jboss.jca:service=ManagedConnectionPool,*" do |path|
|
39
|
-
path.gsub "jboss.jca:service=ManagedConnectionPool,name=", ""
|
40
|
-
end
|
41
|
-
end
|
42
|
-
|
43
|
-
def connectors
|
44
|
-
_query_ "jboss.web:type=ThreadPool,*" do |path|
|
45
|
-
path.gsub "jboss.web:type=ThreadPool,name=", ""
|
46
|
-
end
|
47
|
-
end
|
48
|
-
|
49
|
-
def queues
|
50
|
-
_query_ "jboss.messaging.destination:service=Queue,*" do |path|
|
51
|
-
path.gsub "jboss.messaging.destination:service=Queue,name=", ""
|
52
|
-
end
|
53
|
-
end
|
54
|
-
|
55
|
-
def ejbs
|
56
|
-
result = _query_ "jboss.j2ee:service=EJB3,*"
|
57
|
-
(result.find_all {|path| path["name="] && path["jar="]}).collect do |path|
|
58
|
-
path.gsub("jboss.j2ee:", '').gsub(/,?service=EJB3/, '')
|
59
|
-
end
|
60
|
-
end
|
61
|
-
|
62
|
-
def deployments
|
63
|
-
wars = _query_ "jboss.web.deployment:*" do |path|
|
64
|
-
path.gsub("jboss.web.deployment:", "").split(/,/).find {|p| p.start_with? "war="}
|
65
|
-
end
|
66
|
-
ears = _query_ "jboss.j2ee:*"
|
67
|
-
ears = (ears.find_all {|path| path["ear="] && path["jar="]}).collect do |path|
|
68
|
-
path.gsub("jboss.j2ee:",'').split(/,/).find {|p| p.start_with? "ear="}
|
69
|
-
end
|
70
|
-
result = Set::new
|
71
|
-
(wars + ears).each do |deployment|
|
72
|
-
result << deployment
|
73
|
-
end
|
74
|
-
result
|
75
|
-
end
|
76
|
-
|
77
|
-
def can_scan? resource
|
78
|
-
self.respond_to? resource.to_sym
|
79
|
-
end
|
80
|
-
|
81
|
-
private
|
82
|
-
|
83
|
-
def _query_ query, &block
|
84
|
-
result = @twiddle.execute(:query, query)
|
85
|
-
return [] if result["No MBean matches for query"]
|
86
|
-
result = result.split /\s+/
|
87
|
-
block ? result.collect(&block) : result
|
88
|
-
end
|
89
|
-
|
90
|
-
end
|
91
|
-
end
|
92
|
-
end
|