[munin] strip wsp
darcs-hash:20100211115432-bd074-21666d2a895a1476c2af86a6968e60f6e011858e.gz
This commit is contained in:
parent
909aff2221
commit
2b2226644a
3 changed files with 14 additions and 14 deletions
|
@ -49,7 +49,7 @@ if 'config' in sys.argv :
|
||||||
print "graph_args --base 1000";
|
print "graph_args --base 1000";
|
||||||
print "graph_vlabel nb clients/chaines";
|
print "graph_vlabel nb clients/chaines";
|
||||||
inc = 0
|
inc = 0
|
||||||
chaines = chaines.values()
|
chaines = chaines.values()
|
||||||
chaines.sort()
|
chaines.sort()
|
||||||
for nom in chaines :
|
for nom in chaines :
|
||||||
if not nom : continue
|
if not nom : continue
|
||||||
|
@ -69,12 +69,12 @@ if 'config' in sys.argv :
|
||||||
|
|
||||||
if 'generate' in sys.argv :
|
if 'generate' in sys.argv :
|
||||||
stats = {} # { IP : [ prises ] }
|
stats = {} # { IP : [ prises ] }
|
||||||
|
|
||||||
for switch in all_switchs() :
|
for switch in all_switchs() :
|
||||||
# on vérifie que le switch est pingable
|
# on vérifie que le switch est pingable
|
||||||
if os.system('ping -c 3 %s > /dev/null 2> /dev/null' % switch ) :
|
if os.system('ping -c 3 %s > /dev/null 2> /dev/null' % switch ) :
|
||||||
continue
|
continue
|
||||||
|
|
||||||
sw = hpswitch(switch)
|
sw = hpswitch(switch)
|
||||||
switch=switch.split('.')[0]
|
switch=switch.split('.')[0]
|
||||||
if switch[-1].isalpha() :
|
if switch[-1].isalpha() :
|
||||||
|
@ -84,19 +84,19 @@ if 'generate' in sys.argv :
|
||||||
bat = switch[-3].lower()
|
bat = switch[-3].lower()
|
||||||
sw_num = int(switch[-1])
|
sw_num = int(switch[-1])
|
||||||
|
|
||||||
if bat not in uplink_prises: #Adg fait de la merde avec l'annuaire
|
#if bat not in uplink_prises:
|
||||||
continue
|
# continue
|
||||||
for ip, liste in sw.multicast().items() :
|
for ip, liste in sw.multicast().items() :
|
||||||
stats.setdefault(ip,[])
|
stats.setdefault(ip,[])
|
||||||
for port in liste :
|
for port in liste :
|
||||||
num_port = 100 * sw_num + int(port)
|
num_port = 100 * sw_num + int(port)
|
||||||
if num_port not in uplink_prises[bat].keys() :
|
if num_port not in uplink_prises[bat].keys() :
|
||||||
stats[ip].append('%s%03i' % (bat, num_port) )
|
stats[ip].append('%s%03i' % (bat, num_port) )
|
||||||
|
|
||||||
total = 0
|
total = 0
|
||||||
|
|
||||||
f = open('/var/lib/munin/tmp/audimat','w')
|
f = open('/var/lib/munin/tmp/audimat','w')
|
||||||
|
|
||||||
for ip, nom in chaines.items() :
|
for ip, nom in chaines.items() :
|
||||||
if not nom : continue
|
if not nom : continue
|
||||||
nb_clients = len(stats.get(ip,[]))
|
nb_clients = len(stats.get(ip,[]))
|
||||||
|
|
|
@ -28,7 +28,7 @@ def switch_prise(bat, prise) :
|
||||||
multiprise = map(lambda x : len(x[1])>1 and x[0], reverse(BAT).items())
|
multiprise = map(lambda x : len(x[1])>1 and x[0], reverse(BAT).items())
|
||||||
while False in multiprise :
|
while False in multiprise :
|
||||||
multiprise.remove(False)
|
multiprise.remove(False)
|
||||||
|
|
||||||
try :
|
try :
|
||||||
arg = sys.argv[1]
|
arg = sys.argv[1]
|
||||||
except :
|
except :
|
||||||
|
@ -73,7 +73,7 @@ else :
|
||||||
except:
|
except:
|
||||||
PRISES_ENABLE -= 0
|
PRISES_ENABLE -= 0
|
||||||
print "enabled.value %d" % PRISES_ENABLE
|
print "enabled.value %d" % PRISES_ENABLE
|
||||||
|
|
||||||
PRISES_ACTIVES = 0
|
PRISES_ACTIVES = 0
|
||||||
for switch in all_switchs(BAT) :
|
for switch in all_switchs(BAT) :
|
||||||
try:
|
try:
|
||||||
|
@ -115,16 +115,16 @@ else :
|
||||||
NB_PRISES += PRISES_FIXES
|
NB_PRISES += PRISES_FIXES
|
||||||
print "prises.value %d" % NB_PRISES
|
print "prises.value %d" % NB_PRISES
|
||||||
|
|
||||||
|
|
||||||
print "reste.value %d" % int(NB_PRISES - PRISES_ENABLE - PRISES_FIXES - PRISES_CRANS)
|
print "reste.value %d" % int(NB_PRISES - PRISES_ENABLE - PRISES_FIXES - PRISES_CRANS)
|
||||||
|
|
||||||
fichier = open(stats_batiments, 'r')
|
fichier = open(stats_batiments, 'r')
|
||||||
#NB_ADHERENT = 0 # Plus génant qu'autre chose
|
#NB_ADHERENT = 0 # Plus génant qu'autre chose
|
||||||
for line in fichier.readlines():
|
for line in fichier.readlines():
|
||||||
if line[3:4] == BAT and line[:3] == "bat" :
|
if line[3:4] == BAT and line[:3] == "bat" :
|
||||||
NB_ADHERENT = line[11:].strip()
|
NB_ADHERENT = line[11:].strip()
|
||||||
print "adherent.value %s" % NB_ADHERENT
|
print "adherent.value %s" % NB_ADHERENT
|
||||||
|
|
||||||
if BAT in BAT_CHBRES.keys() :
|
if BAT in BAT_CHBRES.keys() :
|
||||||
print "chbres.value %d" % BAT_CHBRES[BAT]
|
print "chbres.value %d" % BAT_CHBRES[BAT]
|
||||||
print "connues.value %d" % len(chbre_prises[BAT].keys())
|
print "connues.value %d" % len(chbre_prises[BAT].keys())
|
||||||
|
|
|
@ -34,7 +34,7 @@ elif arg == "fichier" :
|
||||||
ips = [ x.ip() for x in crans_ldap().search('ip=*')['machine'] ]
|
ips = [ x.ip() for x in crans_ldap().search('ip=*')['machine'] ]
|
||||||
|
|
||||||
out = file(fichier, "w")
|
out = file(fichier, "w")
|
||||||
|
|
||||||
for subnet in NETs :
|
for subnet in NETs :
|
||||||
total = 0
|
total = 0
|
||||||
for net in NETs[subnet]:
|
for net in NETs[subnet]:
|
||||||
|
@ -44,7 +44,7 @@ elif arg == "fichier" :
|
||||||
|
|
||||||
utilisees = len( [ ip for ip in ips if AddrInNet( ip, NETs[subnet] ) ] )
|
utilisees = len( [ ip for ip in ips if AddrInNet( ip, NETs[subnet] ) ] )
|
||||||
pourcentage = int((utilisees*100)/total)
|
pourcentage = int((utilisees*100)/total)
|
||||||
|
|
||||||
nom = subnet.replace('-', '')
|
nom = subnet.replace('-', '')
|
||||||
out.write("%s.value %d\n" % (nom, pourcentage))
|
out.write("%s.value %d\n" % (nom, pourcentage))
|
||||||
else:
|
else:
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue