From 6334b9cdfc47bd85b2ce236572e08406324d25cd Mon Sep 17 00:00:00 2001 From: Steve Kemp Date: Mon, 12 Nov 2012 21:00:16 +0000 Subject: Initial dump of code. --- worker/tests/rsync.rb | 48 ++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 48 insertions(+) create mode 100644 worker/tests/rsync.rb (limited to 'worker/tests/rsync.rb') 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 -- cgit v1.2.1