Class: RBoss::CommandActions::Twiddle
- Inherits:
-
Object
- Object
- RBoss::CommandActions::Twiddle
- Defined in:
- lib/rboss/bin/command_actions.rb
Instance Method Summary collapse
- #detail(mbeans) ⇒ Object
- #get(id, property) ⇒ Object
- #info(id, *args) ⇒ Object
-
#initialize(twiddle, opts = {}) ⇒ Twiddle
constructor
A new instance of Twiddle.
- #invoke(id, method, *args) ⇒ Object
- #native(command) ⇒ Object
- #normalize(args) ⇒ Object
- #parse_and_execute(commands) ⇒ Object
- #query(id, *args) ⇒ Object
- #set(id, property, value) ⇒ Object
Constructor Details
#initialize(twiddle, opts = {}) ⇒ Twiddle
Returns a new instance of Twiddle.
27 28 29 30 31 |
# File 'lib/rboss/bin/command_actions.rb', line 27 def initialize twiddle, opts = {} @monitor = twiddle.monitor @twiddle = twiddle @opts = opts end |
Instance Method Details
#detail(mbeans) ⇒ Object
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 |
# File 'lib/rboss/bin/command_actions.rb', line 88 def detail mbeans buff = "" mbeans.each do |mbean_id, resources| builder = RBoss::TableBuilder::new @opts[:mbeans][mbean_id] rows = [] if resources.is_a? TrueClass row = [] @monitor.mbean(mbean_id).detail do |name, value| row << value end rows << row elsif @opts[:no_details] builder.show_only_name @monitor.mbean(mbean_id).scan.each do |name| rows << [name] end else @monitor.mbean(mbean_id).detail resources do |resource, detail| row = [resource] detail.each do |name, value| row << value end rows << row end end table = builder.build_table table.data = rows buff << table.to_s buff << $/ end buff end |
#get(id, property) ⇒ Object
53 54 55 56 57 58 |
# File 'lib/rboss/bin/command_actions.rb', line 53 def get id, property mbean, name = extract id @twiddle.get :mbean => mbean.to_sym, :name => name, :property => property end |
#info(id, *args) ⇒ Object
75 76 77 78 79 80 |
# File 'lib/rboss/bin/command_actions.rb', line 75 def info id, *args mbean, name = extract id @twiddle.info :mbean => mbean.to_sym, :name => name, :args => normalize(args) end |
#invoke(id, method, *args) ⇒ Object
60 61 62 63 64 65 66 |
# File 'lib/rboss/bin/command_actions.rb', line 60 def invoke id, method, *args mbean, name = extract id @twiddle.invoke :mbean => mbean.to_sym, :name => name, :method => method, :args => normalize(args) end |
#native(command) ⇒ Object
41 42 43 |
# File 'lib/rboss/bin/command_actions.rb', line 41 def native command @twiddle.execute(command) end |
#normalize(args) ⇒ Object
82 83 84 85 86 |
# File 'lib/rboss/bin/command_actions.rb', line 82 def normalize args args.collect do |arg| "\"#{arg}\"" end end |
#parse_and_execute(commands) ⇒ Object
33 34 35 36 37 38 39 |
# File 'lib/rboss/bin/command_actions.rb', line 33 def parse_and_execute commands buff = "" commands.each do |method, args| buff << send(method, *args) end buff end |
#query(id, *args) ⇒ Object
68 69 70 71 72 73 |
# File 'lib/rboss/bin/command_actions.rb', line 68 def query id, *args mbean, name = extract id @twiddle.query :mbean => mbean.to_sym, :name => name, :args => normalize(args) end |
#set(id, property, value) ⇒ Object
45 46 47 48 49 50 51 |
# File 'lib/rboss/bin/command_actions.rb', line 45 def set id, property, value mbean, name = extract id @twiddle.set :mbean => mbean.to_sym, :name => name, :property => property, :value => value end |