rboss 0.5.6 → 0.6.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/Gemfile +1 -1
- data/bin/jboss-profile +5 -1
- data/bin/rboss-cli +142 -0
- data/bin/twiddle +7 -3
- data/lib/rboss.rb +2 -1
- data/lib/rboss/bin/command_actions.rb +6 -7
- data/lib/rboss/cli.rb +22 -0
- data/lib/rboss/cli/colorizers.rb +22 -0
- data/lib/rboss/cli/formatters.rb +17 -0
- data/lib/rboss/cli/health_checkers.rb +43 -0
- data/lib/rboss/cli/jboss_cli.rb +93 -0
- data/lib/rboss/{table_builder.rb → cli/mappings.rb} +32 -47
- data/lib/rboss/cli/mappings/resources/connector.yaml +75 -0
- data/lib/rboss/cli/mappings/resources/datasource.yaml +113 -0
- data/lib/rboss/cli/mappings/resources/jdbc_driver.yaml +13 -0
- data/lib/rboss/cli/mappings/resources/server.yaml +74 -0
- data/lib/rboss/cli/resource.rb +112 -0
- data/lib/rboss/component_processor.rb +1 -1
- data/lib/rboss/components/component.rb +1 -1
- data/lib/rboss/components/datasource.rb +1 -1
- data/lib/rboss/components/deploy_folder.rb +1 -1
- data/lib/rboss/components/hypersonic_replacer.rb +1 -1
- data/lib/rboss/components/jbossweb.rb +1 -1
- data/lib/rboss/components/jmx.rb +1 -1
- data/lib/rboss/components/mod_cluster.rb +1 -1
- data/lib/rboss/components/org/6.0/deploy_folder.rb +1 -1
- data/lib/rboss/components/org/jmx.rb +1 -1
- data/lib/rboss/components/profile_folder.rb +1 -1
- data/lib/rboss/components/resource.rb +1 -1
- data/lib/rboss/components/restore_slimming.rb +1 -1
- data/lib/rboss/components/run_conf.rb +1 -1
- data/lib/rboss/components/service_script.rb +1 -1
- data/lib/rboss/components/slimming.rb +1 -1
- data/lib/rboss/components/soa-p/hypersonic_replacer.rb +1 -1
- data/lib/rboss/components/soa-p/jmx.rb +1 -1
- data/lib/rboss/components/xadatasource.rb +1 -1
- data/lib/rboss/file_processor.rb +1 -1
- data/lib/rboss/jboss_path.rb +1 -1
- data/lib/rboss/jboss_profile.rb +1 -1
- data/lib/rboss/twiddle.rb +1 -1
- data/lib/rboss/twiddle/base_monitor.rb +1 -1
- data/lib/rboss/twiddle/mbean.rb +1 -1
- data/lib/rboss/twiddle/monitor.rb +57 -39
- data/lib/rboss/twiddle/twiddle.rb +1 -1
- data/lib/rboss/utils.rb +80 -1
- data/lib/rboss/version.rb +2 -2
- data/test/datasource_test.rb +1 -1
- data/test/deploy_folder_test.rb +1 -1
- data/test/jbossweb_test.rb +1 -1
- data/test/mbean_test.rb +1 -1
- data/test/test_helper.rb +1 -1
- data/test/test_suite.rb +1 -1
- metadata +16 -4
data/Gemfile
CHANGED
data/bin/jboss-profile
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
5
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -83,6 +83,10 @@ end
|
|
83
83
|
opts.on("-h", "--help", "Shows this help message") { puts opts; exit }
|
84
84
|
opts.parse!(ARGV) rescue abort 'Invalid Option! Use --help or -h for usage help.'
|
85
85
|
|
86
|
+
unless $stdout.isatty
|
87
|
+
require 'yummi/no_colors'
|
88
|
+
end
|
89
|
+
|
86
90
|
if params.empty?
|
87
91
|
puts opts
|
88
92
|
exit
|
data/bin/rboss-cli
ADDED
@@ -0,0 +1,142 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
# The MIT License
|
4
|
+
#
|
5
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
6
|
+
#
|
7
|
+
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
|
+
# of this software and associated documentation files (the "Software"), to deal
|
9
|
+
# in the Software without restriction, including without limitation the rights
|
10
|
+
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
11
|
+
# copies of the Software, and to permit persons to whom the Software is
|
12
|
+
# furnished to do so, subject to the following conditions:
|
13
|
+
#
|
14
|
+
# The above copyright notice and this permission notice shall be included in
|
15
|
+
# all copies or substantial portions of the Software.
|
16
|
+
#
|
17
|
+
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
18
|
+
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
19
|
+
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
20
|
+
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
21
|
+
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
22
|
+
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
23
|
+
# THE SOFTWARE.
|
24
|
+
|
25
|
+
require_relative '../lib/rboss'
|
26
|
+
require 'optparse'
|
27
|
+
require 'logger'
|
28
|
+
require 'yaml'
|
29
|
+
require 'fileutils'
|
30
|
+
require 'yummi'
|
31
|
+
|
32
|
+
params = {}
|
33
|
+
@conf_dir = File.expand_path "~/.rboss"
|
34
|
+
servers_file = "#@conf_dir/jboss-cli-servers.yaml"
|
35
|
+
@components = {}
|
36
|
+
@servers_file = File.expand_path(servers_file)
|
37
|
+
save = false
|
38
|
+
params[:jboss_home] = (ENV["JBOSS_HOME"] or ENV["RBOSS_CLI_JBOSS_HOME"] or Dir.pwd)
|
39
|
+
params[:host] = '127.0.0.1'
|
40
|
+
params[:port] = '9999'
|
41
|
+
|
42
|
+
def load_yaml
|
43
|
+
return Hash::new unless File.exist?(@servers_file)
|
44
|
+
YAML::load_file(@servers_file)
|
45
|
+
end
|
46
|
+
|
47
|
+
opts = OptionParser::new
|
48
|
+
opts.on('-j', '--jboss-home PATH', 'Defines the JBOSS_HOME variable') do |home|
|
49
|
+
params[:jboss_home] = home
|
50
|
+
end
|
51
|
+
opts.on('-s URL', 'Defines the JBoss server') do |server|
|
52
|
+
params[:server] = server
|
53
|
+
end
|
54
|
+
opts.on('--host HOST', 'Defines the JBoss host') do |host|
|
55
|
+
params[:host] = host
|
56
|
+
end
|
57
|
+
opts.on('--port PORT', 'Defines the JBoss admin port') do |port|
|
58
|
+
params[:port] = port
|
59
|
+
end
|
60
|
+
opts.on('-c', '--connect SERVER_NAME',
|
61
|
+
"Uses a configured server in #{servers_file}") do |server|
|
62
|
+
config = load_yaml[server]
|
63
|
+
abort "No configuration for #{server}" unless config
|
64
|
+
config.each do |key, value|
|
65
|
+
params[key.to_sym] = value
|
66
|
+
end
|
67
|
+
end
|
68
|
+
opts.on('--save SERVER_NAME', "Saves the server configuration in #{servers_file}") do |server|
|
69
|
+
save = server
|
70
|
+
end
|
71
|
+
opts.on('--loop INTERVAL', Float, 'Runs the mbean inside a loop') do |interval|
|
72
|
+
@loop = true
|
73
|
+
@interval = interval
|
74
|
+
end
|
75
|
+
|
76
|
+
opts.on('--no-color', 'Do not colorize output') do
|
77
|
+
require 'yummi/no_colors'
|
78
|
+
end
|
79
|
+
opts.on('-u', '--user USER', 'Defines the Admin User') do |user|
|
80
|
+
params[:user] = user
|
81
|
+
end
|
82
|
+
opts.on('-p', '--password PASSWORD', 'Defines the Admin Password') do |password|
|
83
|
+
params[:password] = password
|
84
|
+
end
|
85
|
+
opts.on('-v', '--verbose', 'Displays jboss-cli commands before execution') do
|
86
|
+
params[:log_level] = Logger::DEBUG
|
87
|
+
end
|
88
|
+
|
89
|
+
JBoss::Cli::Mappings.resource_mappings.each do |name, config|
|
90
|
+
if config[:scan]
|
91
|
+
opts.on("--#{name} [NAMES]", Array, config[:description]) do |resources|
|
92
|
+
@components[name] = resources || :all
|
93
|
+
end
|
94
|
+
else
|
95
|
+
opts.on("--#{name}", config[:description]) do
|
96
|
+
@components[name] = true
|
97
|
+
end
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
opts.on("-h", "--help", "Shows this help message") do
|
102
|
+
puts opts; exit
|
103
|
+
end
|
104
|
+
opts.parse!(ARGV) rescue abort 'Invalid Option! Use --help or -h for usage help.'
|
105
|
+
|
106
|
+
@jboss_cli = JBoss::Cli::Invoker::new params
|
107
|
+
|
108
|
+
unless $stdout.isatty
|
109
|
+
require 'yummi/no_colors'
|
110
|
+
end
|
111
|
+
|
112
|
+
if save
|
113
|
+
config = load_yaml
|
114
|
+
config[save] ||= {}
|
115
|
+
server_config = config[save]
|
116
|
+
params.delete :jboss_home
|
117
|
+
params.each do |key, value|
|
118
|
+
server_config[key.to_s] = value
|
119
|
+
end
|
120
|
+
FileUtils::mkdir_p File.expand_path(@conf_dir)
|
121
|
+
FileUtils::touch @servers_file
|
122
|
+
f = File.open(@servers_file, 'w')
|
123
|
+
YAML::dump(config, f)
|
124
|
+
f.close
|
125
|
+
puts "Configuration saved!"
|
126
|
+
end
|
127
|
+
|
128
|
+
puts opts if @components.empty?
|
129
|
+
|
130
|
+
def execute_actions
|
131
|
+
content = @jboss_cli.content(@components)
|
132
|
+
system "clear" if @loop
|
133
|
+
puts Yummi.colorize(Time.now.strftime("At %H:%M:%S%n"), :white) if @loop
|
134
|
+
puts content
|
135
|
+
end
|
136
|
+
|
137
|
+
while @loop
|
138
|
+
execute_actions
|
139
|
+
sleep @interval
|
140
|
+
end
|
141
|
+
|
142
|
+
execute_actions
|
data/bin/twiddle
CHANGED
@@ -2,7 +2,7 @@
|
|
2
2
|
|
3
3
|
# The MIT License
|
4
4
|
#
|
5
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
5
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
6
6
|
#
|
7
7
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
8
8
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -46,6 +46,10 @@ 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
|
+
|
49
53
|
opts = OptionParser::new
|
50
54
|
opts.on('-j', '--jboss-home PATH', 'Defines the JBOSS_HOME variable') do |home|
|
51
55
|
params[:jboss_home] = home
|
@@ -179,8 +183,8 @@ end
|
|
179
183
|
puts opts if @mbeans.empty? and @commands.empty?
|
180
184
|
|
181
185
|
@actions = JBoss::CommandActions::Twiddle::new @twiddle,
|
182
|
-
|
183
|
-
|
186
|
+
:no_details => no_details,
|
187
|
+
:mbeans => defaults
|
184
188
|
|
185
189
|
def execute_actions
|
186
190
|
buff = ""
|
data/lib/rboss.rb
CHANGED
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -23,5 +23,6 @@
|
|
23
23
|
require_relative "rboss/version"
|
24
24
|
require_relative "rboss/jboss_profile"
|
25
25
|
require_relative "rboss/twiddle"
|
26
|
+
require_relative "rboss/cli"
|
26
27
|
require_relative "rboss/bin/command_actions"
|
27
28
|
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# The MIT License
|
2
2
|
#
|
3
|
-
# Copyright (c) 2011 Marcelo Guimarães <ataxexe@gmail.com>
|
3
|
+
# Copyright (c) 2011-2012 Marcelo Guimarães <ataxexe@gmail.com>
|
4
4
|
#
|
5
5
|
# Permission is hereby granted, free of charge, to any person obtaining a copy
|
6
6
|
# of this software and associated documentation files (the "Software"), to deal
|
@@ -20,8 +20,6 @@
|
|
20
20
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
21
21
|
# THE SOFTWARE.
|
22
22
|
|
23
|
-
require_relative '../table_builder'
|
24
|
-
|
25
23
|
module JBoss
|
26
24
|
module CommandActions
|
27
25
|
class Twiddle
|
@@ -90,7 +88,7 @@ module JBoss
|
|
90
88
|
def detail mbeans
|
91
89
|
buff = ""
|
92
90
|
mbeans.each do |mbean_id, resources|
|
93
|
-
|
91
|
+
builder = TableBuilder::new @opts[:mbeans][mbean_id]
|
94
92
|
rows = []
|
95
93
|
if resources.is_a? TrueClass
|
96
94
|
row = []
|
@@ -99,7 +97,7 @@ module JBoss
|
|
99
97
|
end
|
100
98
|
rows << row
|
101
99
|
elsif @opts[:no_details]
|
102
|
-
|
100
|
+
builder.show_only_name
|
103
101
|
@monitor.mbean(mbean_id).scan.each do |name|
|
104
102
|
rows << [name]
|
105
103
|
end
|
@@ -112,8 +110,9 @@ module JBoss
|
|
112
110
|
rows << row
|
113
111
|
end
|
114
112
|
end
|
115
|
-
|
116
|
-
|
113
|
+
table = builder.build_table
|
114
|
+
table.data = rows
|
115
|
+
buff << table.to_s
|
117
116
|
end
|
118
117
|
buff
|
119
118
|
end
|
data/lib/rboss/cli.rb
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
require_relative 'cli/jboss_cli'
|
2
|
+
|
3
|
+
if RUBY_PLATFORM['linux']
|
4
|
+
class JBoss::Cli::Invoker
|
5
|
+
|
6
|
+
def jboss_cli
|
7
|
+
"#@jboss_home/bin/jboss-cli.sh"
|
8
|
+
end
|
9
|
+
|
10
|
+
end
|
11
|
+
elsif RUBY_PLATFORM['mingw'] #Windows
|
12
|
+
class JBoss::Cli::Invoker
|
13
|
+
|
14
|
+
def jboss_cli
|
15
|
+
"#@jboss_home/bin/jboss-cli.bat"
|
16
|
+
end
|
17
|
+
|
18
|
+
end
|
19
|
+
else
|
20
|
+
puts "Platform #{RUBY_PLATFORM} not supported"
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,22 @@
|
|
1
|
+
require 'yummi'
|
2
|
+
|
3
|
+
module JBoss
|
4
|
+
module Cli
|
5
|
+
module Colorizers
|
6
|
+
|
7
|
+
def self.boolean params
|
8
|
+
lambda do |value|
|
9
|
+
return params[:if_true] if value
|
10
|
+
params[:if_false]
|
11
|
+
end
|
12
|
+
end
|
13
|
+
|
14
|
+
def self.with params
|
15
|
+
lambda do |value|
|
16
|
+
params[:color]
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
require 'yummi'
|
2
|
+
|
3
|
+
module JBoss
|
4
|
+
module Cli
|
5
|
+
module HealthCheckers
|
6
|
+
|
7
|
+
def self.percentage params
|
8
|
+
PercentageColorizer::new params
|
9
|
+
end
|
10
|
+
|
11
|
+
class PercentageColorizer
|
12
|
+
|
13
|
+
def initialize(params)
|
14
|
+
@max = params[:max]
|
15
|
+
@free = params[:free]
|
16
|
+
@using = params[:using]
|
17
|
+
@color = params[:color] || {
|
18
|
+
:bad => :red,
|
19
|
+
:warn => :brown,
|
20
|
+
:good => :green
|
21
|
+
}
|
22
|
+
@threshold = params[:threshold] || {
|
23
|
+
:warn => 0.15,
|
24
|
+
:bad => 0.30
|
25
|
+
}
|
26
|
+
end
|
27
|
+
|
28
|
+
def call(data)
|
29
|
+
max = data[@max.to_sym].to_f
|
30
|
+
free = @using ? max - data[@using.to_sym].to_f : data[@free.to_sym].to_f
|
31
|
+
|
32
|
+
percentage = free / max
|
33
|
+
|
34
|
+
return @color[:bad] if percentage <= @threshold[:bad]
|
35
|
+
return @color[:warn] if percentage <= @threshold[:warn]
|
36
|
+
@color[:good]
|
37
|
+
end
|
38
|
+
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
end
|
43
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# The MIT License
|
2
|
+
#
|
3
|
+
# Copyright (c) 2011-2012 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
|
+
require_relative 'resource'
|
24
|
+
require_relative 'mappings'
|
25
|
+
|
26
|
+
require 'logger'
|
27
|
+
|
28
|
+
module JBoss
|
29
|
+
|
30
|
+
module Cli
|
31
|
+
|
32
|
+
class Invoker
|
33
|
+
include JBoss::Cli::Mappings
|
34
|
+
|
35
|
+
attr_reader :server, :host, :port, :user, :password
|
36
|
+
|
37
|
+
def initialize(params = {})
|
38
|
+
params = {
|
39
|
+
:jboss_home => ENV["JBOSS_HOME"],
|
40
|
+
}.merge! params
|
41
|
+
|
42
|
+
@jboss_home = params[:jboss_home]
|
43
|
+
|
44
|
+
@server = params[:server]
|
45
|
+
@host = params[:host]
|
46
|
+
@port = params[:port]
|
47
|
+
@server ||= [@host, @port].join ':' if @host and @port
|
48
|
+
|
49
|
+
@user = params[:user]
|
50
|
+
@password = params[:password]
|
51
|
+
|
52
|
+
@logger = params[:logger]
|
53
|
+
unless @logger
|
54
|
+
@logger = Logger::new STDOUT
|
55
|
+
@logger.level = params[:log_level] || Logger::INFO
|
56
|
+
formatter = Yummi::Formatter::LogFormatter.new do |severity, message|
|
57
|
+
"#{severity} : #{message}"
|
58
|
+
end
|
59
|
+
@logger.formatter = formatter
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
63
|
+
def command
|
64
|
+
command = "#{jboss_cli} --connect"
|
65
|
+
command << " --controller=#@server" if @server
|
66
|
+
command << " --user='#@user'" if @user
|
67
|
+
command << " --password='#@password'" if @password
|
68
|
+
command
|
69
|
+
end
|
70
|
+
|
71
|
+
def content(components)
|
72
|
+
buff = ""
|
73
|
+
components.each do |key, resources|
|
74
|
+
if resource_mappings.has_key? key
|
75
|
+
mapping = resource_mappings[key]
|
76
|
+
component = JBoss::Cli::Resource::new(self, mapping)
|
77
|
+
buff << component.content(resources)
|
78
|
+
end
|
79
|
+
end
|
80
|
+
buff
|
81
|
+
end
|
82
|
+
|
83
|
+
def execute(*commands)
|
84
|
+
exec = "#{command} --commands=\"#{commands.join ','}\""
|
85
|
+
@logger.debug exec
|
86
|
+
`#{exec}`.chomp
|
87
|
+
end
|
88
|
+
|
89
|
+
end
|
90
|
+
|
91
|
+
end
|
92
|
+
|
93
|
+
end
|