From 3fc1f0323984539c9e1a9238f6dde7b080689677 Mon Sep 17 00:00:00 2001 From: "Ruben S. Montero" Date: Thu, 7 Oct 2010 18:08:59 +0200 Subject: [PATCH] Pass run_probes arguments to the probes. IM ssh and sh now also sends the host to be monitored --- src/im_mad/im_sh/one_im_sh.rb | 17 ++++++++--------- src/im_mad/im_ssh/one_im_ssh.rb | 14 +++++++------- src/im_mad/remotes/run_probes | 8 +++----- 3 files changed, 18 insertions(+), 21 deletions(-) diff --git a/src/im_mad/im_sh/one_im_sh.rb b/src/im_mad/im_sh/one_im_sh.rb index d9dbf30d5b..392af18898 100755 --- a/src/im_mad/im_sh/one_im_sh.rb +++ b/src/im_mad/im_sh/one_im_sh.rb @@ -45,12 +45,12 @@ class InformationManager < OpenNebulaDriver #--------------------------------------------------------------------------- def initialize(hypervisor, num) super(num, true) - - @config = read_configuration - @hypervisor = hypervisor - @cmd_path = "#{ENV['ONE_LOCATION']}/lib/remotes/im/#{hypervisor}.d" - + @config = read_configuration + @hypervisor = hypervisor + + @cmd_path = "#{ENV['ONE_LOCATION']}/lib/remotes/im/#{hypervisor}.d" + # register actions register_action(:MONITOR, method("action_monitor")) end @@ -62,11 +62,10 @@ class InformationManager < OpenNebulaDriver log_lambda=lambda do |message| log(number, message) end - - cmd = "#{@cmd_path}/#{@hypervisor}.rb #{host}" - monitor_exe = LocalCommand.run(cmd, host, log_method(id)) - + cmd_string = "#{@remote_dir}/im/run_probes #{@hypervisor} #{host}" + monitor_exe = LocalCommand.run(cmd_string, host, log_method(id)) + if monitor_exe.code == 0 send_message("MONITOR", RESULT[:success], number, monitor_exe.stdout) else diff --git a/src/im_mad/im_ssh/one_im_ssh.rb b/src/im_mad/im_ssh/one_im_ssh.rb index 12b851a490..0ab0b31794 100755 --- a/src/im_mad/im_ssh/one_im_ssh.rb +++ b/src/im_mad/im_ssh/one_im_ssh.rb @@ -45,12 +45,12 @@ class InformationManager < OpenNebulaDriver #--------------------------------------------------------------------------- def initialize(hypervisor, num) super(num, true) - + @config = read_configuration - + @hypervisor = hypervisor @remote_dir = @config['SCRIPTS_REMOTE_DIR'] || '/tmp/one' - + # register actions register_action(:MONITOR, method("action_monitor")) end @@ -62,18 +62,18 @@ class InformationManager < OpenNebulaDriver log_lambda=lambda do |message| log(number, message) end - + if do_update == "1" # Use SCP to sync: sync_cmd = "scp -r #{REMOTES_LOCATION}/. #{host}:#{@remote_dir}" - + # Use rsync to sync: # sync_cmd = "rsync -Laz #{REMOTES_LOCATION} #{host}:#{@remote_dir}" LocalCommand.run(sync_cmd, log_lambda) end - cmd = SSHCommand.run("#{@remote_dir}/im/run_probes #{@hypervisor}", - host, log_lambda) + cmd_string = "#{@remote_dir}/im/run_probes #{@hypervisor} #{host}" + cmd = SSHCommand.run(cmd_string, host, log_lambda) if cmd.code == 0 send_message("MONITOR", RESULT[:success], number, cmd.stdout) diff --git a/src/im_mad/remotes/run_probes b/src/im_mad/remotes/run_probes index e837acf2d2..f32f2f58a2 100755 --- a/src/im_mad/remotes/run_probes +++ b/src/im_mad/remotes/run_probes @@ -16,19 +16,17 @@ # limitations under the License. # #--------------------------------------------------------------------------- # -HYPERVISOR_DIR=$1.d - SCRIPTS_DIR=`dirname $0` cd $SCRIPTS_DIR function run_dir { ( - DIR=$1 + DIR=$1.d cd $DIR for i in `ls *`;do if [ -x "$i" ]; then - ./$i + ./$i $* EXIT_CODE=$? if [ "x$EXIT_CODE" != "x0" ]; then echo "Error executing $i" 1>&2 @@ -41,7 +39,7 @@ function run_dir { data=$( if [ -d "$HYPERVISOR_DIR" ]; then - run_dir $HYPERVISOR_DIR + run_dir $* fi )