Restructuration du script
darcs-hash:20061004223707-f6463-994434f4fd1bba7c04dd949c6beb180324c8c336.gz
This commit is contained in:
parent
0a6e332ddb
commit
245a057bca
1 changed files with 16 additions and 10 deletions
|
@ -9,9 +9,10 @@ from time import sleep
|
||||||
from os import system
|
from os import system
|
||||||
import threading
|
import threading
|
||||||
|
|
||||||
mac = ":".join([i.zfill(2) for i in sys.argv[1].split(":")]).lower()
|
# mise en forme d'une adresse mac
|
||||||
|
def format_mac(unformated_mac):
|
||||||
|
return ":".join([i.zfill(2) for i in unformated_mac.split(":")]).lower()
|
||||||
|
|
||||||
# on interroge les switchs
|
|
||||||
|
|
||||||
# classe d'interrogation des switchs
|
# classe d'interrogation des switchs
|
||||||
class interroge_switch (threading.Thread) :
|
class interroge_switch (threading.Thread) :
|
||||||
|
@ -27,12 +28,17 @@ class interroge_switch (threading.Thread) :
|
||||||
if prise != None :
|
if prise != None :
|
||||||
print "%-10s => prise %-2s : %s" % (self.switch.encode('iso-8859-15').replace('.adm.crans.org',''), str(prise), sw.nom(None, prise))
|
print "%-10s => prise %-2s : %s" % (self.switch.encode('iso-8859-15').replace('.adm.crans.org',''), str(prise), sw.nom(None, prise))
|
||||||
|
|
||||||
# on onterroge trois fois car il donne pas toujours les clients
|
# interrogation des switchs en parallele
|
||||||
|
def print_trace(mac):
|
||||||
|
|
||||||
for switch in ['backbone'] + all_switchs():
|
for switch in ['backbone'] + all_switchs():
|
||||||
interroge_switch(switch, mac)
|
interroge_switch(switch, mac)
|
||||||
|
|
||||||
while len(threading.enumerate()) > 1 :
|
while len(threading.enumerate()) > 1 :
|
||||||
sleep(1)
|
sleep(1)
|
||||||
|
|
||||||
print
|
# on interroge les switchs et on fait un whos sur la mac
|
||||||
system('/usr/scripts/gestion/whos.py -a mac=%s' % mac)
|
if __name__ == '__main__':
|
||||||
|
mac = format_mac(sys.argv[1])
|
||||||
|
print_trace(mac)
|
||||||
|
print system('/usr/scripts/gestion/whos.py -a mac=%s' % mac)
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue