rboss 0.3.1 → 0.4.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/bin/twiddle +15 -66
- data/lib/rboss.rb +2 -0
- data/lib/rboss/bin/command_actions.rb +107 -0
- data/lib/rboss/twiddle.rb +1 -0
- data/lib/rboss/twiddle/monitor.rb +8 -1
- data/lib/rboss/version.rb +1 -1
- data/rboss.gemspec +1 -1
- metadata +24 -31
data/bin/twiddle
CHANGED
@@ -32,7 +32,8 @@ params = {}
|
|
32
32
|
mbeans = {}
|
33
33
|
commands = {}
|
34
34
|
no_details = false
|
35
|
-
|
35
|
+
@conf_dir = File.expand_path "~/.rboss"
|
36
|
+
servers_file = "#{@conf_dir}/twiddle.yaml"
|
36
37
|
@servers_file = File.expand_path(servers_file)
|
37
38
|
save = false
|
38
39
|
params[:jboss_home] = (ENV["JBOSS_HOME"] or ENV["TWIDDLE_HOME"] or Dir.pwd)
|
@@ -132,16 +133,18 @@ end
|
|
132
133
|
opts.on('-p', '--password PASSWORD', 'Defines the JMX Password') do |password|
|
133
134
|
params[:password] = password
|
134
135
|
end
|
136
|
+
opts.on('-n COMMAND', '--native COMMAND', 'Executes the given command as is') do |command|
|
137
|
+
commands[:native] = command
|
138
|
+
end
|
135
139
|
opts.on('-v', '--verbose', 'Shows the twiddle commands before execution') do
|
136
140
|
params[:log_level] = Logger::DEBUG
|
137
141
|
end
|
138
142
|
opts.on("-h", "--help", "Shows this help message") do
|
139
143
|
puts opts; exit
|
140
144
|
end
|
141
|
-
opts.parse!(ARGV) rescue abort 'Invalid Option! Use --help or -h for usage help.'
|
145
|
+
opts.parse!(ARGV) #rescue abort 'Invalid Option! Use --help or -h for usage help.'
|
142
146
|
|
143
|
-
twiddle = JBoss::Twiddle::Invoker::new params
|
144
|
-
monitor = twiddle.monitor
|
147
|
+
@twiddle = JBoss::Twiddle::Invoker::new params
|
145
148
|
|
146
149
|
if save
|
147
150
|
config = load_yaml
|
@@ -151,7 +154,7 @@ if save
|
|
151
154
|
params.each do |key, value|
|
152
155
|
server_config[key.to_s] = value
|
153
156
|
end
|
154
|
-
FileUtils::mkdir_p File.expand_path(
|
157
|
+
FileUtils::mkdir_p File.expand_path(@conf_dir)
|
155
158
|
FileUtils::touch @servers_file
|
156
159
|
f = File.open(@servers_file, 'w')
|
157
160
|
YAML::dump(config, f)
|
@@ -173,65 +176,11 @@ end
|
|
173
176
|
|
174
177
|
puts opts if mbeans.empty? and commands.empty?
|
175
178
|
|
176
|
-
|
177
|
-
|
178
|
-
|
179
|
-
|
180
|
-
|
181
|
-
|
182
|
-
|
183
|
-
:value => array[2]
|
184
|
-
end
|
185
|
-
if commands[:get]
|
186
|
-
array = commands[:get]
|
187
|
-
raise "Wrong number of arguments" if array.size != 2
|
188
|
-
mbean, name = extract array[0]
|
189
|
-
puts twiddle.get :mbean => mbean.to_sym,
|
190
|
-
:name => name,
|
191
|
-
:property => array[1]
|
192
|
-
end
|
193
|
-
if commands[:invoke]
|
194
|
-
array = commands[:invoke]
|
195
|
-
raise "Wrong number of arguments" if array.size < 2
|
196
|
-
mbean, name = extract array[0]
|
197
|
-
puts twiddle.invoke :mbean => mbean.to_sym,
|
198
|
-
:name => name,
|
199
|
-
:method => array[1],
|
200
|
-
:args => normalize(array[2..-1])
|
201
|
-
end
|
202
|
-
if commands[:query]
|
203
|
-
array = commands[:query]
|
204
|
-
mbean, name = extract array[0]
|
205
|
-
puts twiddle.query :mbean => mbean.to_sym,
|
206
|
-
:name => name,
|
207
|
-
:args => normalize(array[1..-1])
|
208
|
-
end
|
209
|
-
|
210
|
-
if commands[:info]
|
211
|
-
array = commands[:info]
|
212
|
-
mbean, name = extract array[0]
|
213
|
-
puts twiddle.info :mbean => mbean.to_sym,
|
214
|
-
:name => name,
|
215
|
-
:args => normalize(array[1..-1])
|
216
|
-
end
|
217
|
-
|
218
|
-
mbeans.each do |mbean_id, resources|
|
219
|
-
puts " - #{defaults[mbean_id][:description]}"
|
220
|
-
if resources.is_a? TrueClass
|
221
|
-
monitor.mbean(mbean_id).detail do |name, value|
|
222
|
-
puts " - #{name}=#{value}"
|
223
|
-
end
|
224
|
-
elsif no_details
|
225
|
-
monitor.mbean(mbean_id).scan.each do |name|
|
226
|
-
puts " - #{name}"
|
227
|
-
end
|
228
|
-
else
|
229
|
-
monitor.mbean(mbean_id).detail resources do |resource, detail|
|
230
|
-
puts " - #{resource}"
|
231
|
-
detail.each do |name, value|
|
232
|
-
puts " - #{name}=#{value}"
|
233
|
-
end
|
234
|
-
end
|
235
|
-
end
|
236
|
-
end
|
179
|
+
actions = JBoss::CommandActions::Twiddle::new @twiddle,
|
180
|
+
:no_details => no_details,
|
181
|
+
:mbeans => defaults
|
182
|
+
|
183
|
+
actions.parse_and_execute commands
|
184
|
+
|
185
|
+
actions.detail mbeans
|
237
186
|
|
data/lib/rboss.rb
CHANGED
@@ -0,0 +1,107 @@
|
|
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
|
+
module JBoss
|
24
|
+
module CommandActions
|
25
|
+
class Twiddle
|
26
|
+
|
27
|
+
def initialize twiddle, opts = {}
|
28
|
+
@monitor = twiddle.monitor
|
29
|
+
@twiddle = twiddle
|
30
|
+
@opts = opts
|
31
|
+
end
|
32
|
+
|
33
|
+
def parse_and_execute commands
|
34
|
+
commands.each do |method, args|
|
35
|
+
send method, *args
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
def native command
|
40
|
+
puts @twiddle.execute(command)
|
41
|
+
end
|
42
|
+
|
43
|
+
def set id, property, value
|
44
|
+
mbean, name = extract id
|
45
|
+
puts @twiddle.set :mbean => mbean.to_sym,
|
46
|
+
:name => name,
|
47
|
+
:property => property,
|
48
|
+
:value => value
|
49
|
+
end
|
50
|
+
|
51
|
+
def get id, property
|
52
|
+
mbean, name = extract id
|
53
|
+
puts @twiddle.get :mbean => mbean.to_sym,
|
54
|
+
:name => name,
|
55
|
+
:property => property
|
56
|
+
end
|
57
|
+
|
58
|
+
def invoke id, method, *args
|
59
|
+
mbean, name = extract id
|
60
|
+
puts @twiddle.invoke :mbean => mbean.to_sym,
|
61
|
+
:name => name,
|
62
|
+
:method => method,
|
63
|
+
:args => normalize(args)
|
64
|
+
end
|
65
|
+
|
66
|
+
def query id, *args
|
67
|
+
mbean, name = extract id
|
68
|
+
puts @twiddle.query :mbean => mbean.to_sym,
|
69
|
+
:name => name,
|
70
|
+
:args => normalize(args)
|
71
|
+
end
|
72
|
+
|
73
|
+
def info id, *args
|
74
|
+
mbean, name = extract id
|
75
|
+
puts @twiddle.info :mbean => mbean.to_sym,
|
76
|
+
:name => name,
|
77
|
+
:args => normalize(args)
|
78
|
+
end
|
79
|
+
|
80
|
+
def detail mbeans
|
81
|
+
mbeans.each do |mbean_id, resources|
|
82
|
+
puts " - #{@opts[:mbeans][mbean_id][:description]}"
|
83
|
+
if resources.is_a? TrueClass
|
84
|
+
@monitor.mbean(mbean_id).detail do |name, value|
|
85
|
+
puts " - #{name}=#{value}"
|
86
|
+
end
|
87
|
+
elsif @opts[:no_details]
|
88
|
+
@monitor.mbean(mbean_id).scan.each do |name|
|
89
|
+
puts " - #{name}"
|
90
|
+
end
|
91
|
+
else
|
92
|
+
@monitor.mbean(mbean_id).detail resources do |resource, detail|
|
93
|
+
puts " - #{resource}"
|
94
|
+
detail.each do |name, value|
|
95
|
+
puts " - #{name}=#{value}"
|
96
|
+
end
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
end
|
103
|
+
|
104
|
+
end
|
105
|
+
|
106
|
+
end
|
107
|
+
|
data/lib/rboss/twiddle.rb
CHANGED
@@ -32,7 +32,8 @@ module JBoss
|
|
32
32
|
:webapp => {
|
33
33
|
:description => 'Deployed webapps',
|
34
34
|
:pattern => 'jboss.web:type=Manager,host=localhost,path=/#{resource}',
|
35
|
-
:properties => %W(activeSessions maxActive
|
35
|
+
:properties => %W(activeSessions maxActive distributable maxActiveSessions
|
36
|
+
expiredSessions rejectedSessions),
|
36
37
|
:scan => proc do
|
37
38
|
query "jboss.web:type=Manager,*" do |path|
|
38
39
|
path.gsub! "jboss.web:type=Manager,path=/", ""
|
@@ -127,6 +128,10 @@ module JBoss
|
|
127
128
|
end
|
128
129
|
end
|
129
130
|
},
|
131
|
+
:jndi => {
|
132
|
+
:description => 'JNDI View',
|
133
|
+
:pattern => 'jboss:service=JNDIView'
|
134
|
+
},
|
130
135
|
:ejb => {
|
131
136
|
:description => 'EJB',
|
132
137
|
:pattern => 'jboss.j2ee:#{resource},service=EJB3',
|
@@ -157,6 +162,7 @@ module JBoss
|
|
157
162
|
|
158
163
|
def mbean mbean_id
|
159
164
|
mbean = mbeans[mbean_id]
|
165
|
+
return JBoss::MBean::new :pattern => mbean_id.to_s, :twiddle => @twiddle unless mbean
|
160
166
|
if @current_resource
|
161
167
|
mbean.with @current_resource
|
162
168
|
end
|
@@ -168,3 +174,4 @@ module JBoss
|
|
168
174
|
end
|
169
175
|
|
170
176
|
end
|
177
|
+
|
data/lib/rboss/version.rb
CHANGED
data/rboss.gemspec
CHANGED
@@ -10,7 +10,7 @@ Gem::Specification.new do |s|
|
|
10
10
|
s.homepage = "https://github.com/ataxexe/rboss"
|
11
11
|
s.summary = %q{A Ruby way to do a JBoss work!}
|
12
12
|
s.description = %q{A tool to create profiles for JBoss Application Server and use
|
13
|
-
twiddle to
|
13
|
+
twiddle to manage a running JBoss AS.}
|
14
14
|
|
15
15
|
s.rubyforge_project = "rboss"
|
16
16
|
|
metadata
CHANGED
@@ -1,31 +1,26 @@
|
|
1
|
-
--- !ruby/object:Gem::Specification
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
2
|
name: rboss
|
3
|
-
version: !ruby/object:Gem::Version
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.4.1
|
4
5
|
prerelease:
|
5
|
-
version: 0.3.1
|
6
6
|
platform: ruby
|
7
|
-
authors:
|
7
|
+
authors:
|
8
8
|
- Ataxexe
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
|
13
|
-
date: 2011-09-29 00:00:00 Z
|
12
|
+
date: 2012-03-21 00:00:00.000000000Z
|
14
13
|
dependencies: []
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
twiddle to scan a running JBoss AS or execute scripts.
|
19
|
-
email:
|
14
|
+
description: ! "A tool to create profiles for JBoss Application Server and use\n twiddle
|
15
|
+
to manage a running JBoss AS."
|
16
|
+
email:
|
20
17
|
- ataxexe@gmail.com
|
21
|
-
executables:
|
18
|
+
executables:
|
22
19
|
- jboss-profile
|
23
20
|
- twiddle
|
24
21
|
extensions: []
|
25
|
-
|
26
22
|
extra_rdoc_files: []
|
27
|
-
|
28
|
-
files:
|
23
|
+
files:
|
29
24
|
- .gitignore
|
30
25
|
- Gemfile
|
31
26
|
- README.md
|
@@ -33,6 +28,7 @@ files:
|
|
33
28
|
- bin/jboss-profile
|
34
29
|
- bin/twiddle
|
35
30
|
- lib/rboss.rb
|
31
|
+
- lib/rboss/bin/command_actions.rb
|
36
32
|
- lib/rboss/component_processor.rb
|
37
33
|
- lib/rboss/components/component.rb
|
38
34
|
- lib/rboss/components/datasource.rb
|
@@ -77,32 +73,29 @@ files:
|
|
77
73
|
- test/test_suite.rb
|
78
74
|
homepage: https://github.com/ataxexe/rboss
|
79
75
|
licenses: []
|
80
|
-
|
81
76
|
post_install_message:
|
82
77
|
rdoc_options: []
|
83
|
-
|
84
|
-
require_paths:
|
78
|
+
require_paths:
|
85
79
|
- lib
|
86
|
-
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
87
81
|
none: false
|
88
|
-
requirements:
|
89
|
-
- -
|
90
|
-
- !ruby/object:Gem::Version
|
91
|
-
version:
|
92
|
-
required_rubygems_version: !ruby/object:Gem::Requirement
|
82
|
+
requirements:
|
83
|
+
- - ! '>='
|
84
|
+
- !ruby/object:Gem::Version
|
85
|
+
version: '0'
|
86
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
93
87
|
none: false
|
94
|
-
requirements:
|
95
|
-
- -
|
96
|
-
- !ruby/object:Gem::Version
|
97
|
-
version:
|
88
|
+
requirements:
|
89
|
+
- - ! '>='
|
90
|
+
- !ruby/object:Gem::Version
|
91
|
+
version: '0'
|
98
92
|
requirements: []
|
99
|
-
|
100
93
|
rubyforge_project: rboss
|
101
|
-
rubygems_version: 1.8.
|
94
|
+
rubygems_version: 1.8.10
|
102
95
|
signing_key:
|
103
96
|
specification_version: 3
|
104
97
|
summary: A Ruby way to do a JBoss work!
|
105
|
-
test_files:
|
98
|
+
test_files:
|
106
99
|
- test/datasource_test.rb
|
107
100
|
- test/deploy_folder_test.rb
|
108
101
|
- test/jbossweb_test.rb
|