Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- #!/usr/local/bin/ruby
- require 'socket'
- require 'active_record'
- ActiveRecord::Base.establish_connection(
- :adapter => "sqlite3",
- :dbfile => "/rails/wakify/db/development.sqlite3"
- )
- class Status < ActiveRecord::Base
- set_table_name "computers"
- end
- server = TCPServer.open(55523)
- loop do
- Thread.start(server.accept) do |c|
- c.puts("Connected!\n")
- ping = c.readline.chomp
- timestamp = Time.now.strftime("%m/%d/%Y @ %I:%M:%S%p")
- print "#{timestamp} --- Ping check from #{ping}\n"
- c.puts("#{ping} OK!")
- c.close
- suite = Status.first(:conditions => {:host => ping})
- print suite.empty?
- suite.lastping = Time.now.to_i
- suite.save(:validate => false)
- end
- end
Add Comment
Please, Sign In to add comment