From 95c20df073dcdfab0a7ed21c36fe7d5da0c13352 Mon Sep 17 00:00:00 2001 From: j Date: Sun, 8 Mar 2026 13:29:37 +1300 Subject: [PATCH] Clean GPU names in dashboard and remove stale servers from DB --- app/app.py | 32 ++++++++++++++++++++++++++++++++ app/static/style.css | 9 +++++++++ app/templates/index.html | 2 +- 3 files changed, 42 insertions(+), 1 deletion(-) diff --git a/app/app.py b/app/app.py index ba2aee3..afb6b29 100644 --- a/app/app.py +++ b/app/app.py @@ -197,6 +197,12 @@ def collect_all(): # Update database (all in main collector thread) with app.app_context(): + # Remove servers no longer in config + config_keys = {(e['username'], e['hostname']) for e in entries} + for server in Server.query.all(): + if (server.username, server.hostname) not in config_keys: + db.session.delete(server) + for key, (entry, result) in results.items(): server = Server.query.filter_by( username=entry['username'], @@ -363,6 +369,32 @@ def temp_color(temp_c): return '#22c55e' +@app.template_filter('clean_gpu') +def clean_gpu(description): + if not description: + return '-' + s = str(description) + # Strip PCI address prefix (e.g. "01:00.0 ") + import re + s = re.sub(r'^[0-9a-f:.]+\s+', '', s, flags=re.IGNORECASE) + # Strip type prefix + for prefix in ['VGA compatible controller: ', '3D controller: ', 'Display controller: ']: + if s.startswith(prefix): + s = s[len(prefix):] + # Strip common vendor prefixes + for vendor in ['NVIDIA Corporation ', 'Advanced Micro Devices, Inc. ', 'AMD ', 'Intel Corporation ', + 'Advanced Micro Devices Inc. ', 'Matrox Electronics Systems Ltd. ']: + if s.startswith(vendor): + s = s[len(vendor):] + # Strip revision suffix + s = re.sub(r'\s*\(rev [0-9a-f]+\)\s*$', '', s, flags=re.IGNORECASE) + # Prefer bracketed name if present (e.g. "GA106 [GeForce RTX 3060]" -> "GeForce RTX 3060") + bracket = re.search(r'\[(.+)\]', s) + if bracket: + s = bracket.group(1) + return s.strip() + + @app.template_filter('usage_color') def usage_color(percent): try: diff --git a/app/static/style.css b/app/static/style.css index 73707d4..b91b43e 100644 --- a/app/static/style.css +++ b/app/static/style.css @@ -144,6 +144,15 @@ main { .server-os { font-size: 0.75rem; color: #64748b; + margin-bottom: 2px; + overflow: hidden; + text-overflow: ellipsis; + white-space: nowrap; +} + +.server-hw { + font-size: 0.7rem; + color: #475569; margin-bottom: 10px; overflow: hidden; text-overflow: ellipsis; diff --git a/app/templates/index.html b/app/templates/index.html index 213de57..4414942 100644 --- a/app/templates/index.html +++ b/app/templates/index.html @@ -171,7 +171,7 @@

GPUs

{% for gpu in gpus %} - + {% endfor %}
GPU {{ loop.index0 }}{{ gpu.get('description', '-') }}
GPU {{ loop.index0 }}{{ gpu.get('description', '-')|clean_gpu }}