diff options
Diffstat (limited to 'worker/tests/rsync.rb')
-rw-r--r-- | worker/tests/rsync.rb | 48 |
1 files changed, 48 insertions, 0 deletions
diff --git a/worker/tests/rsync.rb b/worker/tests/rsync.rb new file mode 100644 index 0000000..2c781d8 --- /dev/null +++ b/worker/tests/rsync.rb @@ -0,0 +1,48 @@ +require 'timeout' + + +# +# Run an rsync test. +# +# +# Return value +# TRUE: The host is up +# +# FALSE: The host is not up +# +def rsync_test ( params ) + + # + # Get the hostname + # + host = params['target_host'] + port = 873 + + puts "rsync testing host #{host}:#{port}" + + + begin + timeout(3) do + + begin + socket = TCPSocket.new( host, port ) + socket.puts( "QUIT") + banner = socket.gets(nil) + socket.close() + + banner = banner[0,20] + if ( banner =~ /rsyncd/i ) + puts "rsync alive: #{banner}" + return true + end + rescue + puts "Exception on host #{host}:#{port} - #{$!}" + return false + end + end + rescue Timeout::Error => e + puts "TIMEOUT: #{e}" + return false + end + return false +end |