import initial -- comme ca on a tout l'autostatus sur une seule page
darcs-hash:20051002172624-4ec08-7da6c3bd7bee48e7c42db97c701f240055fdc10d.gz
This commit is contained in:
parent
5c03ba00ca
commit
e935588398
1 changed files with 52 additions and 0 deletions
52
wiki/macro/HostStatus.py
Normal file
52
wiki/macro/HostStatus.py
Normal file
|
@ -0,0 +1,52 @@
|
|||
# -*- coding: iso-8859-1 -*-
|
||||
|
||||
from commands import getstatusoutput
|
||||
|
||||
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) :
|
||||
|
||||
status = getstatusoutput('grep -v " 0 " /etc/autostatus/local.status')
|
||||
|
||||
if status[0] :
|
||||
return Cellule('Impossible d\'analyser le fichier de status.','yellow',macro.formatter)
|
||||
|
||||
if not status[1].strip() :
|
||||
return Cellule('Toutes les machines sont up, Vince est de bonne humeur.','lime',macro.formatter)
|
||||
|
||||
lines = status[1].split('\n')
|
||||
|
||||
f = macro.formatter
|
||||
code = ''
|
||||
code += f.table(1)
|
||||
|
||||
for line in lines :
|
||||
line = line.split(' ')
|
||||
code += f.table_row(1)
|
||||
code += f.table_cell(1,{'style':'background-color:silver'})
|
||||
code += f.text(line [0])
|
||||
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('down')
|
||||
else :
|
||||
code += f.table_cell(1,{'style':'background-color:blue'})
|
||||
code += f.text('up')
|
||||
code += f.table_cell(0)
|
||||
code += f.table_row(0)
|
||||
|
||||
code += f.table(0)
|
||||
|
||||
return code.encode('iso-8859-15')
|
Loading…
Add table
Add a link
Reference in a new issue