new options

This commit is contained in:
Mateusz Gruszczyński
2025-11-03 10:32:38 +01:00
parent d01ca3512e
commit 58205be555
4 changed files with 71 additions and 9 deletions

24
app.py
View File

@@ -100,11 +100,29 @@ def display_haproxy_stats():
parsed_stats = parse_haproxy_stats(haproxy_stats)
return render_template('statistics.html', stats=parsed_stats)
@app.route('/logs')
def display_logs():
@requires_auth
def display_haproxy_logs():
log_file_path = '/var/log/haproxy.log'
parsed_entries = parse_log_file(log_file_path)
return render_template('logs.html', entries=parsed_entries)
if not os.path.exists(log_file_path):
return render_template('logs.html',
logs=[],
error_message=f"Log file not found: {log_file_path}")
try:
logs = parse_log_file(log_file_path)
if not logs:
return render_template('logs.html',
logs=[],
error_message="Log file is empty or unreadable")
return render_template('logs.html', logs=logs)
except Exception as e:
return render_template('logs.html',
logs=[],
error_message=f"Error parsing logs: {str(e)}")
@app.route('/home')
def home():