Ajout README Complet
This commit is contained in:
@@ -8,7 +8,7 @@ import matplotlib.pyplot as plt
|
||||
import matplotlib.dates as mdates
|
||||
|
||||
st.set_page_config(page_title="Domo91 - Surveillance", layout="wide")
|
||||
st.title("📡 Supervision Températures")
|
||||
st.title("📡 Supervision Températures Multisites")
|
||||
|
||||
# --- Configuration base de données ---
|
||||
db_config = {
|
||||
@@ -76,6 +76,8 @@ if st.session_state.get("page") == "analyse_logs":
|
||||
|
||||
|
||||
with st.sidebar:
|
||||
st.markdown("# 🌡️ **Domo91**")
|
||||
st.markdown("Monitoring chambres froides industrielles")
|
||||
st.header("🔐 Connexion")
|
||||
if not st.session_state["authenticated"]:
|
||||
login = st.text_input("Nom d'utilisateur")
|
||||
|
||||
56
check_supervisor.py
Normal file
56
check_supervisor.py
Normal file
@@ -0,0 +1,56 @@
|
||||
import subprocess
|
||||
import smtplib
|
||||
from email.mime.text import MIMEText
|
||||
|
||||
def envoyer_mail(sujet, message, destinataires):
|
||||
msg = MIMEText(message)
|
||||
msg['Subject'] = sujet
|
||||
msg['From'] = 'alertes_saclay@domo91.fr'
|
||||
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.sendmail(msg['From'], destinataires, msg.as_string())
|
||||
print(f"📧 Mail envoyé à {destinataires}")
|
||||
except Exception as e:
|
||||
print(f"Erreur envoi mail : {e}")
|
||||
|
||||
# Liste des processus attendus
|
||||
processus_attendus = [
|
||||
"Chauffage",
|
||||
"Cuisine_Saclay",
|
||||
"Monitor",
|
||||
"Streamlit",
|
||||
"Telegram_sondes",
|
||||
"cuisine_meudon"
|
||||
]
|
||||
|
||||
# Commande supervisor
|
||||
output = subprocess.getoutput("supervisorctl status")
|
||||
|
||||
# Vérification
|
||||
anomalies = []
|
||||
for line in output.splitlines():
|
||||
for process in processus_attendus:
|
||||
if line.startswith(process) and "RUNNING" not in line:
|
||||
anomalies.append(line)
|
||||
|
||||
# Logs (facultatif)
|
||||
with open("/var/log/supervisor_alert.log", "a") as log:
|
||||
if anomalies:
|
||||
log.write("🚨 Anomalies détectées :\n")
|
||||
for a in anomalies:
|
||||
log.write(f"{a}\n")
|
||||
else:
|
||||
log.write("✅ Tous les processus sont OK.\n")
|
||||
|
||||
# Envoi de mail si nécessaire
|
||||
if anomalies:
|
||||
message = "\n".join(anomalies)
|
||||
envoyer_mail(
|
||||
sujet="🚨 Alerte Supervisor : processus en erreur",
|
||||
message=message,
|
||||
destinataires=["services@domo91.fr"]
|
||||
)
|
||||
|
||||
47
rapport_supervisor.py
Normal file
47
rapport_supervisor.py
Normal file
@@ -0,0 +1,47 @@
|
||||
import subprocess
|
||||
import smtplib
|
||||
from email.mime.text import MIMEText
|
||||
from datetime import datetime
|
||||
|
||||
# Informations mail
|
||||
FROM = "alertes_saclay@domo91.fr"
|
||||
TO = ["services@domo91.fr"]
|
||||
SUBJECT = f"🟢 Rapport quotidien - Supervisor OK ({datetime.now().strftime('%d/%m/%Y')})"
|
||||
|
||||
# Liste des services attendus
|
||||
processus_attendus = [
|
||||
"Chauffage",
|
||||
"Cuisine_Saclay",
|
||||
"Monitor",
|
||||
"Streamlit",
|
||||
"Telegram_sondes",
|
||||
"cuisine_meudon"
|
||||
]
|
||||
|
||||
# Vérifie les statuts
|
||||
output = subprocess.getoutput("supervisorctl status")
|
||||
etat = "\n".join(line for line in output.splitlines() if any(p in line for p in processus_attendus))
|
||||
|
||||
# Contenu du mail
|
||||
message = f"""Bonjour,
|
||||
|
||||
Voici l'état des processus supervisés ce jour ({datetime.now().strftime('%Y-%m-%d %H:%M')}).
|
||||
|
||||
{etat}
|
||||
|
||||
Cordialement,
|
||||
Domo91
|
||||
"""
|
||||
|
||||
msg = MIMEText(message)
|
||||
msg["Subject"] = SUBJECT
|
||||
msg["From"] = FROM
|
||||
msg["To"] = ", ".join(TO)
|
||||
|
||||
try:
|
||||
with smtplib.SMTP_SSL("smtp.mail.ovh.net", 465) as server:
|
||||
server.login(FROM, "Kdpke674y23Feq^H")
|
||||
server.sendmail(FROM, TO, msg.as_string())
|
||||
print("✅ Rapport envoyé avec succès.")
|
||||
except Exception as e:
|
||||
print(f"Erreur envoi mail : {e}")
|
||||
Reference in New Issue
Block a user