[annuaires/munin] rajouts de switchs
This commit is contained in:
parent
15bc866616
commit
d059fb154b
3 changed files with 31 additions and 29 deletions
|
@ -82,7 +82,7 @@ def reverse(batiment, prise = None):
|
||||||
if not ret:
|
if not ret:
|
||||||
raise ValueError("Batiment inexistant")
|
raise ValueError("Batiment inexistant")
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
@_need_conn
|
@_need_conn
|
||||||
def is_crans(batiment, chambre):
|
def is_crans(batiment, chambre):
|
||||||
"""Chambre cablee au Cr@ns ?"""
|
"""Chambre cablee au Cr@ns ?"""
|
||||||
|
@ -137,25 +137,26 @@ uplink_prises={ 'a' :
|
||||||
301 : 'uplink->batc-0', 302 : 'uplink->batc-1',
|
301 : 'uplink->batc-0', 302 : 'uplink->batc-1',
|
||||||
303 : 'uplink->batc-2', 324 : 'uplink->backbone' },
|
303 : 'uplink->batc-2', 324 : 'uplink->backbone' },
|
||||||
'g' :
|
'g' :
|
||||||
{
|
{
|
||||||
21 : 'libre-service', 22 : 'uplink->backbone',
|
21 : 'libre-service', 22 : 'uplink->backbone',
|
||||||
23 : 'libre-service', 24 : 'uplink->batg-8',
|
23 : 'libre-service', 24 : 'uplink->batg-8',
|
||||||
|
|
||||||
149 : 'uplink->batg-8', 150 : 'libre-service',
|
149 : 'uplink->batg-8', 150 : 'libre-service',
|
||||||
|
|
||||||
249 : 'uplink->batg-8', 250 : 'uplink->batg-3',
|
249 : 'uplink->batg-8', 250 : 'uplink->batg-3',
|
||||||
|
|
||||||
325 : 'uplink->batg-8', 326 : 'libre-service',
|
325 : 'uplink->batg-8', 326 : 'libre-service',
|
||||||
|
|
||||||
449 : 'uplink->batg-9', 450 : 'uplink->batg-5',
|
449 : 'uplink->batg-9', 450 : 'uplink->batg-5',
|
||||||
|
|
||||||
549 : 'uplink->batg-9', 550 : 'uplink->batg-6',
|
549 : 'uplink->batg-9', 550 : 'uplink->batg-6',
|
||||||
|
|
||||||
649 : 'uplink->batg-9', 650 : 'uplink->batg-5',
|
649 : 'uplink->batg-9', 650 : 'uplink->batg-5',
|
||||||
|
|
||||||
725 : 'uplink->batg-9', 726 : 'libre-service',
|
725 : 'uplink->batg-9', 726 : 'libre-service',
|
||||||
|
|
||||||
801 : 'uplink->batg-1', 802 : 'uplink->batg-2',
|
801 : 'uplink->batg-1', 802 : 'uplink->batg-2',
|
||||||
|
|
||||||
803 : 'uplink->batg-3', 821 : 'uplink->batg-0',
|
803 : 'uplink->batg-3', 821 : 'uplink->batg-0',
|
||||||
823 : 'uplink->batg-9',
|
823 : 'uplink->batg-9',
|
||||||
|
|
||||||
|
@ -207,7 +208,7 @@ uplink_prises={ 'a' :
|
||||||
'p' :
|
'p' :
|
||||||
{
|
{
|
||||||
49 : 'uplink->batp-4',
|
49 : 'uplink->batp-4',
|
||||||
149: 'uplink->batp-4',
|
149: 'uplink->batp-4',
|
||||||
249: 'uplink->batp-4',
|
249: 'uplink->batp-4',
|
||||||
350: 'uplink->batp-4',
|
350: 'uplink->batp-4',
|
||||||
# On ne génère pas la conf de batp-4 automatiquement, mais ses uplinks
|
# On ne génère pas la conf de batp-4 automatiquement, mais ses uplinks
|
||||||
|
@ -217,7 +218,7 @@ uplink_prises={ 'a' :
|
||||||
405: 'libre-service', 406: 'uplink->bato-1',
|
405: 'libre-service', 406: 'uplink->bato-1',
|
||||||
},
|
},
|
||||||
'o' :
|
'o' :
|
||||||
{
|
{
|
||||||
25 : 'uplink->bato-1', 26 : 'libre-service',
|
25 : 'uplink->bato-1', 26 : 'libre-service',
|
||||||
101 : 'uplink->bato-0', 121: 'uplink->NRD',
|
101 : 'uplink->bato-0', 121: 'uplink->NRD',
|
||||||
122: 'uplink->backbone', 123: 'uplink->backbone (unused)',
|
122: 'uplink->backbone', 123: 'uplink->backbone (unused)',
|
||||||
|
@ -250,29 +251,30 @@ uplink_prises={ 'a' :
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
def all_switchs(bat=None):
|
def all_switchs(bat=None, hide=['backbone.adm.crans.org',
|
||||||
|
'multiprise-v6.adm.crans.org',
|
||||||
|
'batk-0.crans.org']):
|
||||||
"""Retourne la liste des switchs pour un batiment.
|
"""Retourne la liste des switchs pour un batiment.
|
||||||
|
|
||||||
Si bat est donné, seulement pour le bâtiment demandé, sinon pour
|
Si bat est donné, seulement pour le bâtiment demandé, sinon pour
|
||||||
tous les bâtiments. bat peut être une liste aussi. Le backbone n'est
|
tous les bâtiments. bat peut être une liste aussi. Le backbone n'est
|
||||||
pas pris en compte. La convention est batx-y sauf si y=0 et on a donc
|
pas pris en compte. La convention est batx-y sauf si y=0 et on a donc
|
||||||
simplement batx"""
|
simplement batx"""
|
||||||
def cmp(x,y):
|
|
||||||
if int(x[5]) < int(y[5]): return 1
|
|
||||||
if x[3] < y[3]: return 1
|
|
||||||
return -1
|
|
||||||
|
|
||||||
if bat == None:
|
if bat == None:
|
||||||
bat = bat_switchs
|
bat = bat_switchs
|
||||||
if type(bat) not in [ tuple, list ] :
|
if type(bat) not in [ tuple, list ] :
|
||||||
bat = [bat]
|
bat = [bat]
|
||||||
switchs = []
|
switchs = []
|
||||||
for b in map(lambda x: x.lower(), bat):
|
for b in bat:
|
||||||
dup = map(lambda x: x[0], reverse(b).keys())
|
indexes = set(n/100 for n in uplink_prises[b])
|
||||||
# dup contient des elements en double
|
for i in indexes:
|
||||||
for n in list(dict(zip(dup,[None]*len(dup)))):
|
switchs.append("bat%s-%s.adm.crans.org" % (b, i))
|
||||||
switchs.append("bat%s-%s.adm.crans.org" % (b, n))
|
# on ajoute quand-même le backbone et/ou multiprise-v6 si demandé
|
||||||
switchs.sort(cmp)
|
switchs += set(['backbone.adm.crans.org', 'multiprise-v6.adm.crans.org',
|
||||||
|
'batk-0.crans.org']).difference(hide)
|
||||||
|
|
||||||
|
switchs.sort()
|
||||||
return switchs
|
return switchs
|
||||||
|
|
||||||
# Locaux clubs : lecture dans chbre_prises et ajout des locaux dans les bats non
|
# Locaux clubs : lecture dans chbre_prises et ajout des locaux dans les bats non
|
||||||
|
|
|
@ -37,7 +37,7 @@ file_host=`basename $0 | sed 's/^ping_//g' | sed 's/_/-/g'`
|
||||||
host=${host:-${file_host:-www.google.com}}
|
host=${host:-${file_host:-www.google.com}}
|
||||||
|
|
||||||
if [ "$1" = "config" ]; then
|
if [ "$1" = "config" ]; then
|
||||||
echo host_name `basename $host | sed 's/-//g'`
|
echo host_name `basename $host`
|
||||||
echo graph_title Ping times from $hostname
|
echo graph_title Ping times from $hostname
|
||||||
echo 'graph_args --base 1000 -l 0'
|
echo 'graph_args --base 1000 -l 0'
|
||||||
echo 'graph_vlabel seconds'
|
echo 'graph_vlabel seconds'
|
||||||
|
|
|
@ -101,7 +101,6 @@ hosts_plugins = {
|
||||||
"audimat": "audimat",
|
"audimat": "audimat",
|
||||||
"batiments": "batiments",
|
"batiments": "batiments",
|
||||||
"munin": "munin",
|
"munin": "munin",
|
||||||
"ping_multiprise_v6.adm": "ping_",
|
|
||||||
"stats-ip": "stats-ip",
|
"stats-ip": "stats-ip",
|
||||||
# La suite plus bas...
|
# La suite plus bas...
|
||||||
},
|
},
|
||||||
|
@ -133,11 +132,12 @@ for bat in annuaires.bat_switchs:
|
||||||
hosts_plugins["dyson"]["stats-batiment_%s" % bat] = "stats-batiment_"
|
hosts_plugins["dyson"]["stats-batiment_%s" % bat] = "stats-batiment_"
|
||||||
|
|
||||||
# Ping de tous les switches de bâtiments
|
# Ping de tous les switches de bâtiments
|
||||||
for switch in annuaires.all_switchs():
|
for switch in annuaires.all_switchs(hide=[]):
|
||||||
# Suppression du .adm.crans.org
|
# Suppression du .crans.org pour plus de clarté dans les confs
|
||||||
switch = switch[:switch.index('.')]
|
# (tous les switchs n'étant pas sur adm, on garde quand-même ce suffixe)
|
||||||
|
switch = switch[:switch.rindex('.crans.org')]
|
||||||
switch = switch.replace('-', '_')
|
switch = switch.replace('-', '_')
|
||||||
hosts_plugins["dyson"]["ping_%s.adm" % switch] = "ping_bat_"
|
hosts_plugins["dyson"]["ping_%s" % switch] = "ping_bat_"
|
||||||
|
|
||||||
# On rajoute les stats de connexion
|
# On rajoute les stats de connexion
|
||||||
for host in hosts_plugins.keys():
|
for host in hosts_plugins.keys():
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue