rboss 0.1.0 → 0.2.0

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 ADDED
@@ -0,0 +1,197 @@
1
+ rboss
2
+ =============
3
+
4
+ Use this tool to create profiles for JBoss Application Server and use twiddle to scan
5
+ a running JBoss AS or execute scripts.
6
+
7
+
8
+ Installation
9
+ -----------
10
+
11
+ gem install rboss
12
+
13
+ Using twiddle
14
+ -----------
15
+
16
+ ### Basics
17
+
18
+ Simply do a "cd" to your JBoss Home and use it
19
+
20
+ twiddle --help
21
+
22
+ You can scan resources like: datasources, queues, connectors, webapps, ...
23
+
24
+ twiddle --datasources --webapps
25
+ twiddle --all
26
+
27
+ If you don't need to scan for resources, you can specify them for monitoring:
28
+
29
+ twiddle --webapps jmx-console,admin-console
30
+
31
+ Combine with "watch" to get a simple and instantly monitoring:
32
+
33
+ watch --interval=1 twiddle --webapps jmx-console,admin-console
34
+
35
+ Retrieve property values with --get:
36
+
37
+ twiddle --get webapp:jmx-console,maxSessions
38
+ twiddle --get server_info,FreeMemory
39
+
40
+ Set values with --set:
41
+
42
+ twiddle --set connector:http-127.0.0.1-8080,maxThreads,350
43
+
44
+ Execute commands with --invoke:
45
+
46
+ twiddle --invoke server,shutdown
47
+ twiddle --invoke web_deployment:jmx-console,stop
48
+
49
+ Using jboss-profile
50
+ -----------
51
+
52
+ ### Basics
53
+
54
+ Simply do a "cd" to your JBoss Home and use it
55
+
56
+ jboss-profile --help
57
+
58
+ All configuration can be stored in a single yaml file containing an array of components
59
+ and its configuration:
60
+
61
+ - deploy_folder: deploy/datasources
62
+ - deploy_folder: deploy/apps
63
+ - jmx
64
+ - run_conf:
65
+ :heap_size: 1024m
66
+ :perm_size: 512m
67
+ :debug: :socket
68
+
69
+ You can specify any command-line arguments directly in yaml file:
70
+
71
+ - :params:
72
+ :jboss_home: /home/user/jboss/org/jboss-5
73
+ :type: org
74
+ :version: 5.1
75
+ :base_profile: all
76
+ :profile: my_profile
77
+
78
+ ### Configuring deploy folders
79
+
80
+ Use "deploy_folder" component and the desired folder. If the folder starts with a "/" or
81
+ doesn't start with "deploy", the entries in VFS will be added.
82
+
83
+ # Will be in $JBOSS_HOME/server/$PROFILE/deploy/application
84
+ - deploy_folder: deploy/applications
85
+ # Will be in $JBOSS_HOME/server/$PROFILE/custom/application
86
+ - deploy_folder: custom/applications
87
+ - deploy_folder: /opt/deploy
88
+
89
+ ### Configuring jmx
90
+
91
+ Use "jmx" component:
92
+
93
+ # user and password are "admin" by default
94
+ - jmx
95
+ - jmx:
96
+ :user: admin
97
+ :password: admin
98
+
99
+ Basically, this will add an entry in the jmx-console-users.properties (depends on JBoss type).
100
+ For JBoss org, this will enable security in jmx-console since the enterprise versions have
101
+ jmx-console security by default.
102
+
103
+ ### Configuring datasources
104
+
105
+ Use a "datasource" component
106
+
107
+ Configuration:
108
+
109
+ :folder => a folder where this datasource will be saved (default: $JBOSS_HOME/server/$CONFIG/deploy)
110
+ if a relative path is given, it will be appended to default value
111
+ :encrypt => a flag to indicate if the password should be encrypted (default: false)
112
+ :type => the type of the datasource
113
+ :name => a name for saving the file (default: :type)
114
+ :attributes => a Hash with the attributes that will be changed in template (the only required is :jndi_name)
115
+
116
+ Any attribute that is not present in datasource xml will be created using this template: <key>value</key>.
117
+
118
+ For converting the symbol attributes, the above rules are used taking by example a
119
+ value ":database_url":
120
+
121
+ 1. The value "database_url"
122
+ 2. The value "database-url"
123
+ 3. The value "DatabaseUrl"
124
+ 4. The value "DATABASE_URL"
125
+
126
+ The key for finding the correct datasource is the configuration attribute :type, which is
127
+ used to search in $JBOSS_HOME/docs/examples/jca for the file.
128
+
129
+ Any key that is not found in the datasource template will be added. If it is a Symbol,
130
+ the underlines will be converted to hyphens.
131
+
132
+ For saving the file, the configuration :name will be used in the form "${name}-ds.xml".
133
+
134
+ Example:
135
+
136
+ - datasource:
137
+ :type: postgres
138
+ :attributes:
139
+ :user_name: postgres
140
+ :password: postgres
141
+ :connection_url: jdbc:postgresql://localhost:5432/sample_database
142
+ :min_pool_size: 5
143
+ :max_pool_size: 15
144
+
145
+ ### Replacing hypersonic
146
+
147
+ The same as Datasouce, but use the "default_ds" component instead.
148
+
149
+ - default_ds:
150
+ :type: postgres
151
+ :attributes:
152
+ :user_name: postgres
153
+ :password: postgres
154
+ :connection_url: jdbc:postgresql://localhost:5432/jboss_db
155
+ :min_pool_size: 5
156
+ :max_pool_size: 15
157
+
158
+ ### Installing mod_cluster
159
+
160
+ Use a "mod_cluster" component
161
+
162
+ Configuration:
163
+
164
+ :path => where the mod_cluster.sar is located
165
+ :folder => where the mod_cluster.sar should be installed (default: $JBOSS_HOME/server/$CONFIG/deploy)
166
+
167
+ The additional configurations are the entries in the bean ModClusterConfig (mod_cluster-jboss-beans.xml)
168
+ and can be in a String form (using the entry name) or in a Symbol form (using ruby nomenclature - :sticky_session)
169
+
170
+ ### Configuring run.conf
171
+
172
+ ### Slimming
173
+
174
+ Use a "slimming" component.
175
+
176
+ Configuration:
177
+
178
+ Use an array with the services to remove, the current supported are:
179
+
180
+ * Admin Console => :admin_console
181
+ * Web Console => :web_console
182
+ * Mail Service => :mail
183
+ * Bsh Deployer => :bsh_deployer
184
+ * Hot Deploy => :hot_deploy
185
+ * JUDDI => :juddi
186
+ * UUID Key Generator => :key_generator
187
+ * Scheduling => :scheduling
188
+ * JMX Console => :jmx_console
189
+ * JBoss WS => :jboss_ws
190
+ * JMX Remoting => :jmx_remoting
191
+ * ROOT Page => :root_page
192
+
193
+ Any slimmed service will be removed logically by using a ".rej" suffix in the files/directories.
194
+
195
+ ### Configuring jbossweb
196
+
197
+ ### Configuring connectors
data/bin/jboss-profile CHANGED
@@ -28,7 +28,6 @@ require 'yaml'
28
28
  require 'logger'
29
29
 
30
30
  params = {}
31
- params[:jboss_home] = Dir.pwd unless ENV["JBOSS_HOME"]
32
31
  config = nil
33
32
  create = true
34
33
 
@@ -71,6 +70,12 @@ end
71
70
  opts.on("-h", "--help", "Shows this help message") { puts opts; exit }
72
71
  opts.parse!(ARGV) rescue abort 'Invalid Option! Use --help or -h for usage help.'
73
72
 
73
+ if params.empty?
74
+ puts opts
75
+ exit
76
+ end
77
+
78
+ params[:jboss_home] ||= Dir.pwd unless ENV["JBOSS_HOME"]
74
79
  profile = JBoss::Profile::new params
75
80
 
76
81
  if config
data/bin/twiddle CHANGED
@@ -54,7 +54,7 @@ opts.on('--eval EXPRESSION',
54
54
  'Evaluates the given expression using the vars twiddle and monitor') do |expression|
55
55
  eval_expression = expression
56
56
  end
57
- opts.on('--show-all', 'Shows all resources available') do
57
+ opts.on('--all', 'Shows all resources available') do
58
58
  [
59
59
  :server_info,
60
60
  :deployments,
@@ -97,6 +97,18 @@ opts.on('--system-properties [name_a, name_b, name_c, ...]', Array,
97
97
  'Defines the System properties to show or scan if not specified') do |properties|
98
98
  resources[:system_properties] = properties || :all
99
99
  end
100
+ opts.on('--set resource_type[:resource_name],property,value', Array,
101
+ 'Sets a value to a resource that the monitor knows') do |set|
102
+ resources[:set] = set
103
+ end
104
+ opts.on('--get resource_type[:resource_name],property', Array,
105
+ 'Gets a value to a resource that the monitor knows') do |get|
106
+ resources[:get] = get
107
+ end
108
+ opts.on('--invoke resource_type[:resource_name],method,[,args...]', Array,
109
+ 'Invokes a resoruce method') do |invoke|
110
+ resources[:invoke] = invoke
111
+ end
100
112
  opts.on('--list', 'Only lists the required info (datasources, queues, ...)') do
101
113
  list_only = true
102
114
  end
@@ -123,6 +135,37 @@ eval File.read(exec_file), binding, exec_file if exec_file
123
135
 
124
136
  puts (eval eval_expression, binding) if eval_expression
125
137
 
138
+ def extract resource
139
+ mbean, name = resource.split(/:/)
140
+ end
141
+
142
+ if resources[:set]
143
+ array = resources[:set]
144
+ raise "Wrong number of arguments" if array.size != 3
145
+ mbean, name = extract array[0]
146
+ puts twiddle.set :mbean => mbean.to_sym,
147
+ :name => name,
148
+ :property => array[1],
149
+ :value => array[2]
150
+ end
151
+ if resources[:get]
152
+ array = resources[:get]
153
+ raise "Wrong number of arguments" if array.size != 2
154
+ mbean, name = extract array[0]
155
+ puts twiddle.get :mbean => mbean.to_sym,
156
+ :name => name,
157
+ :property => array[1]
158
+ end
159
+ if resources[:invoke]
160
+ array = resources[:invoke]
161
+ raise "Wrong number of arguments" if array.size < 2
162
+ mbean, name = extract array[0]
163
+ puts twiddle.invoke :mbean => mbean.to_sym,
164
+ :name => name,
165
+ :method => array[1],
166
+ :args => array[2..-1]
167
+ end
168
+
126
169
  if resources[:server_info]
127
170
  puts "Server Info:"
128
171
  monitor.properties[:server].each do |property|
@@ -50,6 +50,28 @@ module JBoss
50
50
  monitor.mbean id
51
51
  end
52
52
 
53
+ def get params
54
+ mbean = extract params
55
+ mbean[params[:property]]
56
+ end
57
+
58
+ def set params
59
+ mbean = extract params
60
+ mbean[params[:property]] = params[:value]
61
+ end
62
+
63
+ def invoke params
64
+ mbean = extract params
65
+ mbean.send params[:method], *params[:args]
66
+ end
67
+
68
+ private
69
+
70
+ def extract params
71
+ mbean = monitor.mbean params[:mbean]
72
+ mbean.with params[:name]
73
+ end
74
+
53
75
  end
54
76
 
55
77
  end
@@ -47,7 +47,7 @@ module JBoss
47
47
  resource = @resource
48
48
  env = @env
49
49
  query = eval("\"#{pattern}\"")
50
- result = @twiddle.invoke(:get, query, property)
50
+ result = @twiddle.execute(:get, query, property)
51
51
  def result.value
52
52
  self.split(/=/)[1]
53
53
  end
@@ -58,7 +58,7 @@ module JBoss
58
58
  resource = @resource
59
59
  env = @env
60
60
  query = eval("\"#{pattern}\"")
61
- @twiddle.invoke :set, query, property, value
61
+ @twiddle.execute :set, query, property, value
62
62
  end
63
63
 
64
64
  def method_missing(method, *args, &block)
@@ -69,7 +69,7 @@ module JBoss
69
69
  resource = @resource
70
70
  env = @env
71
71
  query = eval("\"#{pattern} #{method}\"")
72
- return_value = @twiddle.invoke :invoke, query, args
72
+ return_value = @twiddle.execute :invoke, query, args
73
73
  if block_given?
74
74
  block.call return_value
75
75
  end
@@ -33,6 +33,9 @@ module JBoss
33
33
  :pattern => 'jboss.web:type=Manager,host=localhost,path=/#{resource}',
34
34
  :properties => %W(activeSessions maxActive)
35
35
  },
36
+ :web_deployment => {
37
+ :pattern => 'jboss.web.deployment:war=/#{resource}'
38
+ },
36
39
  :connector => {
37
40
  :pattern => 'jboss.web:type=ThreadPool,name=#{resource}',
38
41
  :properties => %W(maxThreads currentThreadCount currentThreadsBusy)
@@ -115,12 +118,7 @@ module JBoss
115
118
  end
116
119
  end
117
120
 
118
- def mbean mbean_id = nil
119
- return get current_scan unless mbean_id
120
- mbeans[mbean_id]
121
- end
122
-
123
- def get mbean_id
121
+ def mbean mbean_id
124
122
  mbean = mbeans[mbean_id]
125
123
  if @current_resource
126
124
  mbean.with @current_resource
@@ -128,8 +126,6 @@ module JBoss
128
126
  mbean
129
127
  end
130
128
 
131
- alias_method :[], :get
132
-
133
129
  def method_missing(method, *args, &block)
134
130
  mbean_id = method
135
131
  mbean = mbeans[mbean_id]
@@ -81,7 +81,7 @@ module JBoss
81
81
  private
82
82
 
83
83
  def _query_ query, &block
84
- result = @twiddle.invoke(:query, query)
84
+ result = @twiddle.execute(:query, query)
85
85
  return [] if result["No MBean matches for query"]
86
86
  result = result.split /\s+/
87
87
  block ? result.collect(&block) : result
@@ -53,16 +53,12 @@ module JBoss
53
53
  @jboss_home
54
54
  end
55
55
 
56
- def invoke command, *arguments
57
- execute(shell command, arguments)
58
- end
59
-
60
56
  def shell operation, *arguments
61
57
  "#{command} #{operation} #{arguments.join " "}"
62
58
  end
63
59
 
64
- def execute shell
65
- `#{shell}`.chomp
60
+ def execute command, *arguments
61
+ `#{shell command, arguments}`.chomp
66
62
  end
67
63
 
68
64
  end
data/lib/rboss/version.rb CHANGED
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module RBoss
24
- VERSION = "0.1.0"
24
+ VERSION = "0.2.0"
25
25
  end
data/rboss.gemspec CHANGED
@@ -7,9 +7,10 @@ Gem::Specification.new do |s|
7
7
  s.version = RBoss::VERSION
8
8
  s.authors = ["Ataxexe"]
9
9
  s.email = ["ataxexe@gmail.com"]
10
- s.homepage = ""
10
+ s.homepage = "https://github.com/ataxexe/rboss"
11
11
  s.summary = %q{A Ruby way to do a JBoss work!}
12
- s.description = %q{This gem help you to create a JBoss profile and some other things like building twiddle scripts}
12
+ s.description = %q{A tool to create profiles for JBoss Application Server and use
13
+ twiddle to scan a running JBoss AS or execute scripts.}
13
14
 
14
15
  s.rubyforge_project = "rboss"
15
16
 
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rboss
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.1.0
5
+ version: 0.2.0
6
6
  platform: ruby
7
7
  authors:
8
8
  - Ataxexe
@@ -10,10 +10,12 @@ autorequire:
10
10
  bindir: bin
11
11
  cert_chain: []
12
12
 
13
- date: 2011-08-11 00:00:00 Z
13
+ date: 2011-08-13 00:00:00 Z
14
14
  dependencies: []
15
15
 
16
- description: This gem help you to create a JBoss profile and some other things like building twiddle scripts
16
+ description: |-
17
+ A tool to create profiles for JBoss Application Server and use
18
+ twiddle to scan a running JBoss AS or execute scripts.
17
19
  email:
18
20
  - ataxexe@gmail.com
19
21
  executables:
@@ -26,6 +28,7 @@ extra_rdoc_files: []
26
28
  files:
27
29
  - .gitignore
28
30
  - Gemfile
31
+ - README.md
29
32
  - Rakefile
30
33
  - bin/jboss-profile
31
34
  - bin/twiddle
@@ -74,7 +77,7 @@ files:
74
77
  - test/mbean_test.rb
75
78
  - test/test_helper.rb
76
79
  - test/test_suite.rb
77
- homepage: ""
80
+ homepage: https://github.com/ataxexe/rboss
78
81
  licenses: []
79
82
 
80
83
  post_install_message: