diff --git a/src/im_mad/im_exec/one_im_exec.rb b/src/im_mad/im_exec/one_im_exec.rb index 42828b6f8d..75c08fc09d 100755 --- a/src/im_mad/im_exec/one_im_exec.rb +++ b/src/im_mad/im_exec/one_im_exec.rb @@ -49,6 +49,16 @@ class InformationManagerDriver < OpenNebulaDriver # register actions register_action(:MONITOR, method("action_monitor")) + + # collectd port + @collectd_port = 4124 + begin + im_collectd = @config["IM_MAD"].select{|e| e.match(/collectd/)}[0] + @collectd_port = im_collectd.match(/-p (\d+)/)[1] + rescue + end + + File.open('/tmp/collectd_port.log','a'){|f| f.puts @collectd_port} end # Execute the run_probes in the remote host @@ -73,9 +83,8 @@ class InformationManagerDriver < OpenNebulaDriver end end - # TODO: Do not hard-code the port - do_action("#{@hypervisor} #{number} 9876", number, host, :MONITOR, - :script_name => 'run_probes', :base64 => true) + do_action("#{@hypervisor} #{number} #{@collectd_port}", number, host, + :MONITOR, :script_name => 'run_probes', :base64 => true) end end diff --git a/src/mad/ruby/DriverExecHelper.rb b/src/mad/ruby/DriverExecHelper.rb index d462db9cc1..2d9afb4f5e 100644 --- a/src/mad/ruby/DriverExecHelper.rb +++ b/src/mad/ruby/DriverExecHelper.rb @@ -15,7 +15,7 @@ #--------------------------------------------------------------------------- # # This module provides an abstraction to generate an execution context for -# OpenNebula Drivers. The module has been designed to be included as part +# OpenNebula Drivers. The module has been designed to be included as part # of a driver and not to be used standalone. module DriverExecHelper # Action result strings for messages @@ -27,7 +27,7 @@ module DriverExecHelper def self.failed?(rc_str) return rc_str == RESULT[:failure] end - + #Initialize module variables def initialize_helper(directory, options) @config = read_configuration @@ -51,7 +51,7 @@ module DriverExecHelper # # METHODS FOR COMMAND LINE & ACTION PATHS - # + # # Given the action name and the parameter returns full path of the script # and appends its parameters. It uses @local_actions hash to know if the # actions is remote or local. If the local actions has defined an special @@ -96,7 +96,7 @@ module DriverExecHelper # # METHODS FOR LOGS & COMMAND OUTPUT - # + # # Sends a message to the OpenNebula core through stdout def send_message(action="-", result=RESULT[:failure], id="-", info="-") @send_mutex.synchronize { @@ -151,7 +151,7 @@ module DriverExecHelper } end - #This method returns the result in terms + #This method returns the result in terms def get_info_from_execution(command_exe) if command_exe.code == 0 result = RESULT[:success] @@ -165,10 +165,10 @@ module DriverExecHelper [result, info] end - + # - # - # Simple parser for the config file generated by OpenNebula + # + # Simple parser for the config file generated by OpenNebula def read_configuration one_config=nil @@ -192,7 +192,16 @@ module DriverExecHelper if m name=m[1].strip.upcase value=m[2].strip - config[name]=value + + if config[name] + if config[name].instance_of? Array + config[name] << value + else + config[name] = [config[name], value] + end + else + config[name]=value + end end end rescue Exception => e