[wifi/{bornes.py,status.py}] légères modifications maintenant que gordon est le routeur wifi
darcs-hash:20091109025242-bd074-2a7b80e68944e1a6e949eedfac93dd94a01ab4ef.gz
This commit is contained in:
parent
61d31e04a0
commit
c541996784
2 changed files with 21 additions and 14 deletions
|
@ -23,7 +23,7 @@ def bornes():
|
||||||
Moyen rapide, mais peut-être un peu crade pour récupérer la liste des bornes:
|
Moyen rapide, mais peut-être un peu crade pour récupérer la liste des bornes:
|
||||||
on regarde les machines présentes dans 138.231.148.1/24"""
|
on regarde les machines présentes dans 138.231.148.1/24"""
|
||||||
names = []
|
names = []
|
||||||
for line in commands.getoutput("host -l wifi.crans.org").splitlines():
|
for line in commands.getoutput("host -l wifi.crans.org sable.crans.org").splitlines()[5:]:
|
||||||
# Chaque ligne est de la forme:
|
# Chaque ligne est de la forme:
|
||||||
# "truc.wifi.crans.org has address 138.231.148.42"
|
# "truc.wifi.crans.org has address 138.231.148.42"
|
||||||
fields = line.split()
|
fields = line.split()
|
||||||
|
@ -123,6 +123,7 @@ def munin(config, cmd=None, process=(lambda x: x), results=None, buckets=None, s
|
||||||
|
|
||||||
if 'config' in sys.argv:
|
if 'config' in sys.argv:
|
||||||
print config
|
print config
|
||||||
|
print "graph_category wifi"
|
||||||
if buckets:
|
if buckets:
|
||||||
for i, (val, lbl) in enumerate(buckets.items()):
|
for i, (val, lbl) in enumerate(buckets.items()):
|
||||||
print "%s.label %s" % (lbl, val)
|
print "%s.label %s" % (lbl, val)
|
||||||
|
@ -164,6 +165,10 @@ def main():
|
||||||
action='store_const', const='uname -v', dest='cmd', default='uname -v')
|
action='store_const', const='uname -v', dest='cmd', default='uname -v')
|
||||||
parser.add_option('-u', '--uptime', help=u"renvoie l'uptime",
|
parser.add_option('-u', '--uptime', help=u"renvoie l'uptime",
|
||||||
action='store_const', const='uptime', dest='cmd')
|
action='store_const', const='uptime', dest='cmd')
|
||||||
|
parser.add_option('-w', '--mac-wifi',
|
||||||
|
help=u"renvoie l'addresse MAC de l'access point",
|
||||||
|
action='store_const', dest='cmd',
|
||||||
|
const="iwconfig wl0 | sed -n 's/^.*00:/00:/p'")
|
||||||
parser.add_option('-c', '--custom', help=u'exécute une commande custom',
|
parser.add_option('-c', '--custom', help=u'exécute une commande custom',
|
||||||
action='store', dest='cmd')
|
action='store', dest='cmd')
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
#! /usr/bin/env python
|
#! /usr/bin/env python
|
||||||
# -*- encoding: iso-8859-15 -*-
|
# -*- coding: iso-8859-15 -*-
|
||||||
|
|
||||||
# Génération d'un fichier XML indiquant le status des bornes
|
# Génération d'un fichier XML indiquant le status des bornes
|
||||||
|
|
||||||
|
@ -25,6 +25,7 @@ xml_bornes.setAttribute(u"date",time.strftime("%c"))
|
||||||
|
|
||||||
# On récupère l'ensemble des bornes
|
# On récupère l'ensemble des bornes
|
||||||
bornes = l.search('host=*.wifi.crans.org&canal=*')['borneWifi']
|
bornes = l.search('host=*.wifi.crans.org&canal=*')['borneWifi']
|
||||||
|
bornes.sort(cmp=(lambda x, y: cmp(x.nom(), y.nom())))
|
||||||
|
|
||||||
canaux = bornes_canal()
|
canaux = bornes_canal()
|
||||||
clients = bornes_clients()
|
clients = bornes_clients()
|
||||||
|
@ -32,7 +33,6 @@ uptimes = bornes_uptime()
|
||||||
|
|
||||||
for b in bornes:
|
for b in bornes:
|
||||||
infos = filter(lambda x: not x.startswith("<"), b.info())
|
infos = filter(lambda x: not x.startswith("<"), b.info())
|
||||||
|
|
||||||
if not infos or b.nom().split('.')[0]=="non-configure":
|
if not infos or b.nom().split('.')[0]=="non-configure":
|
||||||
# Rien à propos de cette borne...
|
# Rien à propos de cette borne...
|
||||||
continue
|
continue
|
||||||
|
@ -40,7 +40,7 @@ for b in bornes:
|
||||||
# Est-ce un hotspot ?
|
# Est-ce un hotspot ?
|
||||||
hotspot = b.hotspot() and 1 or 0
|
hotspot = b.hotspot() and 1 or 0
|
||||||
# Est-ce que la borne est up ?
|
# Est-ce que la borne est up ?
|
||||||
if os.system("/usr/local/sbin/fping -q %s || /usr/local/sbin/fping -q %s" % ((b.nom(),)*2)) == 0:
|
if os.system("/usr/sbin/fping -q %s 2> /dev/null" % b.nom()) == 0:
|
||||||
up = 1
|
up = 1
|
||||||
else:
|
else:
|
||||||
up = 0
|
up = 0
|
||||||
|
@ -55,7 +55,6 @@ for b in bornes:
|
||||||
xml_desc.appendChild(status.createTextNode(infos[0]))
|
xml_desc.appendChild(status.createTextNode(infos[0]))
|
||||||
#xml_desc.appendChild(status.createTextNode(u"Description pas compatible unicode/ascii"))
|
#xml_desc.appendChild(status.createTextNode(u"Description pas compatible unicode/ascii"))
|
||||||
xml_borne.appendChild(xml_desc)
|
xml_borne.appendChild(xml_desc)
|
||||||
|
|
||||||
xml_mac=status.createElement(u"mac")
|
xml_mac=status.createElement(u"mac")
|
||||||
xml_mac.appendChild(status.createTextNode(b.mac2()))
|
xml_mac.appendChild(status.createTextNode(b.mac2()))
|
||||||
xml_borne.appendChild(xml_mac)
|
xml_borne.appendChild(xml_mac)
|
||||||
|
@ -63,12 +62,16 @@ for b in bornes:
|
||||||
# Certains résultats (ragnarok) n'ont pas tous les champs.
|
# Certains résultats (ragnarok) n'ont pas tous les champs.
|
||||||
if (canaux.has_key(nom)):
|
if (canaux.has_key(nom)):
|
||||||
xml_canal=status.createElement(u"canal")
|
xml_canal=status.createElement(u"canal")
|
||||||
xml_canal.appendChild(status.createTextNode(unicode(int('0' + canaux[nom]))))
|
try: canal = unicode(int(canaux[nom]))
|
||||||
|
except TypeError: canal = u'Inconnu'
|
||||||
|
xml_canal.appendChild(status.createTextNode(canal))
|
||||||
xml_borne.appendChild(xml_canal)
|
xml_borne.appendChild(xml_canal)
|
||||||
|
|
||||||
if (clients.has_key(nom)):
|
if (clients.has_key(nom)):
|
||||||
xml_clients=status.createElement(u"clients")
|
xml_clients=status.createElement(u"clients")
|
||||||
xml_clients.appendChild(status.createTextNode(unicode(int('0' + clients[nom]))))
|
try: client = unicode(int(clients[nom]))
|
||||||
|
except TypeError: client = u'Inconnu'
|
||||||
|
xml_clients.appendChild(status.createTextNode(client))
|
||||||
xml_borne.appendChild(xml_clients)
|
xml_borne.appendChild(xml_clients)
|
||||||
|
|
||||||
if (uptimes.has_key(nom)):
|
if (uptimes.has_key(nom)):
|
||||||
|
@ -76,7 +79,6 @@ for b in bornes:
|
||||||
xml_uptime.appendChild(status.createTextNode(unicode(uptimes[nom])))
|
xml_uptime.appendChild(status.createTextNode(unicode(uptimes[nom])))
|
||||||
xml_borne.appendChild(xml_uptime)
|
xml_borne.appendChild(xml_uptime)
|
||||||
|
|
||||||
|
|
||||||
position = b.position()
|
position = b.position()
|
||||||
if position:
|
if position:
|
||||||
xml_position=status.createElement(u"position")
|
xml_position=status.createElement(u"position")
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue