mirror of
https://github.com/OpenNebula/one.git
synced 2025-03-21 14:50:08 +03:00
im-collectd: the collectd-client stops if it receives a onehost sync
This commit is contained in:
parent
0b818bd373
commit
97f63c3659
@ -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?
|
||||
|
@ -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]
|
||||
|
Loading…
x
Reference in New Issue
Block a user