[wiki] wiki-lenny -> wiki
darcs-hash:20090427173001-bd074-51c7f6aea2843640e34adc0921b478f40ea98609.gz
This commit is contained in:
parent
5f26116790
commit
cd037bbbe9
31 changed files with 0 additions and 0 deletions
61
wiki/macro/HostStatus.py
Normal file
61
wiki/macro/HostStatus.py
Normal file
|
@ -0,0 +1,61 @@
|
|||
# -*- coding: utf-8 -*-
|
||||
|
||||
import re
|
||||
from commands import getstatusoutput,getoutput
|
||||
|
||||
|
||||
def execute(macro, text) :
|
||||
|
||||
lines = open('/usr/scripts/var/local.status').readlines()
|
||||
|
||||
f = macro.formatter
|
||||
code = f.table(1)
|
||||
|
||||
typlist = ['routes', 'serveurs', 'serveurs de la ferme', 'switches', 'bornes', u'services extérieurs au crans']
|
||||
|
||||
for typ in typlist:
|
||||
lines = lines [1:]
|
||||
trucsdown = ''
|
||||
|
||||
while lines and not re.match('dummy_host_\d+ 0 \n', lines[0]):
|
||||
if not re.search(' 0 ', lines[0]):
|
||||
line = lines[0].split(' ')
|
||||
trucsdown += f.table_row(1)
|
||||
trucsdown += f.table_cell(1,{'style':'background-color:lightgrey; color: black;'})
|
||||
trucsdown += unicode(f.text('%s (%s)' % (line [0], getoutput("grep '^%s[^-.a-zA-Z]' /usr/scripts/var/autostatus/hosts | cut -d ' ' -f 5-" % line [0])) ), "utf-8")
|
||||
trucsdown += f.table_cell(0)
|
||||
# nombre de non réponse au ping
|
||||
if int(line[1]) > 2 :
|
||||
trucsdown += f.table_cell(1,{'style':'background-color:red; color: black;'})
|
||||
trucsdown += f.text(u'down')
|
||||
else :
|
||||
trucsdown += f.table_cell(1,{'style':'background-color:blue;'})
|
||||
trucsdown += f.text(u'état incertain')
|
||||
trucsdown += f.table_cell(0)
|
||||
trucsdown += f.table_row(0)
|
||||
lines = lines [1:]
|
||||
|
||||
if trucsdown == '':
|
||||
code += f.table_row(1)
|
||||
code += f.table_cell(1, {'style':'background-color:silver; color: black;'})
|
||||
code += f.text(u'Autostatus des '+typ)
|
||||
code += f.table_cell(0)
|
||||
code += f.table_cell(1, {'style':'background-color:lime; color: black;'})
|
||||
code += f.text(u'OK')
|
||||
code += f.table_cell(0)
|
||||
code += f.table_row(0)
|
||||
else:
|
||||
code += f.table_row(1)
|
||||
code += f.table_cell(1, {'style':'background-color:silver; color:black;', 'colspan':'2' })
|
||||
code += f.text(u'Autostatus des '+typ)
|
||||
code += f.table_cell(0)
|
||||
code += f.table_row(0)
|
||||
code += f.table_row(1)
|
||||
code += f.table_cell(1, {'style':'background-color:aliceblue', 'colspan':'2'})
|
||||
code += f.table(1) + trucsdown + f.table(0)
|
||||
code += f.table_cell(0)
|
||||
code += f.table_row(0)
|
||||
trucsdown = ''
|
||||
|
||||
code += f.table(0)
|
||||
return code
|
Loading…
Add table
Add a link
Reference in a new issue