Advertisement
Guest User

Untitled

a guest
Jan 14th, 2012
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.82 KB | None | 0 0
  1. def bool_server_status(servername, ipaddress)
  2. ipvalue = IPAddr.new(ipaddress)
  3. status = 0
  4. route = ""
  5. if !File.exists?("statefiles/" + servername + ".STATE")
  6. status = 2
  7. end
  8. if File.exists?("statefiles/" + servername + ".STATE")
  9. state = "statefiles/" + servername + ".STATE"
  10.  
  11. route = open(state).gets
  12.  
  13.  
  14. begin
  15. timeout(3) do
  16. begin
  17.  
  18. t = TCPSocket.new(ipvalue, 1734)
  19.  
  20.  
  21.  
  22. rescue
  23. status = 0
  24.  
  25. else
  26.  
  27. # ... do something with the socket
  28. t.print "PARADIGM"
  29. line = t.gets
  30.  
  31. #while line = t.gets # Read lines from the socket
  32. puts line # And print with platform line terminator
  33. #end
  34. if (line == "Recieved")
  35. status = 1
  36. t.close
  37.  
  38. return status
  39. end
  40. @val = 1
  41.  
  42.  
  43. #end
  44.  
  45.  
  46.  
  47.  
  48. end
  49.  
  50.  
  51. end
  52. rescue Timeout::Error
  53.  
  54. status = 0
  55.  
  56.  
  57.  
  58.  
  59. end
  60.  
  61. end
  62. return status
  63. end
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement