who2b: --warn-tpe => mail si tpe pas au 2B

This commit is contained in:
Daniel STAN 2014-09-15 21:59:07 +02:00
parent f1efc54db1
commit 95e2503320
8 changed files with 35 additions and 3 deletions

View file

@ -5,4 +5,4 @@ if [ `hostname` != "vo" ]; then
exit 1
fi
sudo -u root /usr/scripts/gestion/tools/who2b.py
sudo -u root /usr/scripts/gestion/tools/who2b.py "$@"

View file

@ -11,8 +11,15 @@ from affich_tools import coul, cprint
from whos import aff
from socket import gethostname
from os import system
from gestion.mail import generate
from utils.sendmail import actually_sendmail
def liste_2b():
def missing_tpe():
dst = 'respbats@crans.org'
mail = generate('missing_tpe', {'to': dst})
actually_sendmail('respbats@crans.org', [dst], mail)
def liste_2b(warn_mail=[]):
'''Cette fonction permet de savoir s'il y a du monde au 2B.'''
sw = hpswitch('backbone.adm')
@ -34,6 +41,7 @@ def liste_2b():
"00:1c:2e:56:1a:20": "minigiga (switch)",
"00:40:8c:7f:4a:b5": "tinybrother",
"00:24:8c:44:3b:70": "vo",
"54:7f:54:77:ca:be": "terminal",
}
# Machines branchée sur la prise
@ -65,6 +73,9 @@ def liste_2b():
for expectedMac in expected.iterkeys():
if expectedMac not in macs:
cprint("Machine %s manquante !" % expected[expectedMac], 'rouge')
if expected[expectedMac] in warn_mail:
missing_tpe()
print("envoi d'un mail")
# Affichage des machines
cprint('---=== Machines du Crans ===---', 'bleu')
aff(machines_crans, mtech=True)
@ -85,4 +96,8 @@ def liste_2b():
cprint("---=== Il semble n'y avoir personne au 2B ... ===---", 'rouge')
if __name__ == '__main__':
liste_2b()
if '--warn-tpe' in sys.argv:
liste_2b(warn_mail=["terminal"])
else:
liste_2b()