From 656f53c024a4f1d2aa66b52d4e353d85b2a749cd Mon Sep 17 00:00:00 2001 From: Thomas Ciesla Date: Fri, 9 Jan 2026 16:00:10 +0100 Subject: [PATCH] reset stats fix --- jtl-wafi-agent.py | 18 +++++++++++++++--- 1 file changed, 15 insertions(+), 3 deletions(-) diff --git a/jtl-wafi-agent.py b/jtl-wafi-agent.py index 3ca4365..634e624 100644 --- a/jtl-wafi-agent.py +++ b/jtl-wafi-agent.py @@ -4679,7 +4679,7 @@ class JTLWAFiAgent: }) async def _handle_reset_stats_command(self, data: Dict[str, Any]): - """Setzt alle In-Memory Caches und Statistiken zurück.""" + """Setzt alle In-Memory Caches, Statistiken und Log-Files zurück.""" global _ip_info_cache, _whois_cache, _shop_stats_trackers command_id = data.get('command_id', 'unknown') @@ -4697,13 +4697,25 @@ class JTLWAFiAgent: _shop_stats_trackers.clear() logger.info("LiveStats Tracker geleert") + # Log-Files aller aktiven Shops löschen + deleted_logs = 0 + for shop in get_active_shops(): + log_file = os.path.join(VHOSTS_DIR, shop, 'httpdocs', SHOP_LOG_FILE) + if os.path.isfile(log_file): + try: + os.remove(log_file) + deleted_logs += 1 + logger.info(f"Log-File gelöscht: {log_file}") + except Exception as e: + logger.warning(f"Konnte Log-File nicht löschen {log_file}: {e}") + await self._send_event('command.result', { 'command_id': command_id, 'status': 'success', - 'message': f'Agent {self.hostname}: Alle Caches zurückgesetzt' + 'message': f'Agent {self.hostname}: Alle Caches zurückgesetzt, {deleted_logs} Log-Files gelöscht' }) - logger.info("Reset Stats: Alle In-Memory Daten zurückgesetzt") + logger.info(f"Reset Stats: Alle In-Memory Daten zurückgesetzt, {deleted_logs} Log-Files gelöscht") except Exception as e: logger.error(f"Reset Stats Fehler: {e}")