Implémentation de missing tpe sur whosthere et archivage de who2b

This commit is contained in:
Gabriel Detraz 2015-08-18 00:42:50 +02:00
parent a9593fe783
commit 8f3f9c13da
2 changed files with 15 additions and 0 deletions

View file

@ -17,6 +17,8 @@ from gestion.hptools import hpswitch, ConversationError
from gestion.affich_tools import cprint from gestion.affich_tools import cprint
import gestion.affichage as affichage import gestion.affichage as affichage
import gestion.mail as mail_module import gestion.mail as mail_module
from gestion.mail import generate
from utils.sendmail import actually_sendmail
# Constantes pour munin. # Constantes pour munin.
# L'ordre est important : il détermine comment sont empilées les valeurs # L'ordre est important : il détermine comment sont empilées les valeurs
@ -35,6 +37,12 @@ DN_CRANS = 'ou=data,dc=crans,dc=org'
WIFIMAP_DIR = os.getenv('DBG_WIFIMAP_DB', '/usr/scripts/var/wifi_xml') WIFIMAP_DIR = os.getenv('DBG_WIFIMAP_DB', '/usr/scripts/var/wifi_xml')
def missing_tpe():
"""Envoie un mail si le tpe n'est pas présent avec l'arg --warn-tpe"""
dst = 'respbats@crans.org'
mail = generate('missing_tpe', {'to': dst})
actually_sendmail('respbats@crans.org', [dst], mail)
def pretty_name(item): def pretty_name(item):
"""Affiche un joli nom pour un objet ldap (adh ou machine)""" """Affiche un joli nom pour un objet ldap (adh ou machine)"""
v = "" v = ""
@ -132,8 +140,11 @@ class WhosThere(object):
for mach in self.expected: for mach in self.expected:
if mach not in detected_mach: if mach not in detected_mach:
mach_manq.append(mach) mach_manq.append(mach)
if warn:
missing_tpe()
return mach_manq return mach_manq
def populate_from_switch(self, host, port): def populate_from_switch(self, host, port):
"""Rempli les macs à partir de la prise d'un switch""" """Rempli les macs à partir de la prise d'un switch"""
sw = hpswitch(host) sw = hpswitch(host)
@ -297,6 +308,10 @@ if __name__ == '__main__':
'kfet': WhoKfet, 'kfet': WhoKfet,
'4j': Who4J, '4j': Who4J,
} }
if '--warn-tpe' in sys.argv:
warn=['tpe']
else:
warn=False
for what in sys.argv[1:]: for what in sys.argv[1:]:
try: try:
name = where[what.lower()] name = where[what.lower()]