Created
April 14, 2012 19:57
-
-
Save KINGSABRI/2387616 to your computer and use it in GitHub Desktop.
OK Client
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
require 'socket' | |
require 'logger' | |
# OK Client | |
def logger | |
# Creat Log file with rotation | |
log = Logger.new('status.log', 10, 1024000) # Filename: log.txt , Number of rotation: 10 , Rotation Size= 125MB | |
end | |
def status | |
host = "127.0.0.1" | |
begin | |
client_ok = TCPSocket.open(host ,2000) | |
if client_ok.recv(1024).chomp.inspect.include? "OK" | |
puts "Server #{host}: UP" | |
logger.info "Server #{host} : UP" | |
end | |
rescue #Exception => e | |
puts "OMG! Server is down" | |
logger.fatal "Server #{host} : DOWN!" | |
exit | |
end | |
end | |
status |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment