summaryrefslogtreecommitdiff
path: root/worker/tests/rsync.rb
diff options
context:
space:
mode:
authorSteve Kemp <steve@steve.org.uk>2012-11-12 21:00:16 +0000
committerSteve Kemp <steve@steve.org.uk>2012-11-12 21:00:16 +0000
commit6334b9cdfc47bd85b2ce236572e08406324d25cd (patch)
treebd0bd3cc279d8377efde2affc8dc223bfb858ca2 /worker/tests/rsync.rb
Initial dump of code.
Diffstat (limited to 'worker/tests/rsync.rb')
-rw-r--r--worker/tests/rsync.rb48
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