new options
This commit is contained in:
24
app.py
24
app.py
@@ -100,11 +100,29 @@ def display_haproxy_stats():
|
|||||||
parsed_stats = parse_haproxy_stats(haproxy_stats)
|
parsed_stats = parse_haproxy_stats(haproxy_stats)
|
||||||
return render_template('statistics.html', stats=parsed_stats)
|
return render_template('statistics.html', stats=parsed_stats)
|
||||||
|
|
||||||
|
|
||||||
@app.route('/logs')
|
@app.route('/logs')
|
||||||
def display_logs():
|
@requires_auth
|
||||||
|
def display_haproxy_logs():
|
||||||
log_file_path = '/var/log/haproxy.log'
|
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')
|
@app.route('/home')
|
||||||
def home():
|
def home():
|
||||||
|
|||||||
@@ -6,6 +6,8 @@ document.addEventListener('DOMContentLoaded', function() {
|
|||||||
const resetBtn = document.getElementById('reset_filters');
|
const resetBtn = document.getElementById('reset_filters');
|
||||||
|
|
||||||
const logsTable = document.getElementById('logs_table');
|
const logsTable = document.getElementById('logs_table');
|
||||||
|
if (!logsTable) return; // Exit if no logs
|
||||||
|
|
||||||
const allRows = Array.from(document.querySelectorAll('.log-row'));
|
const allRows = Array.from(document.querySelectorAll('.log-row'));
|
||||||
|
|
||||||
// Filter function
|
// Filter function
|
||||||
|
|||||||
@@ -4,7 +4,15 @@
|
|||||||
|
|
||||||
{% block title %}HAProxy • Configuration{% endblock %}
|
{% block title %}HAProxy • Configuration{% endblock %}
|
||||||
|
|
||||||
{% block breadcrumb %}Configuration{% endblock %}
|
{% block breadcrumb %}
|
||||||
|
<nav aria-label="breadcrumb" class="mb-3">
|
||||||
|
<ol class="breadcrumb mb-0">
|
||||||
|
<li class="breadcrumb-item"><a href="{{ url_for('main.index') }}"><i class="bi bi-house"></i></a></li>
|
||||||
|
<li class="breadcrumb-item active" aria-current="page">Add Configuration</li>
|
||||||
|
</ol>
|
||||||
|
</nav>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
|
|||||||
@@ -4,17 +4,34 @@
|
|||||||
|
|
||||||
{% block title %}HAProxy • Logs{% endblock %}
|
{% block title %}HAProxy • Logs{% endblock %}
|
||||||
|
|
||||||
{% block breadcrumb %}Logs{% endblock %}
|
{% block breadcrumb %}
|
||||||
|
<nav aria-label="breadcrumb" class="mb-3">
|
||||||
|
<ol class="breadcrumb mb-0">
|
||||||
|
<li class="breadcrumb-item"><a href="{{ url_for('main.index') }}"><i class="bi bi-house"></i></a></li>
|
||||||
|
<li class="breadcrumb-item active" aria-current="page">Access Logs</li>
|
||||||
|
</ol>
|
||||||
|
</nav>
|
||||||
|
{% endblock %}
|
||||||
|
|
||||||
{% block content %}
|
{% block content %}
|
||||||
|
|
||||||
<div class="card shadow-sm mb-4">
|
<div class="card shadow-sm mb-4">
|
||||||
<div class="card-header bg-primary text-white">
|
<div class="card-header bg-info text-white">
|
||||||
<h5 class="mb-0"><i class="bi bi-file-text me-2"></i>HAProxy Access Logs</h5>
|
<h5 class="mb-0"><i class="bi bi-file-text me-2"></i>HAProxy Access Logs</h5>
|
||||||
</div>
|
</div>
|
||||||
<div class="card-body">
|
<div class="card-body">
|
||||||
|
|
||||||
{% if logs %}
|
<!-- Error/Info Messages -->
|
||||||
|
{% if error_message %}
|
||||||
|
<div class="alert alert-warning alert-dismissible fade show" role="alert">
|
||||||
|
<i class="bi bi-exclamation-triangle me-2"></i>
|
||||||
|
<strong>Warning:</strong> {{ error_message }}
|
||||||
|
<button type="button" class="btn-close" data-bs-dismiss="alert" aria-label="Close"></button>
|
||||||
|
</div>
|
||||||
|
{% endif %}
|
||||||
|
|
||||||
|
<!-- Filter Section (kompaktnie, jak było) -->
|
||||||
|
{% if logs and logs|length > 0 %}
|
||||||
<div class="row mb-3 g-2">
|
<div class="row mb-3 g-2">
|
||||||
<div class="col-auto">
|
<div class="col-auto">
|
||||||
<input type="text" class="form-control form-control-sm" id="filter_ip" placeholder="Filter by IP">
|
<input type="text" class="form-control form-control-sm" id="filter_ip" placeholder="Filter by IP">
|
||||||
@@ -161,9 +178,25 @@
|
|||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
{% else %}
|
{% elif logs %}
|
||||||
|
<!-- Logs exist but empty after filtering -->
|
||||||
<div class="alert alert-info">
|
<div class="alert alert-info">
|
||||||
<i class="bi bi-info-circle me-2"></i>No log entries found.
|
<i class="bi bi-info-circle me-2"></i>No log entries match your filters.
|
||||||
|
</div>
|
||||||
|
{% else %}
|
||||||
|
<!-- No logs at all -->
|
||||||
|
<div class="alert alert-danger" role="alert">
|
||||||
|
<h4 class="alert-heading"><i class="bi bi-exclamation-circle me-2"></i>No logs available</h4>
|
||||||
|
<hr>
|
||||||
|
<p class="mb-2"><strong>Possible reasons:</strong></p>
|
||||||
|
<ul class="mb-0">
|
||||||
|
<li>Log file does not exist or is not readable</li>
|
||||||
|
<li>HAProxy is not configured to log requests</li>
|
||||||
|
<li>Log file path is incorrect in configuration</li>
|
||||||
|
<li>No requests have been processed yet</li>
|
||||||
|
</ul>
|
||||||
|
<hr class="my-2">
|
||||||
|
<p class="small text-muted mb-0">Check HAProxy configuration and log file permissions.</p>
|
||||||
</div>
|
</div>
|
||||||
{% endif %}
|
{% endif %}
|
||||||
|
|
||||||
@@ -171,4 +204,5 @@
|
|||||||
</div>
|
</div>
|
||||||
|
|
||||||
<script src="{{ url_for('static', filename='js/logs.js') }}"></script>
|
<script src="{{ url_for('static', filename='js/logs.js') }}"></script>
|
||||||
|
|
||||||
{% endblock %}
|
{% endblock %}
|
||||||
|
|||||||
Reference in New Issue
Block a user