rboss 0.2.1 → 0.2.2

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 CHANGED
@@ -46,6 +46,24 @@ Execute commands with --invoke:
46
46
  twiddle --invoke server,shutdown
47
47
  twiddle --invoke web_deployment:jmx-console,stop
48
48
 
49
+ Extending mbeans
50
+
51
+ You can use a file in ~/.rboss.twiddle for mapping new mbeans or overriding the defaults
52
+
53
+ JBoss::Twiddle::Monitor.defaults[:http_request] = {
54
+ :description => 'Request for http protocol',
55
+ :pattern => 'jboss.web:type=GlobalRequestProcessor,name=http-127.0.0.1-8080',
56
+ :properties => %W(requestCount errorCount maxTime)
57
+ }
58
+
59
+ And use it normally
60
+
61
+ twiddle --http-request
62
+
63
+ You can do every action using custom mbeans
64
+
65
+ twiddle --invoke http_request,resetCounters
66
+
49
67
  Using jboss-profile
50
68
  -----------
51
69
 
data/bin/twiddle CHANGED
@@ -30,7 +30,7 @@ params = {}
30
30
  mbeans = {}
31
31
  commands = {}
32
32
  no_details = false
33
- params[:jboss_home] = Dir.pwd unless ENV["JBOSS_HOME"]
33
+ params[:jboss_home] = (ENV["JBOSS_HOME"] or ENV["TWIDDLE_HOME"] or Dir.pwd)
34
34
  exec_file = nil
35
35
  defaults = JBoss::Twiddle::Monitor::defaults
36
36
 
@@ -56,21 +56,21 @@ opts.on('--all', "Detail all mapped mbeans") do
56
56
  defaults.each do |mbean_id, mbean|
57
57
  if mbean[:scan]
58
58
  mbeans[mbean_id] = :all
59
- elsif mbean[:detail]
59
+ elsif mbean[:properties]
60
60
  mbeans[mbean_id] = true
61
61
  end
62
62
  end
63
63
  end
64
64
 
65
- defaults.each do |mbean_id, mbean|
65
+ (defaults.sort_by {|k,v| k}).each do |mbean_id, mbean|
66
66
  command = mbean_id.to_s.gsub /_/, '-'
67
67
  if mbean[:scan]
68
68
  opts.on("--#{command} [name_a,name_b,...]", Array,
69
- "Detail this mbeam based on the given names (no names for scan)") do |names|
69
+ "Detail \"#{mbean[:description]}\" based on the given names (no names for scan)") do |names|
70
70
  mbeans[mbean_id] = names || :all
71
71
  end
72
- elsif mbean[:detail]
73
- opts.on("--#{command}", "Detail this mbeam") do
72
+ elsif mbean[:properties]
73
+ opts.on("--#{command}", "Detail \"#{mbean[:description]}\"") do
74
74
  mbeans[mbean_id] = true
75
75
  end
76
76
  end
@@ -89,7 +89,7 @@ opts.on('--invoke mbean_id[:resource_name],method,[,args...]', Array,
89
89
  commands[:invoke] = invoke
90
90
  end
91
91
  opts.on("-l", "--list", "List the mbeans mappings") do
92
- defaults.each do |mbean_id, mbean|
92
+ (defaults.sort_by {|k,v| k}).each do |mbean_id, mbean|
93
93
  puts " - #{mbean_id}"
94
94
  [:description, :pattern].each do |detail|
95
95
  puts " - #{detail} : #{mbean[detail]}"
@@ -156,8 +156,7 @@ end
156
156
  mbeans.each do |mbean_id, resources|
157
157
  puts " - #{defaults[mbean_id][:description]}"
158
158
  if resources.is_a? TrueClass
159
- details = monitor.mbean(mbean_id).detail
160
- details.each do |name, value|
159
+ monitor.mbean(mbean_id).detail do |name, value|
161
160
  puts " - #{name}=#{value}"
162
161
  end
163
162
  elsif no_details
@@ -165,8 +164,7 @@ mbeans.each do |mbean_id, resources|
165
164
  puts " - #{name}"
166
165
  end
167
166
  else
168
- details = monitor.mbean(mbean_id).detail resources
169
- details.each do |resource, detail|
167
+ monitor.mbean(mbean_id).detail resources do |resource, detail|
170
168
  puts " - #{resource}"
171
169
  detail.each do |name, value|
172
170
  puts " - #{name}=#{value}"
data/lib/rboss/twiddle.rb CHANGED
@@ -23,3 +23,7 @@
23
23
  require_relative 'twiddle/base_monitor'
24
24
  require_relative 'twiddle/mbean'
25
25
  require_relative 'twiddle/monitor'
26
+
27
+ file = ENV["RBOSS_TWIDDLE"] || File.expand_path("~/.rboss.twiddle")
28
+
29
+ eval File.read(file), binding, file
@@ -28,7 +28,7 @@ module JBoss
28
28
  attr_reader :pattern
29
29
  attr_accessor :resource, :twiddle, :description
30
30
 
31
- @@__default__detail__resource__ = proc do |resources|
31
+ @@__default__detail__resource__ = proc do |resources, &block|
32
32
  resouces = _parse_resource_ resources
33
33
  details = {}
34
34
  resouces.each do |resource|
@@ -39,14 +39,16 @@ module JBoss
39
39
  end
40
40
  end
41
41
  end
42
+ details.each &block if block
42
43
  details
43
44
  end
44
45
 
45
- @@__default__detail__ = proc do
46
+ @@__default__detail__ = proc do |&block|
46
47
  details = {}
47
48
  @properties.each do |property|
48
49
  details[property] = self[property].value
49
50
  end
51
+ details.each &block if block
50
52
  details
51
53
  end
52
54
 
@@ -59,16 +61,19 @@ module JBoss
59
61
  (class << self
60
62
  self
61
63
  end).send :define_method, :scan, &params[:scan]
64
+ (class << self
65
+ self
66
+ end).send :define_method, :each do |&block|
67
+ scan.each &block
68
+ end
62
69
  end
63
- if params[:detail]
70
+ if params[:properties]
64
71
  (class << self
65
72
  self
66
73
  end).send :define_method,
67
74
  :detail,
68
- &(params[:detail].is_a?(TrueClass) ?
69
- (params[:scan] ?
75
+ &(params[:scan] ?
70
76
  @@__default__detail__resource__ : @@__default__detail__)
71
- : params[:detail])
72
77
  end
73
78
  end
74
79
 
@@ -81,10 +86,6 @@ module JBoss
81
86
  self
82
87
  end
83
88
 
84
- def resourced?
85
- @pattern['#{resource}']
86
- end
87
-
88
89
  def [] property
89
90
  resource = @resource
90
91
  query = eval("\"#{pattern}\"")
@@ -28,7 +28,7 @@ module JBoss
28
28
  module Monitor
29
29
 
30
30
  def defaults
31
- @defaults ||= {
31
+ @@defaults ||= {
32
32
  :webapp => {
33
33
  :description => 'Deployed webapps',
34
34
  :pattern => 'jboss.web:type=Manager,host=localhost,path=/#{resource}',
@@ -39,8 +39,7 @@ module JBoss
39
39
  path.gsub! /,host=.+/, ''
40
40
  path
41
41
  end
42
- end,
43
- :detail => true
42
+ end
44
43
  },
45
44
  :web_deployment => {
46
45
  :description => 'Deployed webapp control',
@@ -54,27 +53,23 @@ module JBoss
54
53
  _query_ "jboss.web:type=ThreadPool,*" do |path|
55
54
  path.gsub "jboss.web:type=ThreadPool,name=", ""
56
55
  end
57
- end,
58
- :detail => true
56
+ end
59
57
  },
60
58
  :engine => {
61
59
  :description => 'JBossWeb engine',
62
60
  :pattern => 'jboss.web:type=Engine',
63
- :properties => %W(jvmRoute name defaultHost),
64
- :detail => true
61
+ :properties => %W(jvmRoute name defaultHost)
65
62
  },
66
63
  :server_info => {
67
64
  :description => 'JBoss running info',
68
65
  :pattern => 'jboss.system:type=ServerInfo',
69
66
  :properties => %W(ActiveThreadCount MaxMemory FreeMemory AvailableProcessors
70
- HostAddress JavaVendor JavaVersion OSName OSArch),
71
- :detail => true
67
+ HostAddress JavaVendor JavaVersion OSName OSArch)
72
68
  },
73
69
  :server => {
74
70
  :description => 'JBoss specifications',
75
71
  :pattern => 'jboss.system:type=Server',
76
- :properties => %W(VersionNumber StartDate),
77
- :detail => true
72
+ :properties => %W(VersionNumber StartDate)
78
73
  },
79
74
  :system_properties => {
80
75
  :description => 'System properties',
@@ -88,8 +83,7 @@ module JBoss
88
83
  _query_ "jboss.web:type=ThreadPool,*" do |path|
89
84
  path.gsub "jboss.web:type=ThreadPool,name=", ""
90
85
  end
91
- end,
92
- :detail => true
86
+ end
93
87
  },
94
88
  :datasource => {
95
89
  :description => 'Datasource',
@@ -100,8 +94,7 @@ module JBoss
100
94
  _query_ "jboss.jca:service=ManagedConnectionPool,*" do |path|
101
95
  path.gsub "jboss.jca:service=ManagedConnectionPool,name=", ""
102
96
  end
103
- end,
104
- :detail => true
97
+ end
105
98
  },
106
99
  :queue => {
107
100
  :description => 'JMS Queue',
@@ -112,8 +105,7 @@ module JBoss
112
105
  _query_ "jboss.messaging.destination:service=Queue,*" do |path|
113
106
  path.gsub "jboss.messaging.destination:service=Queue,name=", ""
114
107
  end
115
- end,
116
- :detail => true
108
+ end
117
109
  },
118
110
  :ejb => {
119
111
  :description => 'EJB',
@@ -126,21 +118,14 @@ module JBoss
126
118
  end).collect do |path|
127
119
  path.gsub("jboss.j2ee:", '').gsub(/,?service=EJB3/, '')
128
120
  end
129
- end,
130
- :detail => true
121
+ end
131
122
  }
132
123
  }
133
- @defaults
124
+ @@defaults
134
125
  end
135
126
 
136
127
  module_function :defaults
137
128
 
138
- def properties mbean_id = nil
139
- @properties ||= {}
140
- return properties[mbean_id] if mbean_id
141
- @properties
142
- end
143
-
144
129
  def mbeans
145
130
  @mbeans ||= {}
146
131
  @mbeans
data/lib/rboss/version.rb CHANGED
@@ -21,5 +21,5 @@
21
21
  # THE SOFTWARE.
22
22
 
23
23
  module RBoss
24
- VERSION = "0.2.1"
24
+ VERSION = "0.2.2"
25
25
  end
metadata CHANGED
@@ -2,7 +2,7 @@
2
2
  name: rboss
3
3
  version: !ruby/object:Gem::Version
4
4
  prerelease:
5
- version: 0.2.1
5
+ version: 0.2.2
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-19 00:00:00 Z
13
+ date: 2011-08-23 00:00:00 Z
14
14
  dependencies: []
15
15
 
16
16
  description: |-
@@ -35,7 +35,6 @@ files:
35
35
  - examples/jboss_profile/jbb_profile_1.yaml
36
36
  - examples/jboss_profile/jbb_profile_2.yaml
37
37
  - examples/jboss_profile/jboss_profile.yaml
38
- - examples/monitor/simple_monitor.rb
39
38
  - lib/rboss.rb
40
39
  - lib/rboss/component_processor.rb
41
40
  - lib/rboss/components/component.rb
@@ -1,61 +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
- puts "Server Info:"
24
- monitor.properties[:server_info].each do |property|
25
- puts " |--> #{monitor.server_info[property]}"
26
- end
27
-
28
- puts "Connectors:"
29
- monitor.with :connectors do |connector|
30
- puts " |--> #{connector}"
31
- monitor.properties[:connector].each do |property|
32
- puts " |--> #{monitor.connector[property]}"
33
- end
34
- monitor.properties[:request].each do |property|
35
- puts " |--> #{monitor.request[property]}"
36
- end
37
- end
38
-
39
- puts "Datasources:"
40
- monitor.with :datasources do |datasource|
41
- puts " |--> #{datasource}"
42
- monitor.properties[:datasource].each do |property|
43
- puts " |--> #{monitor.datasource[property]}"
44
- end
45
- end
46
-
47
- puts "Webapps:"
48
- monitor.with :webapps do |webapp|
49
- puts " |--> #{webapp}"
50
- monitor.properties[:webapp].each do |property|
51
- puts " |--> #{monitor.webapp[property]}"
52
- end
53
- end
54
-
55
- puts "Queues:"
56
- monitor.with :queues do |queue|
57
- puts " |--> #{queue}"
58
- monitor.properties[:queue].each do |property|
59
- puts " |--> #{monitor.queue[property]}"
60
- end
61
- end