who2b: --warn-tpe => mail si tpe pas au 2B
This commit is contained in:
parent
f1efc54db1
commit
95e2503320
8 changed files with 35 additions and 3 deletions
1
gestion/mail/template/missing_tpe/From/fr
Normal file
1
gestion/mail/template/missing_tpe/From/fr
Normal file
|
@ -0,0 +1 @@
|
|||
respbats@crans.org
|
2
gestion/mail/template/missing_tpe/README
Normal file
2
gestion/mail/template/missing_tpe/README
Normal file
|
@ -0,0 +1,2 @@
|
|||
Envoyé si le tpe n'est pas branché au 2B. Appelé par un cron à des horaires
|
||||
où il est censé s'y trouver.
|
1
gestion/mail/template/missing_tpe/Subject/fr
Normal file
1
gestion/mail/template/missing_tpe/Subject/fr
Normal file
|
@ -0,0 +1 @@
|
|||
Le TPE n'est pas revenu au 2B !
|
1
gestion/mail/template/missing_tpe/To/fr
Normal file
1
gestion/mail/template/missing_tpe/To/fr
Normal file
|
@ -0,0 +1 @@
|
|||
{{to}}
|
1
gestion/mail/template/missing_tpe/X-Mailer/fr
Normal file
1
gestion/mail/template/missing_tpe/X-Mailer/fr
Normal file
|
@ -0,0 +1 @@
|
|||
{{ mailer }}
|
11
gestion/mail/template/missing_tpe/body/fr
Normal file
11
gestion/mail/template/missing_tpe/body/fr
Normal file
|
@ -0,0 +1,11 @@
|
|||
Bonjour,
|
||||
|
||||
Ce mail automatique signale l'absence du terminal bancaire. La permanence Crans
|
||||
étant terminée, le terminal devrait normalement se trouver au 2B. Si le
|
||||
terminal s'y trouve, merci de le brancher au réseau.
|
||||
|
||||
L'état de connectivité du terminal est disponible sur la page d'autostatus :
|
||||
http://autostatus.crans.org
|
||||
|
||||
--
|
||||
who2b
|
|
@ -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 "$@"
|
||||
|
|
|
@ -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()
|
||||
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue