imports de petits utilisatires pour faire des stats et voir les tats de
certains trucs darcs-hash:20050411210725-4ec08-0edcb7b1d4e46ce310dbffcffd8b07e50690c8a1.gz
This commit is contained in:
parent
21f285fabb
commit
477219f2ed
8 changed files with 260 additions and 0 deletions
36
gestion/tools/locate-mac.py
Executable file
36
gestion/tools/locate-mac.py
Executable file
|
@ -0,0 +1,36 @@
|
|||
#! /usr/bin/env python
|
||||
# -*- coding: iso-8859-15 -*-
|
||||
|
||||
import sys
|
||||
sys.path.append('/usr/scripts/gestion')
|
||||
from annuaires import reverse, all_switchs
|
||||
from hptools import hpswitch
|
||||
from time import sleep
|
||||
import threading
|
||||
|
||||
mac = ":".join([i.zfill(2) for i in sys.argv[1].split(":")]).lower()
|
||||
|
||||
# on interroge les switchs
|
||||
|
||||
# classe d'interrogation des switchs
|
||||
class interroge_switch (threading.Thread) :
|
||||
def __init__ (self, switch, mac = None) :
|
||||
threading.Thread.__init__(self)
|
||||
self.switch = switch
|
||||
self.mac = mac
|
||||
self.start()
|
||||
|
||||
def run (self) :
|
||||
sw = hpswitch(self.switch)
|
||||
prise = sw.where_is_mac(mac)
|
||||
if prise != None :
|
||||
# on a trouvé une prise, on affiche si c'est pas un uplink
|
||||
if 'uplink' not in sw.nom(None, prise) or switch == 'backbone' :
|
||||
print "%-10s => prise %-2s : %s" % (self.switch, str(prise), sw.nom(None, prise))
|
||||
|
||||
# on onterroge trois fois car il donne pas toujours les clients
|
||||
for switch in ['backbone'] + all_switchs():
|
||||
interroge_switch(switch, mac)
|
||||
|
||||
while len(threading.enumerate()) > 1 :
|
||||
sleep(1)
|
Loading…
Add table
Add a link
Reference in a new issue