Vorläufig fertiger server
Dieser Commit ist enthalten in:
@@ -561,91 +561,8 @@ def clear_attempts():
|
||||
@admin_bp.route("/lizenzserver/monitor")
|
||||
@login_required
|
||||
def license_monitor():
|
||||
"""License server live monitoring dashboard"""
|
||||
try:
|
||||
conn = get_connection()
|
||||
cur = conn.cursor()
|
||||
|
||||
# Get current statistics
|
||||
# Active validations in last 5 minutes
|
||||
cur.execute("""
|
||||
SELECT COUNT(DISTINCT license_id) as active_licenses,
|
||||
COUNT(*) as total_validations,
|
||||
COUNT(DISTINCT hardware_id) as unique_devices,
|
||||
COUNT(DISTINCT ip_address) as unique_ips
|
||||
FROM license_heartbeats
|
||||
WHERE timestamp > NOW() - INTERVAL '5 minutes'
|
||||
""")
|
||||
live_stats = cur.fetchone()
|
||||
|
||||
# Get validation rate (per minute)
|
||||
cur.execute("""
|
||||
SELECT DATE_TRUNC('minute', timestamp) as minute,
|
||||
COUNT(*) as validations
|
||||
FROM license_heartbeats
|
||||
WHERE timestamp > NOW() - INTERVAL '10 minutes'
|
||||
GROUP BY minute
|
||||
ORDER BY minute DESC
|
||||
LIMIT 10
|
||||
""")
|
||||
validation_rates = cur.fetchall()
|
||||
|
||||
# Get top active licenses
|
||||
cur.execute("""
|
||||
SELECT l.id, l.license_key, c.name as customer_name,
|
||||
COUNT(DISTINCT lh.hardware_id) as device_count,
|
||||
COUNT(*) as validation_count,
|
||||
MAX(lh.timestamp) as last_seen
|
||||
FROM licenses l
|
||||
JOIN customers c ON l.customer_id = c.id
|
||||
JOIN license_heartbeats lh ON l.id = lh.license_id
|
||||
WHERE lh.timestamp > NOW() - INTERVAL '15 minutes'
|
||||
GROUP BY l.id, l.license_key, c.name
|
||||
ORDER BY validation_count DESC
|
||||
LIMIT 10
|
||||
""")
|
||||
top_licenses = cur.fetchall()
|
||||
|
||||
# Get recent anomalies
|
||||
cur.execute("""
|
||||
SELECT ad.*, l.license_key, c.name as customer_name
|
||||
FROM anomaly_detections ad
|
||||
LEFT JOIN licenses l ON ad.license_id = l.id
|
||||
LEFT JOIN customers c ON l.customer_id = c.id
|
||||
WHERE ad.resolved = false
|
||||
ORDER BY ad.detected_at DESC
|
||||
LIMIT 10
|
||||
""")
|
||||
recent_anomalies = cur.fetchall()
|
||||
|
||||
# Get geographic distribution
|
||||
cur.execute("""
|
||||
SELECT ip_address, COUNT(*) as count
|
||||
FROM license_heartbeats
|
||||
WHERE timestamp > NOW() - INTERVAL '1 hour'
|
||||
AND ip_address IS NOT NULL
|
||||
GROUP BY ip_address
|
||||
ORDER BY count DESC
|
||||
LIMIT 20
|
||||
""")
|
||||
geo_distribution = cur.fetchall()
|
||||
|
||||
return render_template('license_monitor.html',
|
||||
live_stats=live_stats,
|
||||
validation_rates=validation_rates,
|
||||
top_licenses=top_licenses,
|
||||
recent_anomalies=recent_anomalies,
|
||||
geo_distribution=geo_distribution
|
||||
)
|
||||
|
||||
except Exception as e:
|
||||
flash(f'Fehler beim Laden der Monitoring-Daten: {str(e)}', 'error')
|
||||
return render_template('license_monitor.html')
|
||||
finally:
|
||||
if 'cur' in locals():
|
||||
cur.close()
|
||||
if 'conn' in locals():
|
||||
conn.close()
|
||||
"""Redirect to new analytics page"""
|
||||
return redirect(url_for('monitoring.analytics'))
|
||||
|
||||
|
||||
@admin_bp.route("/lizenzserver/analytics")
|
||||
|
||||
In neuem Issue referenzieren
Einen Benutzer sperren