Clean GPU names in dashboard and remove stale servers from DB
This commit is contained in:
32
app/app.py
32
app/app.py
@@ -197,6 +197,12 @@ def collect_all():
|
|||||||
|
|
||||||
# Update database (all in main collector thread)
|
# Update database (all in main collector thread)
|
||||||
with app.app_context():
|
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():
|
for key, (entry, result) in results.items():
|
||||||
server = Server.query.filter_by(
|
server = Server.query.filter_by(
|
||||||
username=entry['username'],
|
username=entry['username'],
|
||||||
@@ -363,6 +369,32 @@ def temp_color(temp_c):
|
|||||||
return '#22c55e'
|
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')
|
@app.template_filter('usage_color')
|
||||||
def usage_color(percent):
|
def usage_color(percent):
|
||||||
try:
|
try:
|
||||||
|
|||||||
@@ -144,6 +144,15 @@ main {
|
|||||||
.server-os {
|
.server-os {
|
||||||
font-size: 0.75rem;
|
font-size: 0.75rem;
|
||||||
color: #64748b;
|
color: #64748b;
|
||||||
|
margin-bottom: 2px;
|
||||||
|
overflow: hidden;
|
||||||
|
text-overflow: ellipsis;
|
||||||
|
white-space: nowrap;
|
||||||
|
}
|
||||||
|
|
||||||
|
.server-hw {
|
||||||
|
font-size: 0.7rem;
|
||||||
|
color: #475569;
|
||||||
margin-bottom: 10px;
|
margin-bottom: 10px;
|
||||||
overflow: hidden;
|
overflow: hidden;
|
||||||
text-overflow: ellipsis;
|
text-overflow: ellipsis;
|
||||||
|
|||||||
@@ -171,7 +171,7 @@
|
|||||||
<h4>GPUs</h4>
|
<h4>GPUs</h4>
|
||||||
<table>
|
<table>
|
||||||
{% for gpu in gpus %}
|
{% for gpu in gpus %}
|
||||||
<tr><td>GPU {{ loop.index0 }}</td><td>{{ gpu.get('description', '-') }}</td></tr>
|
<tr><td>GPU {{ loop.index0 }}</td><td>{{ gpu.get('description', '-')|clean_gpu }}</td></tr>
|
||||||
{% endfor %}
|
{% endfor %}
|
||||||
</table>
|
</table>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
Reference in New Issue
Block a user