#!/usr/bin/python

import os, threading, time

class ThreadClass(threading.Thread):
	def __init__(self, host):
		threading.Thread.__init__(self)
		self.host = host
		self.lock = threading.Lock()
		self.lock.acquire()
		
	def run(self):
		self.reached = os.system('ping6 -c 2 -W 2 %s >/dev/null' % self.host) == 0
		self.lock.release()

def fq(hosts, domain):
	return map(lambda s: s + '.' + domain, hosts)

HOSTS=['localhost']
HOSTS+=fq(('gauss', 'neumann', 'emo', 'wu', 'archimedes', 'samantha', 'isar', 'orange'), 'gaf.fs.lmu.de')
HOSTS+=fq(('newton', 'leibniz', 'pauli', 'vergil', 'medhurst', 'codd', 'lee', 'zuse'), 'fs.lmu.de')

pool=list(map(ThreadClass, HOSTS))
[t.start() for t in pool]

f="  %%%is   %%s" % max(map(len, HOSTS))
for t in pool:
	t.lock.acquire()
	print(f % (t.host, t.reached and 'up' or 'down'))
