summaryrefslogtreecommitdiff
path: root/worker/tests/ping.rb
blob: 72769a690f0799bb3dadfc680f79c04221292c90 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
#
# Run a PING test.
#
#
# Return value
#   TRUE:  The host is up
#
#  FALSE:  The host is not up
#
def ping_test( params )

  #
  # Find the binary
  #
  binary = nil
  binary = "./util/multi-ping"  if ( File.exists?( "./util/multi-ping" ) )
  binary = "../util/multi-ping" if ( File.exists?( "../util/multi-ping" ) )

  if ( binary.nil? )
    puts "Failed to find 'multi-ping'"
    exit 1
  end

  #
  # Is it IPv6 or IPv4a
  #
  host = params['target_host']
  if ( system( "#{binary} #{host}" ) == true )
    puts "PING OK"
    return  true
  else
    puts "PING FAILED"
    return false
  end
end