Mise à jour de la branche product avec les fichiers en production sur le VPS
This commit is contained in:
@@ -32,7 +32,7 @@ def envoyer_mail(sujet, message, destinataires):
|
||||
msg['To'] = ', '.join(destinataires)
|
||||
try:
|
||||
with smtplib.SMTP_SSL('smtp.mail.ovh.net', 465) as server:
|
||||
server.login('alertes_saclay@domo91.fr', 'Kdpke674y23Feq^H')
|
||||
server.login('alertes_saclay@domo91.fr','Kdpke674y23Feq^H')
|
||||
server.sendmail(msg['From'], destinataires, msg.as_string())
|
||||
print(f"📧 Mail envoyé à {destinataires}", flush=True)
|
||||
except Exception as e:
|
||||
@@ -141,7 +141,7 @@ def surveiller():
|
||||
|
||||
if log_entries:
|
||||
df_logs = pd.DataFrame(log_entries)
|
||||
df_logs.to_csv("/home/debian/travail/Gestion_sondes/Logs/monitor.csv", sep=";", index=False)
|
||||
df_logs.to_csv("/home/debian/Gestion_sondes/Logs/monitor.csv", sep=";", index=False)
|
||||
|
||||
except Exception as e:
|
||||
print(f"Erreur : {e}", flush=True)
|
||||
|
||||
71
requirements.txt
Normal file
71
requirements.txt
Normal file
@@ -0,0 +1,71 @@
|
||||
acme==2.1.0
|
||||
altair==5.5.0
|
||||
attrs==22.2.0
|
||||
blinker==1.5
|
||||
cachetools==5.5.2
|
||||
certifi==2022.9.24
|
||||
cffi==1.17.1
|
||||
chardet==5.1.0
|
||||
charset-normalizer==2.1.1
|
||||
click==8.1.8
|
||||
ConfigArgParse==1.5.3
|
||||
configobj==5.0.8
|
||||
contourpy==1.3.2
|
||||
cryptography==38.0.4
|
||||
cycler==0.12.1
|
||||
distro==1.8.0
|
||||
dotenv==0.9.9
|
||||
fonttools==4.57.0
|
||||
fpdf==1.7.2
|
||||
gitdb==4.0.12
|
||||
GitPython==3.1.44
|
||||
httplib2==0.20.4
|
||||
idna==3.3
|
||||
Jinja2==3.1.2
|
||||
josepy==1.13.0
|
||||
jsonpatch==1.32
|
||||
jsonpointer==2.3
|
||||
jsonschema==4.10.3
|
||||
kiwisolver==1.4.8
|
||||
markdown-it-py==2.1.0
|
||||
MarkupSafe==2.1.2
|
||||
matplotlib==3.10.1
|
||||
mdurl==0.1.2
|
||||
mysql-connector-python==9.3.0
|
||||
narwhals==1.33.0
|
||||
numpy==2.2.4
|
||||
oauthlib==3.2.2
|
||||
packaging==24.2
|
||||
paho-mqtt==2.1.0
|
||||
pandas==2.2.3
|
||||
parsedatetime==2.6
|
||||
pillow==11.1.0
|
||||
protobuf==5.29.4
|
||||
pyarrow==19.0.1
|
||||
pycparser==2.22
|
||||
pydeck==0.9.1
|
||||
Pygments==2.14.0
|
||||
PyJWT==2.6.0
|
||||
pyOpenSSL==23.2.0
|
||||
pyparsing==3.0.9
|
||||
pyRFC3339==1.1
|
||||
pyrsistent==0.18.1
|
||||
pyserial==3.5
|
||||
PySimpleSOAP==1.16.2
|
||||
python-dateutil==2.9.0.post0
|
||||
python-dotenv==1.1.0
|
||||
pytz==2022.7.1
|
||||
PyYAML==6.0
|
||||
requests==2.28.1
|
||||
rich==13.3.1
|
||||
six==1.16.0
|
||||
smmap==5.0.2
|
||||
streamlit==1.44.1
|
||||
supervisor==4.2.5
|
||||
tenacity==9.1.2
|
||||
toml==0.10.2
|
||||
tornado==6.4.2
|
||||
typing_extensions==4.13.1
|
||||
tzdata==2025.2
|
||||
urllib3==1.26.12
|
||||
watchdog==6.0.0
|
||||
4
scripts/restart_services.sh
Normal file → Executable file
4
scripts/restart_services.sh
Normal file → Executable file
@@ -1,6 +1,6 @@
|
||||
#!/bin/bash
|
||||
|
||||
LOG="/home/debian/travail/Gestion_sondes/Logs/restart_services.log"
|
||||
LOG="/home/debian/Gestion_sondes/Logs/restart_services.log"
|
||||
DATE=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
|
||||
echo "[$DATE] 🔄 Redémarrage des services Supervisor" >> $LOG
|
||||
@@ -34,4 +34,4 @@ else
|
||||
echo " → $LOG"
|
||||
fi
|
||||
echo ""
|
||||
echo "===== ✅ FIN DU SCRIPT ====="
|
||||
echo "===== ✅ FIN DU SCRIPT ====="
|
||||
|
||||
6
scripts/update_product.sh
Normal file → Executable file
6
scripts/update_product.sh
Normal file → Executable file
@@ -1,7 +1,7 @@
|
||||
#!/bin/bash
|
||||
|
||||
LOG="/home/debian/travail/Gestion_sondes/Logs/update_product.log"
|
||||
REPO_PATH="/home/debian/travail/Gestion_sondes"
|
||||
LOG="/home/debian/Gestion_sondes/Logs/update_product.log"
|
||||
REPO_PATH="/home/debian/Gestion_sondes"
|
||||
DATE=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
|
||||
echo "[$DATE] 🔄 Lancement du script de mise à jour" >> $LOG
|
||||
@@ -29,4 +29,4 @@ git merge origin/develop -m "🧩 Merge auto develop → product" >> $LOG 2>&1
|
||||
git push origin product >> $LOG 2>&1
|
||||
|
||||
DATE_END=$(date '+%Y-%m-%d %H:%M:%S')
|
||||
echo "[$DATE_END] ✅ Mise à jour terminée avec succès." >> $LOG
|
||||
echo "[$DATE_END] ✅ Mise à jour terminée avec succès." >> $LOG
|
||||
|
||||
45
supervisor_watchdog.py
Executable file
45
supervisor_watchdog.py
Executable file
@@ -0,0 +1,45 @@
|
||||
#!/home/debian/Gestion_sondes/myenv/bin/python
|
||||
import subprocess
|
||||
import smtplib
|
||||
from email.mime.text import MIMEText
|
||||
from datetime import datetime
|
||||
|
||||
heure_actuelle = datetime.now().strftime("%H:%M")
|
||||
etat_services = []
|
||||
anomalies = []
|
||||
|
||||
try:
|
||||
output = subprocess.check_output("/usr/bin/supervisorctl status", shell=True, text=True)
|
||||
for line in output.splitlines():
|
||||
parts = line.split()
|
||||
if len(parts) >= 2:
|
||||
nom, statut = parts[0], parts[1]
|
||||
etat_services.append(f"{nom} ➤ {statut}")
|
||||
if statut != "RUNNING":
|
||||
anomalies.append(f"{nom} ➤ {statut}")
|
||||
except Exception as e:
|
||||
etat_services.append("❌ Impossible d'exécuter supervisorctl")
|
||||
anomalies.append(f"Erreur : {e}")
|
||||
|
||||
# Déclenchement mail si anomalie ou à 07:00
|
||||
envoyer_mail = bool(anomalies) or heure_actuelle == "07:00"
|
||||
|
||||
if envoyer_mail:
|
||||
sujet = "⚠️ Alerte Supervisor" if anomalies else "✅ Rapport quotidien Supervisor"
|
||||
intro = "🛑 Les services suivants ne sont pas en RUNNING :" if anomalies else "✅ Tous les services supervisés sont en RUNNING."
|
||||
contenu = f"{intro}\n\n" + "\n".join(etat_services)
|
||||
|
||||
msg = MIMEText(contenu)
|
||||
msg["Subject"] = sujet
|
||||
msg["From"] = "alertes_saclay@domo91.fr"
|
||||
msg["To"] = "services@domo91.fr"
|
||||
|
||||
try:
|
||||
with smtplib.SMTP_SSL("smtp.mail.ovh.net", 465) as server:
|
||||
server.login("alertes_saclay@domo91.fr", "Kdpke674y23Feq^H")
|
||||
server.sendmail(msg["From"], [msg["To"]], msg.as_string())
|
||||
print("📧 Mail envoyé.")
|
||||
except Exception as e:
|
||||
print(f"Erreur envoi mail : {e}")
|
||||
else:
|
||||
print("🕖 Aucun mail envoyé (tout est OK et ce n’est pas l’heure du rapport).")
|
||||
@@ -1,6 +0,0 @@
|
||||
# Fichier de sauvegarde BDD sur Syno en NFS
|
||||
# Fichier my.cnf
|
||||
#[mysqldump]
|
||||
#user=root
|
||||
#password=4V5t9P!Z2HgT#CLFes4cntEeNBWs
|
||||
mysqldump --defaults-file=/home/debian/travail/my.cnf -u root --all-databases > /mnt/syno920/all-$(date +%Y%m%d).sql
|
||||
@@ -1,9 +0,0 @@
|
||||
mysql~=0.0.3
|
||||
mysql-connector-python~=9.2.0
|
||||
pandas~=2.2.3
|
||||
DateTime~=5.5
|
||||
streamlit~=1.44.1
|
||||
matplotlib~=3.10.1
|
||||
paho-mqtt~=2.1.0
|
||||
requests~=2.32.3
|
||||
schedule~=1.2.2
|
||||
@@ -1,17 +0,0 @@
|
||||
#!/bin/bash
|
||||
|
||||
echo "🔄 Passage à la branche product"
|
||||
git checkout product || exit 1
|
||||
|
||||
FILES=("Cuisine_meudon.py" "Cuisine_saclay.py" "Monitor.py" "domo91.py")
|
||||
|
||||
for file in "${FILES[@]}"; do
|
||||
if [ -f "$file" ]; then
|
||||
echo "✔️ Mise à jour de $file depuis develop"
|
||||
git checkout develop -- "$file"
|
||||
else
|
||||
echo "⏭️ Ignoré : $file n'existe pas dans product"
|
||||
fi
|
||||
done
|
||||
|
||||
echo "✅ Fichiers mis à jour avec succès depuis develop"
|
||||
Reference in New Issue
Block a user