diff --git a/src/cli/one_helper/onehost_helper.rb b/src/cli/one_helper/onehost_helper.rb index 970414c86d..0692a9c71d 100644 --- a/src/cli/one_helper/onehost_helper.rb +++ b/src/cli/one_helper/onehost_helper.rb @@ -173,6 +173,10 @@ class OneHostHelper < OpenNebulaHelper::OneHelper return -1,error_msg end + # Touch the update file + FileUtils.touch(File.join(REMOTES_LOCATION,'.update')) + + # Get the Host pool filter_flag ||= OpenNebula::Pool::INFO_ALL pool = factory_pool(filter_flag) @@ -180,6 +184,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper rc = pool.info return -1, rc.message if OpenNebula.is_error?(rc) + # Assign hosts to threads i = 0 hs_threads = Array.new pool.each do |host| @@ -188,6 +193,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper i+=1 end + # Run the jobs in threads host_errors = Array.new lock = Mutex.new @@ -206,6 +212,7 @@ class OneHostHelper < OpenNebulaHelper::OneHelper } end + # Wait for threads to finish ts.each{|t| t.join} if host_errors.empty? diff --git a/src/im_mad/remotes/common.d/collectd-client.rb b/src/im_mad/remotes/common.d/collectd-client.rb index bf332972ca..3ebfb7f636 100644 --- a/src/im_mad/remotes/common.d/collectd-client.rb +++ b/src/im_mad/remotes/common.d/collectd-client.rb @@ -20,6 +20,7 @@ require 'socket' require 'base64' DIRNAME = File.dirname(__FILE__) +REMOTE_DIR_UPDATE = File.join(DIRNAME, '../../.update') CYCLE = 20 TOTAL_HOSTS = 1000 @@ -42,6 +43,9 @@ class CollectdClient run_probes_cmd = File.join(DIRNAME, '..', "run_probes") @run_probes_cmd = "#{run_probes_cmd} #{@hypervisor}-probes" + # Get last update + @last_update = get_last_update + # Socket @s = UDPSocket.new end @@ -86,6 +90,9 @@ class CollectdClient last_send = nil loop do + # Stop the execution if we receive the update signal + exit 0 if stop? + t = Time.now.to_i current_cycle = t / CYCLE @@ -108,6 +115,14 @@ class CollectdClient sleep SLEEP end end + + def get_last_update + File.stat(REMOTE_DIR_UPDATE).mtime.to_i rescue 0 + end + + def stop? + get_last_update.to_i != @last_update.to_i + end end hypervisor = ARGV[0]