// Collection of code snippets by Arne Vajhøj 
// (likely posted to comp.os.vms/INFO-VAX, INFO-TPU, MACRO32, eksperten.dk, newz.dk, LinkedIn or other place sometime between 1990 and now) 
import java.io.IOException;
import java.net.InetAddress;
import java.net.UnknownHostException;
import java.util.Date;

public class Pinger {
    public static void main(String[] args) throws UnknownHostException, IOException, InterruptedException {
        while(true) {
            Date t = new Date();
            String status = InetAddress.getByName("localhost").isReachable(1000) ? "up" : "down";
            System.out.println(t + ": " + status);
            Thread.sleep(5000);
        }
    }
}
