resetbutton dashboard + agent
This commit is contained in:
@@ -4043,6 +4043,9 @@ class JTLWAFiAgent:
|
||||
elif event_type == 'command.whois':
|
||||
await self._handle_whois_command(event_data)
|
||||
|
||||
elif event_type == 'command.reset_stats':
|
||||
await self._handle_reset_stats_command(event_data)
|
||||
|
||||
elif event_type == 'log.subscribe':
|
||||
shop = event_data.get('shop')
|
||||
if shop:
|
||||
@@ -4589,6 +4592,41 @@ class JTLWAFiAgent:
|
||||
'error': str(e)
|
||||
})
|
||||
|
||||
async def _handle_reset_stats_command(self, data: Dict[str, Any]):
|
||||
"""Setzt alle In-Memory Caches und Statistiken zurück."""
|
||||
global _ip_info_cache, _whois_cache, _shop_stats_trackers
|
||||
|
||||
command_id = data.get('command_id', 'unknown')
|
||||
|
||||
try:
|
||||
# IP-Info Cache leeren
|
||||
_ip_info_cache.clear()
|
||||
logger.info("IP-Info Cache geleert")
|
||||
|
||||
# WHOIS Cache leeren
|
||||
_whois_cache.clear()
|
||||
logger.info("WHOIS Cache geleert")
|
||||
|
||||
# LiveStats Tracker für alle Shops leeren
|
||||
_shop_stats_trackers.clear()
|
||||
logger.info("LiveStats Tracker geleert")
|
||||
|
||||
await self._send_event('command.result', {
|
||||
'command_id': command_id,
|
||||
'status': 'success',
|
||||
'message': f'Agent {self.hostname}: Alle Caches zurückgesetzt'
|
||||
})
|
||||
|
||||
logger.info("Reset Stats: Alle In-Memory Daten zurückgesetzt")
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Reset Stats Fehler: {e}")
|
||||
await self._send_event('command.result', {
|
||||
'command_id': command_id,
|
||||
'status': 'error',
|
||||
'message': str(e)
|
||||
})
|
||||
|
||||
async def _periodic_tasks(self):
|
||||
"""Führt periodische Tasks aus."""
|
||||
while self.running:
|
||||
|
||||
Reference in New Issue
Block a user