new_functions_and_fixes #1
@@ -124,12 +124,10 @@
|
|||||||
|
|
||||||
<div class="row g-3 mb-3 d-none" id="ssl_fields">
|
<div class="row g-3 mb-3 d-none" id="ssl_fields">
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<label for="ssl_cert_path" class="form-label">SSL Certificate Path
|
<label for="ssl_cert_path" class="form-label">SSL Certificate Path</label>
|
||||||
<small>Upload certs in /ssl/</small></label>
|
|
||||||
|
|
||||||
<input type="text" class="form-control" id="ssl_cert_path" name="ssl_cert_path"
|
<input type="text" class="form-control" id="ssl_cert_path" name="ssl_cert_path"
|
||||||
value="/app/ssl/haproxy-configurator.pem">
|
value="/app/ssl/haproxy-configurator.pem">
|
||||||
<div class="form-text">Full path to .pem file</div>
|
<div class="form-text">Full path to .pem file, upload certs in /ssl/</div>
|
||||||
</div>
|
</div>
|
||||||
<div class="col-md-12">
|
<div class="col-md-12">
|
||||||
<div class="form-check">
|
<div class="form-check">
|
||||||
|
|||||||
@@ -13,18 +13,62 @@ def fetch_haproxy_stats():
|
|||||||
|
|
||||||
def parse_haproxy_stats(stats_data):
|
def parse_haproxy_stats(stats_data):
|
||||||
data = []
|
data = []
|
||||||
header_row = stats_data.splitlines()[0].replace('# ', '')
|
|
||||||
reader = csv.DictReader(stats_data.splitlines(), fieldnames=header_row.split(','))
|
# Skip empty lines and get header
|
||||||
next(reader)
|
lines = [line for line in stats_data.splitlines() if line.strip()]
|
||||||
|
if not lines:
|
||||||
|
return data
|
||||||
|
|
||||||
|
header_row = lines[0].replace('# ', '')
|
||||||
|
|
||||||
|
# Parse CSV
|
||||||
|
reader = csv.DictReader(lines, fieldnames=header_row.split(','))
|
||||||
|
next(reader) # Skip header
|
||||||
|
|
||||||
for row in reader:
|
for row in reader:
|
||||||
if row['svname'] != 'BACKEND':
|
# Only process servers, skip BACKEND summary rows
|
||||||
data.append({
|
if row.get('svname') == 'BACKEND':
|
||||||
'frontend_name': row['pxname'],
|
continue
|
||||||
'server_name': row['svname'],
|
|
||||||
'4xx_errors': row['hrsp_4xx'],
|
# Strip whitespace from values
|
||||||
'5xx_errors': row['hrsp_5xx'],
|
row = {k: v.strip() if isinstance(v, str) else v for k, v in row.items()}
|
||||||
'bytes_in_mb': f'{float(row["bin"]) / (1024 * 1024):.2f}',
|
|
||||||
'bytes_out_mb': f'{float(row["bout"]) / (1024 * 1024):.2f}',
|
# Safe conversion to int/float
|
||||||
'conn_tot': row['conn_tot'],
|
try:
|
||||||
})
|
conn_tot = int(row.get('conn_tot', 0) or 0)
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
conn_tot = 0
|
||||||
|
|
||||||
|
try:
|
||||||
|
hrsp_4xx = int(row.get('hrsp_4xx', 0) or 0)
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
hrsp_4xx = 0
|
||||||
|
|
||||||
|
try:
|
||||||
|
hrsp_5xx = int(row.get('hrsp_5xx', 0) or 0)
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
hrsp_5xx = 0
|
||||||
|
|
||||||
|
try:
|
||||||
|
bin_bytes = float(row.get('bin', 0) or 0)
|
||||||
|
bytes_in_mb = f'{bin_bytes / (1024 * 1024):.2f}'
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
bytes_in_mb = '0.00'
|
||||||
|
|
||||||
|
try:
|
||||||
|
bout_bytes = float(row.get('bout', 0) or 0)
|
||||||
|
bytes_out_mb = f'{bout_bytes / (1024 * 1024):.2f}'
|
||||||
|
except (ValueError, TypeError):
|
||||||
|
bytes_out_mb = '0.00'
|
||||||
|
|
||||||
|
data.append({
|
||||||
|
'frontend_name': row.get('pxname', 'Unknown'),
|
||||||
|
'server_name': row.get('svname', 'Unknown'),
|
||||||
|
'4xx_errors': hrsp_4xx,
|
||||||
|
'5xx_errors': hrsp_5xx,
|
||||||
|
'bytes_in_mb': bytes_in_mb,
|
||||||
|
'bytes_out_mb': bytes_out_mb,
|
||||||
|
'conn_tot': conn_tot, # ✅ Teraz INT
|
||||||
|
})
|
||||||
|
|
||||||
return data
|
return data
|
||||||
Reference in New Issue
Block a user