[wikis/../autostatus] Fichiers de l'autostatus déplacés dans /usr/scripts/var/autostatus
darcs-hash:20081207202337-bd074-e1ed8bdeb462c6b717abf47229add5876a377cea.gz
This commit is contained in:
parent
d29a380e65
commit
913a142aa7
3 changed files with 74 additions and 7 deletions
|
@ -15,13 +15,18 @@ from gen_confs import gen_config
|
||||||
|
|
||||||
# définition de la classe
|
# définition de la classe
|
||||||
|
|
||||||
|
def inform(string):
|
||||||
|
pass
|
||||||
|
# print string
|
||||||
|
|
||||||
|
|
||||||
class autostatus(gen_config) :
|
class autostatus(gen_config) :
|
||||||
|
|
||||||
# CONFIGURATION #
|
# CONFIGURATION #
|
||||||
#################
|
#################
|
||||||
|
|
||||||
# fichier de l'autostatus
|
# fichier de l'autostatus
|
||||||
CONFFILE = '/etc/autostatus/hosts'
|
CONFFILE = '/usr/scripts/var/autostatus/hosts'
|
||||||
|
|
||||||
# machines crans à ne pas mettre dans l'autostatus
|
# machines crans à ne pas mettre dans l'autostatus
|
||||||
pasimportant = ["non-configure.wifi.crans.org",
|
pasimportant = ["non-configure.wifi.crans.org",
|
||||||
|
@ -154,7 +159,7 @@ class autostatus(gen_config) :
|
||||||
|
|
||||||
# machines crans
|
# machines crans
|
||||||
################
|
################
|
||||||
|
inform(u"Récupération des machines du Cr@ns")
|
||||||
machines = AssociationCrans().machines()
|
machines = AssociationCrans().machines()
|
||||||
# Quand un serveur est à la fois dans adm et dans autre chose,
|
# Quand un serveur est à la fois dans adm et dans autre chose,
|
||||||
# on garde que le autre chose
|
# on garde que le autre chose
|
||||||
|
@ -174,6 +179,7 @@ class autostatus(gen_config) :
|
||||||
ferme = {}
|
ferme = {}
|
||||||
|
|
||||||
# tri des machines
|
# tri des machines
|
||||||
|
inform(u"tri des machines")
|
||||||
for m in machines :
|
for m in machines :
|
||||||
|
|
||||||
# machine exclue
|
# machine exclue
|
||||||
|
@ -229,10 +235,10 @@ class autostatus(gen_config) :
|
||||||
|
|
||||||
# route vers l'extérieur
|
# route vers l'extérieur
|
||||||
########################
|
########################
|
||||||
|
inform(u"Récupération de la route vers l'extérieur")
|
||||||
# on récupère la route vers l'extérieur
|
# on récupère la route vers l'extérieur
|
||||||
traceroute = commands.getoutput("/usr/bin/traceroute www.free.fr 2> /dev/null | sed 's/\*//g' | sed 's/ */ /g' | sed 's/^ //g' | sed 's/[(,)]//g' | cut -d ' ' -f 2,3").split("\n")
|
traceroute = commands.getoutput("/usr/bin/traceroute www.free.fr 2> /dev/null | sed 's/\*//g' | sed 's/ */ /g' | sed 's/^ //g' | sed 's/[(,)]//g' | cut -d ' ' -f 2,3").split("\n")
|
||||||
|
inform(u"Analyse de la route")
|
||||||
# initialisation des variables
|
# initialisation des variables
|
||||||
in_renater = 0
|
in_renater = 0
|
||||||
route_to_ext = ''
|
route_to_ext = ''
|
||||||
|
@ -276,7 +282,7 @@ class autostatus(gen_config) :
|
||||||
|
|
||||||
# services extérieurs
|
# services extérieurs
|
||||||
#####################
|
#####################
|
||||||
|
inform(u"Services extérieurs")
|
||||||
services_exterieurs = {}
|
services_exterieurs = {}
|
||||||
for key in self.services_exterieurs.keys() :
|
for key in self.services_exterieurs.keys() :
|
||||||
s = self.services_exterieurs[key]
|
s = self.services_exterieurs[key]
|
||||||
|
|
61
wiki-lenny/local/macro/HostStatus.py
Normal file
61
wiki-lenny/local/macro/HostStatus.py
Normal file
|
@ -0,0 +1,61 @@
|
||||||
|
# -*- coding: iso-8859-1 -*-
|
||||||
|
|
||||||
|
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;'})
|
||||||
|
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])) ), "iso-8859-15")
|
||||||
|
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;'})
|
||||||
|
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;'})
|
||||||
|
code += f.text(u'Autostatus des '+typ)
|
||||||
|
code += f.table_cell(0)
|
||||||
|
code += f.table_cell(1, {'style':'background-color:lime;'})
|
||||||
|
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', '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
|
|
@ -5,7 +5,7 @@ from commands import getstatusoutput,getoutput
|
||||||
|
|
||||||
def execute(macro, text) :
|
def execute(macro, text) :
|
||||||
|
|
||||||
lines = open('/etc/autostatus/local.status').readlines()
|
lines = open('/usr/scripts/var/local.status').readlines()
|
||||||
|
|
||||||
f = macro.formatter
|
f = macro.formatter
|
||||||
code = f.table(1)
|
code = f.table(1)
|
||||||
|
@ -21,7 +21,7 @@ def execute(macro, text) :
|
||||||
line = lines[0].split(' ')
|
line = lines[0].split(' ')
|
||||||
trucsdown += f.table_row(1)
|
trucsdown += f.table_row(1)
|
||||||
trucsdown += f.table_cell(1,{'style':'background-color:lightgrey;'})
|
trucsdown += f.table_cell(1,{'style':'background-color:lightgrey;'})
|
||||||
trucsdown += 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")
|
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])) ), "iso-8859-15")
|
||||||
trucsdown += f.table_cell(0)
|
trucsdown += f.table_cell(0)
|
||||||
# nombre de non réponse au ping
|
# nombre de non réponse au ping
|
||||||
if int(line[1]) > 2 :
|
if int(line[1]) > 2 :
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue