diff --git a/gestion/tools/who2b.py b/archive/gestion/tools/who2b.py similarity index 100% rename from gestion/tools/who2b.py rename to archive/gestion/tools/who2b.py diff --git a/gestion/tools/whosthere.py b/gestion/tools/whosthere.py index 98014f6d..7b45fe6c 100755 --- a/gestion/tools/whosthere.py +++ b/gestion/tools/whosthere.py @@ -17,6 +17,8 @@ from gestion.hptools import hpswitch, ConversationError from gestion.affich_tools import cprint import gestion.affichage as affichage import gestion.mail as mail_module +from gestion.mail import generate +from utils.sendmail import actually_sendmail # Constantes pour munin. # 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') +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): """Affiche un joli nom pour un objet ldap (adh ou machine)""" v = "" @@ -132,8 +140,11 @@ class WhosThere(object): for mach in self.expected: if mach not in detected_mach: mach_manq.append(mach) + if warn: + missing_tpe() return mach_manq + def populate_from_switch(self, host, port): """Rempli les macs à partir de la prise d'un switch""" sw = hpswitch(host) @@ -297,6 +308,10 @@ if __name__ == '__main__': 'kfet': WhoKfet, '4j': Who4J, } + if '--warn-tpe' in sys.argv: + warn=['tpe'] + else: + warn=False for what in sys.argv[1:]: try: name = where[what.lower()]