Ajout ou correction sur develop___21:49

This commit is contained in:
2025-04-26 21:50:05 +02:00
parent c4ad3c7ba6
commit ba4f5d7d4f
2 changed files with 23 additions and 22 deletions

View File

@@ -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("/var/log/monitor.csv", sep=";", index=False)
except Exception as e:
print(f"Erreur : {e}", flush=True)

View File

@@ -511,27 +511,28 @@ if st.session_state["authenticated"]:
except Exception as e:
st.error(f"Erreur SQL (admin) : {e}")
# --- ONGLET TRAFFIC ------
elif onglet == "Traffic":
st.markdown("## 🚦 Connexions récentes")
try:
conn = mysql.connector.connect(**db_config)
cursor = conn.cursor(dictionary=True)
cursor.execute(
"SELECT Utilisateur, Lieu, Date_Connexion FROM Connexion_Log WHERE Lieu IS NOT NULL ORDER BY Date_Connexion DESC LIMIT 200"
)
connexions = cursor.fetchall()
cursor.close()
conn.close()
elif onglet == "Traffic":
st.markdown("## 🚦 Connexions récentes")
try:
conn = mysql.connector.connect(**db_config)
cursor = conn.cursor(dictionary=True)
cursor.execute(
"SELECT Utilisateur, Lieu, Date_Connexion FROM Connexion_Log WHERE Lieu IS NOT NULL ORDER BY Date_Connexion DESC LIMIT 200"
)
connexions = cursor.fetchall()
cursor.close()
conn.close()
if connexions:
df_connexions = pd.DataFrame(connexions)
st.success(f"{len(df_connexions)} connexions trouvées.") # Compteur affiché proprement
st.dataframe(df_connexions, use_container_width=True)
else:
st.info("Aucune connexion enregistrée.")
except Exception as e:
st.error(f"Erreur chargement des connexions : {e}")
if connexions:
df_connexions = pd.DataFrame(connexions)
st.dataframe(df_connexions, use_container_width=True)
else:
st.info("Aucune connexion enregistrée.")
except Exception as e:
st.error(f"Erreur chargement des connexions : {e}")
except Exception as err: # petit bug dans ton except ici (tu avais écrit "except exception")
st.error(f"Erreur MySQL : {err}")
except Exception as err:
st.error(f"Erreur MySQL : {err}")