#!/usr/bin/env python import string,sys,os,time if len(sys.argv) > 1: username = sys.argv[1] else: username = "nouser" hostsfile = open('./nfshosts').readlines() hosts = "" for i in hostsfile: if string.find(i,'$') == -1: hosts = hosts + " " + string.strip(string.split(i,'"')[1]) hosts = string.split(hosts) print "Load report on "+time.asctime(time.localtime(time.time())) for h in hosts: status = os.system('ping -c 1' + h + ' >&/dev/null ') if status == 256: print string.ljust(h,10) +':' if username == 'all': print " " + string.strip(string.join(os.popen('ssh ' + h + ' w').readlines())) else: print " " + string.strip(string.join(os.popen('ssh ' + h + ' w | head -1').readlines())) result = string.join(os.popen('ssh ' + h + ' w | grep ' + username).readlines(), " + ") if result <> "" : print " + " + result else: print h + ' est down'