Files
haproxy-dashboard/templates/statistics.html
Mateusz Gruszczyński ef4f9de301 redactor
2025-11-01 21:30:28 +01:00

126 lines
5.7 KiB
HTML

{% extends "base.html" %}
{% set active_page = "" %}
{% block title %}HAProxy • Statistics{% endblock %}
{% block head %}
{% 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">Statystyki</li></ol></nav>{% endblock %}
{% block content %}
<!-- Header -->
<header>
<a href="/home" style="text-decoration: none;">
<h3 style="color: grey; font-size: 22px;" class="logo">
<i style="margin: 8px;" class="fas fa-globe"></i>Haproxy Configurator
</h3>
</a>
<a href="/home" class="menu-link">Home</a>
<a href="/" class="menu-link">Add Frontend&Backend</a>
<a href="/edit" class="menu-link">Edit HAProxy Config</a>
<a href="/logs" class="menu-link">Security Events</a>
<a href="/statistics" class="menu-link active">Statistics</a>
<a href="http://{{ request.host.split(':')[0] }}:8484/stats" class="menu-link" target="_blank">HAProxy Stats</a>
</header>
<!-- Main Content -->
<div class="container">
<h1>
<i class="fas fa-chart-line"></i> HAProxy Statistics
</h1>
{% if stats %}
<!-- Summary Cards -->
<div class="row mb-4">
<div class="col-md-3">
<div class="card text-white bg-info summary-card">
<div class="card-body">
<h5 class="card-title">Total Frontends</h5>
<h2>{{ stats|length }}</h2>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card text-white bg-success summary-card">
<div class="card-body">
<h5 class="card-title">Total Connections</h5>
<h2>{{ stats|map(attribute='conn_tot')|sum }}</h2>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card text-white bg-warning summary-card">
<div class="card-body">
<h5 class="card-title">4xx Errors</h5>
<h2>{{ stats|map(attribute='4xx_errors')|sum }}</h2>
</div>
</div>
</div>
<div class="col-md-3">
<div class="card text-white bg-danger summary-card">
<div class="card-body">
<h5 class="card-title">5xx Errors</h5>
<h2>{{ stats|map(attribute='5xx_errors')|sum }}</h2>
</div>
</div>
</div>
</div>
<!-- Statistics Table -->
<div class="table-responsive">
<table class="table table-hover table-striped">
<thead>
<tr>
<th><i class="fas fa-code"></i> Frontend Name</th>
<th><i class="fas fa-server"></i> Server Name</th>
<th class="text-center">4xx Errors</th>
<th class="text-center">5xx Errors</th>
<th class="text-right">Bytes In (MB)</th>
<th class="text-right">Bytes Out (MB)</th>
<th class="text-center">Total Connections</th>
</tr>
</thead>
<tbody>
{% for stat in stats %}
<tr>
<td>
<span class="badge bg-info">{{ stat.frontend_name }}</span>
</td>
<td>
<span class="badge bg-secondary">{{ stat.server_name }}</span>
</td>
<td class="text-center">
{% if stat['4xx_errors'] > 0 %}
<span class="badge bg-warning">{{ stat['4xx_errors'] }}</span>
{% else %}
<span class="badge bg-success">{{ stat['4xx_errors'] }}</span>
{% endif %}
</td>
<td class="text-center">
{% if stat['5xx_errors'] > 0 %}
<span class="badge bg-danger">{{ stat['5xx_errors'] }}</span>
{% else %}
<span class="badge bg-success">{{ stat['5xx_errors'] }}</span>
{% endif %}
</td>
<td class="text-right">{{ "%.2f"|format(stat.bytes_in_mb) }}</td>
<td class="text-right">{{ "%.2f"|format(stat.bytes_out_mb) }}</td>
<td class="text-center">
<strong>{{ stat.conn_tot }}</strong>
</td>
</tr>
{% endfor %}
</tbody>
</table>
</div>
{% else %}
<div class="alert alert-info no-data">
<i class="fas fa-info-circle"></i> No statistics available
</div>
{% endif %}
</div>
<!-- Footer -->
<footer>
<p>&copy; 2025 HAProxy Configurator. All rights reserved.</p>
</footer>
{% endblock %}
{% block scripts %}
{% endblock %}