reset stats fix

This commit is contained in:
Thomas Ciesla
2026-01-09 16:00:10 +01:00
parent db8b0d0f67
commit 656f53c024

View File

@@ -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}")