rboss 0.6.2 → 0.7.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/.gitignore CHANGED
@@ -1,9 +1,9 @@
1
1
  out
2
2
  rboss.iws
3
- rboss.ipr
4
- rboss.iml
5
3
  *.gem
6
4
  .bundle
7
5
  Gemfile.lock
8
6
  pkg/*
9
7
  .rakeTasks
8
+ *.sublime-project
9
+ *.sublime-workspace
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/twiddle.rb file,
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
- You can use the indexes of the values (in that case, 2 for :max and 0 for :using) or the
161
- header values in downcase and underscores.
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
- while @loop
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
- execute_actions
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
- while @loop
194
+ begin
195
+
196
+ while @loop
197
+ execute_actions
198
+ sleep @interval
199
+ end
200
+
199
201
  execute_actions
200
- sleep @interval
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
@@ -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
- puts Yummi::colorize("Please input the requested parameters", :yellow)
92
+ props = result["request-properties"]
93
+ props ||= {}
94
94
  builder = CommandBuilder::new operation
95
- result["request-properties"].each do |name, detail|
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 Yummi::colorize(name, :intense_blue)
100
- puts "Enter parameter value (type --help to get the parameter description): "
101
- while (input = gets.chomp) == '--help'
102
- puts Yummi::colorize(detail['description'], :intense_gray)
103
- required = detail['required']
104
- default_value = detail['default']
105
- puts RBoss::Colorizers.type(detail['type']).colorize(detail['type'])
106
- puts Yummi::colorize("Required", :red) if required
107
- puts Yummi::colorize("Default: #{default_value}", :brown) if default_value
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
@@ -40,8 +40,8 @@ print:
40
40
  bytes_sent: byte
41
41
  max_post_size: byte
42
42
  max_save_post_size: byte
43
- enabled: yes_or_no
44
- secure: yes_or_no
43
+ enabled: boolean
44
+ secure: boolean
45
45
 
46
46
  color:
47
47
  scheme:
@@ -7,66 +7,67 @@ print:
7
7
  title: Datasource Details
8
8
  layout: vertical
9
9
  properties:
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
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
- - 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
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: yes_or_no
31
- using_jta: yes_or_no
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: brown
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
- - ActiveCount
46
- - AvailableCount
47
- - AverageBlockingTime
48
- - AverageCreationTime
49
- - CreatedCount
50
- - DestroyedCount
51
- - MaxCreationTime
52
- - MaxUsedCount
53
- - MaxWaitTime
54
- - TimedOut
55
- - TotalBlockingTime
56
- - TotalCreationTime
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
- - Active
60
- - Available
61
- - Average Blocking
62
- - Average Creation
63
- - Created
64
- - Destroyed
65
- - Max Creation
66
- - Max Wait
67
- - Timed Out
68
- - Total Blocking
69
- - Total Creation
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
- - PreparedStatementCacheCurrentSize
82
- - PreparedStatementCacheAccessCount
83
- - PreparedStatementCacheAddCount
84
- - PreparedStatementCacheDeleteCount
85
- - PreparedStatementCacheHitCount
86
- - PreparedStatementCacheMissCount
82
+ - PreparedStatementCacheCurrentSize
83
+ - PreparedStatementCacheAccessCount
84
+ - PreparedStatementCacheAddCount
85
+ - PreparedStatementCacheDeleteCount
86
+ - PreparedStatementCacheHitCount
87
+ - PreparedStatementCacheMissCount
87
88
  header:
88
- - Current
89
-
90
- Size
91
- - Access
92
-
93
- Count
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"