Implémentation de missing tpe sur whosthere et archivage de who2b
This commit is contained in:
parent
a9593fe783
commit
8f3f9c13da
2 changed files with 15 additions and 0 deletions
|
@ -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()]
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue