[wiki/macro/autostatus] Modification de la macro d'autostatus
darcs-hash:20081205191250-bd074-bf9a2977ceffc63760580ecc50db57f0bc58c363.gz
This commit is contained in:
parent
278a018207
commit
bfcaf970a7
1 changed files with 35 additions and 47 deletions
|
@ -3,62 +3,50 @@
|
||||||
import re
|
import re
|
||||||
from commands import getstatusoutput,getoutput
|
from commands import getstatusoutput,getoutput
|
||||||
|
|
||||||
def Cellule(texte, couleur, f) :
|
|
||||||
"""
|
|
||||||
Retourne le code HTML d'une cellule formattée aver le formatter f
|
|
||||||
"""
|
|
||||||
code = f.table(1)
|
|
||||||
code += f.table_row(1)
|
|
||||||
code += f.table_cell(1,{'style':'background-color:%s' % couleur })
|
|
||||||
code += f.text(texte)
|
|
||||||
code += f.table_cell(0)
|
|
||||||
code += f.table_row(0)
|
|
||||||
code += f.table(0)
|
|
||||||
return code
|
|
||||||
|
|
||||||
def execute(macro, text) :
|
def execute(macro, text) :
|
||||||
|
|
||||||
lines = open('/etc/autostatus/local.status').readlines()
|
lines = open('/etc/autostatus/local.status').readlines()
|
||||||
|
|
||||||
# if status[0] and status[0] != 256 :
|
|
||||||
# return Cellule(u'Impossible d\'analyser le fichier de status.','yellow',macro.formatter)
|
|
||||||
#
|
|
||||||
# if not status[1].strip() :
|
|
||||||
# return Cellule(u'Toutes les machines importantes sont up.','lime',macro.formatter)
|
|
||||||
#
|
|
||||||
# lines = status[1].split('\n')
|
|
||||||
|
|
||||||
f = macro.formatter
|
f = macro.formatter
|
||||||
code = ''
|
code = ''
|
||||||
code += f.heading(1,3)
|
|
||||||
code += 'Autostatus des machines'
|
|
||||||
code += f.heading(0,3)
|
|
||||||
code += f.table(1)
|
|
||||||
|
|
||||||
for line in lines:
|
typlist = ['routes', 'serveurs', 'serveurs de la ferme', 'switches', 'bornes', u'services et de l\'extérieur']
|
||||||
if re.match('dummy_host_\d+ 0 \n', line):
|
|
||||||
if line == 'dummy_host_9 0 \n':
|
for typ in typlist:
|
||||||
code += f.table(0)
|
lines = lines [1:]
|
||||||
code += f.heading(1,3)
|
|
||||||
code += 'Autostatus des bornes wifi'
|
code += f.heading(1,3)
|
||||||
code += f.heading(0,3)
|
code += 'Autostatus des '+typ
|
||||||
code += f.table(1)
|
code += f.heading(0,3)
|
||||||
if not re.search(' 0 ', line):
|
code += f.table(1)
|
||||||
line = line.split(' ')
|
|
||||||
|
trucsdown = 0
|
||||||
|
|
||||||
|
while lines and not re.match('dummy_host_\d+ 0 \n', lines[0]):
|
||||||
|
if not re.search(' 0 ', lines[0]):
|
||||||
|
trucsdown += 1
|
||||||
|
line = lines[0].split(' ')
|
||||||
|
code += f.table_row(1)
|
||||||
|
code += f.table_cell(1,{'style':'background-color:silver'})
|
||||||
|
code += unicode(f.text('%s (%s)' % (line [0], getoutput("grep '^%s[^a-zA-Z]' /etc/autostatus/hosts | cut -d ' ' -f 5-" % line [0])) ), "iso-8859-15")
|
||||||
|
code += f.table_cell(0)
|
||||||
|
# nombre de non réponse au ping
|
||||||
|
if int(line[1]) > 2 :
|
||||||
|
code += f.table_cell(1,{'style':'background-color:red'})
|
||||||
|
code += f.text(u'down')
|
||||||
|
else :
|
||||||
|
code += f.table_cell(1,{'style':'background-color:blue'})
|
||||||
|
code += f.text(u'état incertain')
|
||||||
|
code += f.table_cell(0)
|
||||||
|
code += f.table_row(0)
|
||||||
|
lines = lines [1:]
|
||||||
|
|
||||||
|
if trucsdown == 0:
|
||||||
code += f.table_row(1)
|
code += f.table_row(1)
|
||||||
code += f.table_cell(1,{'style':'background-color:silver'})
|
code += f.table_cell(1,{'style':'background-color:lime'})
|
||||||
code += unicode(f.text('%s (%s)' % (line [0], getoutput("grep '^%s[^a-zA-Z]' /etc/autostatus/hosts | cut -d ' ' -f 5-" % line [0])) ), "iso-8859-15")
|
code += f.text(u'Ok pour les '+typ)
|
||||||
code += f.table_cell(0)
|
|
||||||
# nombre de non réponse au ping
|
|
||||||
if int(line[1]) > 2 :
|
|
||||||
code += f.table_cell(1,{'style':'background-color:red'})
|
|
||||||
code += f.text(u'down')
|
|
||||||
else :
|
|
||||||
code += f.table_cell(1,{'style':'background-color:blue'})
|
|
||||||
code += f.text(u'état incertain')
|
|
||||||
code += f.table_cell(0)
|
code += f.table_cell(0)
|
||||||
code += f.table_row(0)
|
code += f.table_row(0)
|
||||||
|
code += f.table(0)
|
||||||
code += f.table(0)
|
|
||||||
|
|
||||||
return code
|
return code
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue