rboss 0.6.2 → 0.7.0
Sign up to get free protection for your applications and to get access to all the features.
- data/.gitignore +2 -2
- data/README.md +144 -3
- data/bin/rboss-cli +20 -9
- data/bin/twiddle +11 -10
- data/lib/rboss.rb +4 -0
- data/lib/rboss/cli/invoker.rb +28 -12
- data/lib/rboss/cli/mappings/resources/connector.yaml +2 -2
- data/lib/rboss/cli/mappings/resources/datasource.yaml +57 -69
- data/lib/rboss/cli/mappings/resources/server.yaml +28 -38
- data/lib/rboss/cli/resource.rb +5 -8
- data/lib/rboss/cli/result_parser.rb +1 -1
- data/lib/rboss/twiddle.rb +0 -5
- data/lib/rboss/twiddle/mbean.rb +1 -1
- data/lib/rboss/version.rb +1 -1
- data/lib/rboss/view/colorizers.rb +11 -22
- data/lib/rboss/view/formatters.rb +3 -14
- data/lib/rboss/view/health_checkers.rb +3 -34
- data/lib/rboss/view/table_builder.rb +13 -37
- data/rboss.iml +206 -0
- data/rboss.ipr +577 -0
- metadata +4 -2
data/.gitignore
CHANGED
data/README.md
CHANGED
@@ -10,6 +10,146 @@ Installation
|
|
10
10
|
|
11
11
|
gem install rboss
|
12
12
|
|
13
|
+
### Dependencies
|
14
|
+
|
15
|
+
* yummi
|
16
|
+
|
17
|
+
Using rboss-cli
|
18
|
+
-----------
|
19
|
+
|
20
|
+
rboss-cli is a helper tool for jboss-cli, it maps resource paths and helps the operation
|
21
|
+
invoke.
|
22
|
+
|
23
|
+
### Basics
|
24
|
+
|
25
|
+
Invoke the command for a list of mapped resources:
|
26
|
+
|
27
|
+
rboss-cli --help
|
28
|
+
|
29
|
+
You can scan resources, detail information and execute operations.
|
30
|
+
|
31
|
+
rboss-cli --datasource
|
32
|
+
rboss-cli --server-memory
|
33
|
+
rboss-cli --server --operation shutdown
|
34
|
+
|
35
|
+
### Invoking Operations
|
36
|
+
|
37
|
+
To see the operations for a resource, use the option "--list-operations"
|
38
|
+
|
39
|
+
rboss-cli --server --list-operations
|
40
|
+
|
41
|
+
To detail an operation, use the option "--detail-operation"
|
42
|
+
|
43
|
+
rboss-cli --server --detail-operation shutdown
|
44
|
+
|
45
|
+
This will print a table showing both request and response parameters. To invoke the
|
46
|
+
operation, use the "--operation" (or "-o") option
|
47
|
+
|
48
|
+
rboss-cli --server --operation shutdown
|
49
|
+
rboss-cli --server -o shutdown
|
50
|
+
|
51
|
+
Since this operation requires a parameter, rboss-cli will ask you to input them. If you
|
52
|
+
want to pass the required parameters, use the "--arguments" (or "-a") option
|
53
|
+
|
54
|
+
rboss-cli --server --operation shutdown --arguments restart=true
|
55
|
+
rboss-cli --server -o shutdown -a restart=true
|
56
|
+
|
57
|
+
If you want to skip optional arguments, use the "--skip-optional". rboss-cli will not ask
|
58
|
+
you to input the arguments, leaving "--arguments" as the only way to set them.
|
59
|
+
|
60
|
+
### Known Issues
|
61
|
+
|
62
|
+
The datasource mapping (--datasource) retrieves incorrect information if you call either
|
63
|
+
detail operation or invoke operation for the operation add. This is caused because the
|
64
|
+
command '/subsystem=datasources/data-source=:read-operation-description(name=add)' needs
|
65
|
+
to be executed as
|
66
|
+
'/subsystem=datasources/data-source=ANY_VALUE:read-operation-description(name=add)',
|
67
|
+
leaving the '--datasource any' as a workaround.
|
68
|
+
|
69
|
+
rboss-cli --datasource --detail-operation add
|
70
|
+
rboss-cli --datasource a --detail-operation add
|
71
|
+
|
72
|
+
### Configuring mappings
|
73
|
+
|
74
|
+
To create and override mappings, just put a yaml file in "~/.rboss/rboss-cli/resources". The filename will
|
75
|
+
be used to identify the operation. Example: placing a file named datasource.yaml will override the
|
76
|
+
--datasource option and a file named logger.yaml will create a new option (--logger).
|
77
|
+
|
78
|
+
The yaml must contain the given definitions:
|
79
|
+
|
80
|
+
* description: an explaining text to appear in command usage (--help)
|
81
|
+
* path: the path to invoke the operations, may take a ${NAME} if the path contains a resource name
|
82
|
+
* scan (optional): a command to scan resources (by using this, the option may take an array of resource names)
|
83
|
+
* print (optional): an array of table definitions to print with "read-resource" operation.
|
84
|
+
|
85
|
+
To configure a table to print, just use the following parameters:
|
86
|
+
|
87
|
+
* id: a name that will be joined to the file name to allow print only this table
|
88
|
+
* title: the table title
|
89
|
+
* layout (horizontal | vertical): how the table must be printed. Use vertical for large number of properties
|
90
|
+
* properties: an array with the properties (returned by "read-resource") to print in this table
|
91
|
+
* header: an array that maps a header text to the properties
|
92
|
+
* format: a hash that maps formatters to the table columns
|
93
|
+
* color: a hash that maps colors to the table columns
|
94
|
+
* health: a hash that maps health checkers to the table columns
|
95
|
+
|
96
|
+
All mappings (formatter, colorizer and health checker) should be mapped using the following conventions:
|
97
|
+
|
98
|
+
* the key should be the property name (replace '-' with '_')
|
99
|
+
* the value should be the message to send to RBoss::Formatters, RBoss::HealthCheckers or RBoss::Colorizers
|
100
|
+
* if the message takes parameters, they must be specified in a form of a hash after the message
|
101
|
+
|
102
|
+
Examples:
|
103
|
+
|
104
|
+
health:
|
105
|
+
active:
|
106
|
+
percentage:
|
107
|
+
max: available
|
108
|
+
using: active
|
109
|
+
color:
|
110
|
+
jndi_name:
|
111
|
+
with: purple
|
112
|
+
enabled: boolean
|
113
|
+
connection_url:
|
114
|
+
with: yellow
|
115
|
+
|
116
|
+
format:
|
117
|
+
system_load: percentage
|
118
|
+
color:
|
119
|
+
name:
|
120
|
+
with: white
|
121
|
+
system_load:
|
122
|
+
threshold:
|
123
|
+
0.8: intense_red
|
124
|
+
0.7: red
|
125
|
+
0.5: yellow
|
126
|
+
0: green
|
127
|
+
|
128
|
+
### Adding new components
|
129
|
+
|
130
|
+
To add new Colorizers, Formatters or HealthCheckers, just put the code in the "~/.rboss/rboss.rb".
|
131
|
+
|
132
|
+
Example:
|
133
|
+
|
134
|
+
module RBoss::Colorizers
|
135
|
+
def self.my_colorizer
|
136
|
+
lambda do |value|
|
137
|
+
value ? :red : :green
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
|
142
|
+
From now you can use this colorizer
|
143
|
+
|
144
|
+
color:
|
145
|
+
name: my_colorizer
|
146
|
+
|
147
|
+
The components included are defined in the following files:
|
148
|
+
|
149
|
+
* /lib/rboss/view/colorizers.rb
|
150
|
+
* /lib/rboss/view/formatters.rb
|
151
|
+
* /lib/rboss/view/health_checkers.rb
|
152
|
+
|
13
153
|
Using twiddle
|
14
154
|
-----------
|
15
155
|
|
@@ -74,7 +214,7 @@ And used with -c or --config
|
|
74
214
|
|
75
215
|
### Customizing MBeans
|
76
216
|
|
77
|
-
Every time you run the twiddle command, this gem will load the ~/.rboss/
|
217
|
+
Every time you run the twiddle command, this gem will load the ~/.rboss/rboss.rb file,
|
78
218
|
which can be used to customize the mbeans.
|
79
219
|
|
80
220
|
defaults = RBoss::Twiddle::Monitor.defaults
|
@@ -157,8 +297,9 @@ limits by using a :health key:
|
|
157
297
|
end
|
158
298
|
}
|
159
299
|
|
160
|
-
|
161
|
-
|
300
|
+
Customizing health, formatters and colors are the same as customizing in rboss-cli. You can
|
301
|
+
use the indexes of the values (in that case, 2 for :max and 0 for :using) or the header values
|
302
|
+
in downcase and underscores.
|
162
303
|
|
163
304
|
Using jboss-profile
|
164
305
|
-----------
|
data/bin/rboss-cli
CHANGED
@@ -93,13 +93,22 @@ opts.on('-o', '--operation NAME',
|
|
93
93
|
@operation = name
|
94
94
|
end
|
95
95
|
|
96
|
+
opts.on('-l', '--list-operations', 'Lists the available operations for a resource') do
|
97
|
+
@operation = 'read-operation-names'
|
98
|
+
end
|
99
|
+
|
100
|
+
opts.on('--detail-operation NAME', 'Shows the operation details') do |operation_name|
|
101
|
+
@operation = 'read-operation-description'
|
102
|
+
@parameters = {'name' => operation_name}
|
103
|
+
end
|
104
|
+
|
96
105
|
opts.on('--skip-optional', 'Skips optional parameters while invoking a command ') do
|
97
106
|
params[:skip_optional] = true
|
98
107
|
end
|
99
108
|
|
100
109
|
opts.on('-a', '--args PARAMETERS', Array,
|
101
110
|
'Specifies parameters in form of (name=value) for use with operation') do |parameters|
|
102
|
-
@parameters = Hash[(parameters.collect {|p| p.split(/=/,2)})]
|
111
|
+
@parameters = Hash[(parameters.collect { |p| p.split( /=/, 2) })]
|
103
112
|
end
|
104
113
|
|
105
114
|
RBoss::Cli::Mappings.resource_mappings.each do |name, config|
|
@@ -127,10 +136,6 @@ opts.parse!(ARGV) rescue abort 'Invalid Option! Use --help or -h for usage help.
|
|
127
136
|
|
128
137
|
@jboss_cli = RBoss::Cli::Invoker::new params
|
129
138
|
|
130
|
-
unless $stdout.isatty
|
131
|
-
require 'yummi/no_colors'
|
132
|
-
end
|
133
|
-
|
134
139
|
if save
|
135
140
|
config = load_yaml
|
136
141
|
config[save] ||= {}
|
@@ -160,9 +165,15 @@ def execute_actions
|
|
160
165
|
end
|
161
166
|
end
|
162
167
|
|
163
|
-
|
168
|
+
begin
|
169
|
+
|
170
|
+
while @loop
|
171
|
+
execute_actions
|
172
|
+
sleep @interval
|
173
|
+
end
|
174
|
+
|
164
175
|
execute_actions
|
165
|
-
sleep @interval
|
166
|
-
end
|
167
176
|
|
168
|
-
|
177
|
+
rescue Interrupt
|
178
|
+
#Do nothing
|
179
|
+
end
|
data/bin/twiddle
CHANGED
@@ -46,10 +46,6 @@ def load_yaml
|
|
46
46
|
YAML::load_file(@servers_file)
|
47
47
|
end
|
48
48
|
|
49
|
-
unless $stdout.isatty
|
50
|
-
require 'yummi/no_colors'
|
51
|
-
end
|
52
|
-
|
53
49
|
opts = OptionParser::new
|
54
50
|
opts.on('-j', '--jboss-home PATH', 'Defines the JBOSS_HOME variable') do |home|
|
55
51
|
params[:jboss_home] = home
|
@@ -90,7 +86,7 @@ end
|
|
90
86
|
|
91
87
|
(defaults.sort_by { |k, v| k }).each do |mbean_id, mbean|
|
92
88
|
next if mbean[:properties] and not mbean[:scan] and mbean[:pattern]['#{resource}']
|
93
|
-
command = mbean_id.to_s.gsub
|
89
|
+
command = mbean_id.to_s.gsub(/_/, '-')
|
94
90
|
if mbean[:scan]
|
95
91
|
opts.on("--#{command} [name_a,name_b,...]", Array,
|
96
92
|
"Detail \"#{mbean[:description]}\" based on the given names (no names for scan)") do |names|
|
@@ -176,7 +172,7 @@ end
|
|
176
172
|
|
177
173
|
def extract resource
|
178
174
|
mbean, name = resource.split(/:/)
|
179
|
-
mbean.gsub!
|
175
|
+
mbean.gsub!(/-/, '_')
|
180
176
|
[mbean, name]
|
181
177
|
end
|
182
178
|
|
@@ -195,9 +191,14 @@ def execute_actions
|
|
195
191
|
puts buff
|
196
192
|
end
|
197
193
|
|
198
|
-
|
194
|
+
begin
|
195
|
+
|
196
|
+
while @loop
|
197
|
+
execute_actions
|
198
|
+
sleep @interval
|
199
|
+
end
|
200
|
+
|
199
201
|
execute_actions
|
200
|
-
|
202
|
+
rescue Interrupt
|
203
|
+
#Do nothing
|
201
204
|
end
|
202
|
-
|
203
|
-
execute_actions
|
data/lib/rboss.rb
CHANGED
@@ -30,3 +30,7 @@ require_relative "rboss/jboss_profile"
|
|
30
30
|
require_relative "rboss/twiddle"
|
31
31
|
require_relative "rboss/cli/invoker"
|
32
32
|
require_relative "rboss/bin/command_actions"
|
33
|
+
|
34
|
+
file = File.expand_path("~/.rboss/rboss.rb")
|
35
|
+
|
36
|
+
eval File.read(file), binding, file if File.exist? file
|
data/lib/rboss/cli/invoker.rb
CHANGED
@@ -89,28 +89,38 @@ module RBoss
|
|
89
89
|
|
90
90
|
def gets_and_invoke(path, operation, parameters)
|
91
91
|
result = result("#{path}:read-operation-description(name=#{operation})")
|
92
|
-
result["request-properties"]
|
93
|
-
|
92
|
+
props = result["request-properties"]
|
93
|
+
props ||= {}
|
94
94
|
builder = CommandBuilder::new operation
|
95
|
-
|
95
|
+
help_printed = false
|
96
|
+
info = Yummi::colorize("Please input the requested parameters", :yellow)
|
97
|
+
props.each do |name, detail|
|
96
98
|
next if (@skip_optional and not detail['required'] or detail['default'])
|
97
99
|
input = parameters[name]
|
98
100
|
unless input
|
99
|
-
puts
|
100
|
-
|
101
|
-
|
102
|
-
|
103
|
-
|
104
|
-
|
105
|
-
|
106
|
-
|
107
|
-
|
101
|
+
puts info unless help_printed
|
102
|
+
help_printed = true
|
103
|
+
input_message = Yummi::colorize(name, :intense_blue)
|
104
|
+
required = detail['required']
|
105
|
+
default_value = detail['default']
|
106
|
+
input_message << ' | ' << RBoss::Colorizers.type(detail['type']).colorize(detail['type'])
|
107
|
+
input_message << ' | ' << Yummi::colorize("Required", :red) if required
|
108
|
+
input_message << ' | ' << Yummi::colorize("Optional", :cyan) unless required
|
109
|
+
input_message << ' | ' << Yummi::colorize("Default: #{default_value}", :blue) if default_value
|
110
|
+
input_message << "\n" << Yummi::colorize(detail['description'], :intense_gray)
|
111
|
+
puts input_message
|
112
|
+
input = get_input
|
113
|
+
while required and input.empty?
|
114
|
+
puts Yummi::colorize("Required parameter!", :red)
|
115
|
+
input = get_input
|
108
116
|
end
|
109
117
|
end
|
110
118
|
next if input.empty?
|
111
119
|
builder << {:name => name, :value => detail['type'].convert(input)}
|
112
120
|
end
|
113
121
|
result = result("#{path}:#{builder}")
|
122
|
+
puts Yummi::colorize("Result:", :yellow)
|
123
|
+
#TODO print a table using the returned parameters
|
114
124
|
puts YAML::dump(result)
|
115
125
|
end
|
116
126
|
|
@@ -124,6 +134,12 @@ module RBoss
|
|
124
134
|
eval_result(execute commands)
|
125
135
|
end
|
126
136
|
|
137
|
+
private
|
138
|
+
|
139
|
+
def get_input
|
140
|
+
gets.chomp.strip
|
141
|
+
end
|
142
|
+
|
127
143
|
end
|
128
144
|
|
129
145
|
class CommandBuilder
|
@@ -7,66 +7,67 @@ print:
|
|
7
7
|
title: Datasource Details
|
8
8
|
layout: vertical
|
9
9
|
properties:
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
10
|
+
- jndi-name
|
11
|
+
- connection-url
|
12
|
+
- driver-name
|
13
|
+
- user-name
|
14
|
+
- password
|
15
|
+
- jta
|
16
|
+
- min-pool-size
|
17
|
+
- max-pool-size
|
18
|
+
- enabled
|
19
19
|
header:
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
20
|
+
- JNDI Name
|
21
|
+
- Connection URL
|
22
|
+
- Driver Name
|
23
|
+
- User Name
|
24
|
+
- Password
|
25
|
+
- Using JTA
|
26
|
+
- Min Pool Size
|
27
|
+
- Max Pool Size
|
28
|
+
- Enabled
|
29
29
|
format:
|
30
|
-
enabled:
|
31
|
-
using_jta:
|
30
|
+
enabled: boolean
|
31
|
+
using_jta: boolean
|
32
32
|
|
33
33
|
color:
|
34
34
|
jndi_name:
|
35
35
|
with: purple
|
36
36
|
enabled: boolean
|
37
|
+
using_jta: boolean
|
37
38
|
connection_url:
|
38
|
-
with:
|
39
|
+
with: yellow
|
39
40
|
|
40
41
|
- id: pool
|
41
42
|
title: Datasource Pool Statistics
|
42
43
|
path: ${PATH}/statistics=pool
|
43
44
|
layout: vertical
|
44
45
|
properties:
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
46
|
+
- ActiveCount
|
47
|
+
- AvailableCount
|
48
|
+
- AverageBlockingTime
|
49
|
+
- AverageCreationTime
|
50
|
+
- CreatedCount
|
51
|
+
- DestroyedCount
|
52
|
+
- MaxCreationTime
|
53
|
+
- MaxUsedCount
|
54
|
+
- MaxWaitTime
|
55
|
+
- TimedOut
|
56
|
+
- TotalBlockingTime
|
57
|
+
- TotalCreationTime
|
57
58
|
|
58
59
|
header:
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
60
|
+
- Active
|
61
|
+
- Available
|
62
|
+
- Average Blocking
|
63
|
+
- Average Creation
|
64
|
+
- Created
|
65
|
+
- Destroyed
|
66
|
+
- Max Creation
|
67
|
+
- Max Wait
|
68
|
+
- Timed Out
|
69
|
+
- Total Blocking
|
70
|
+
- Total Creation
|
70
71
|
|
71
72
|
health:
|
72
73
|
active:
|
@@ -78,29 +79,16 @@ print:
|
|
78
79
|
title: Datasource JDBC Statistics
|
79
80
|
path: ${PATH}/statistics=jdbc
|
80
81
|
properties:
|
81
|
-
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
|
86
|
-
|
82
|
+
- PreparedStatementCacheCurrentSize
|
83
|
+
- PreparedStatementCacheAccessCount
|
84
|
+
- PreparedStatementCacheAddCount
|
85
|
+
- PreparedStatementCacheDeleteCount
|
86
|
+
- PreparedStatementCacheHitCount
|
87
|
+
- PreparedStatementCacheMissCount
|
87
88
|
header:
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
- Add
|
96
|
-
|
97
|
-
Count
|
98
|
-
- Delete
|
99
|
-
|
100
|
-
Count
|
101
|
-
- Hit
|
102
|
-
|
103
|
-
Count
|
104
|
-
- Miss
|
105
|
-
|
106
|
-
Count
|
89
|
+
- "Current\nSize"
|
90
|
+
- "Access\nCount"
|
91
|
+
- "Add\nCount"
|
92
|
+
- "Delete\nCount"
|
93
|
+
- "Hit\nCount"
|
94
|
+
- "Miss\nCount"
|