Ruby 用 Ping 来检查机器和服务的状态

require 'ping'

puts "Pong!" if Ping.pingecho('localhost', 5)

编程技巧