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: if log_entries:
df_logs = pd.DataFrame(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: except Exception as e:
print(f"Erreur : {e}", flush=True) print(f"Erreur : {e}", flush=True)

View File

@@ -511,27 +511,28 @@ if st.session_state["authenticated"]:
except Exception as e: except Exception as e:
st.error(f"Erreur SQL (admin) : {e}") st.error(f"Erreur SQL (admin) : {e}")
# --- ONGLET TRAFFIC ------ # --- ONGLET TRAFFIC ------
elif onglet == "Traffic": elif onglet == "Traffic":
st.markdown("## 🚦 Connexions récentes") st.markdown("## 🚦 Connexions récentes")
try: try:
conn = mysql.connector.connect(**db_config) conn = mysql.connector.connect(**db_config)
cursor = conn.cursor(dictionary=True) cursor = conn.cursor(dictionary=True)
cursor.execute( cursor.execute(
"SELECT Utilisateur, Lieu, Date_Connexion FROM Connexion_Log WHERE Lieu IS NOT NULL ORDER BY Date_Connexion DESC LIMIT 200" "SELECT Utilisateur, Lieu, Date_Connexion FROM Connexion_Log WHERE Lieu IS NOT NULL ORDER BY Date_Connexion DESC LIMIT 200"
) )
connexions = cursor.fetchall() connexions = cursor.fetchall()
cursor.close() cursor.close()
conn.close() conn.close()
if connexions: if connexions:
df_connexions = pd.DataFrame(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)
st.dataframe(df_connexions, use_container_width=True) else:
else: st.info("Aucune connexion enregistrée.")
st.info("Aucune connexion enregistrée.") except Exception as e:
except Exception as e: st.error(f"Erreur chargement des connexions : {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}")