Add temperature monitoring and optional server URL links to dashboard
All checks were successful
Build-Publish / build (linux/amd64) (push) Successful in 5s
Build-Publish / build (linux/arm64) (push) Successful in 11s
Build-Publish / create-manifest (push) Successful in 2s
Build-Publish / publish-template (push) Successful in 7s

This commit is contained in:
j
2026-03-07 23:08:57 +13:00
parent d8338bbf82
commit df29cd88de
5 changed files with 96 additions and 4 deletions

View File

@@ -35,6 +35,7 @@ class Server(db.Model):
username = db.Column(db.String(255), nullable=False)
hostname = db.Column(db.String(255), nullable=False)
primary_ip = db.Column(db.String(45), default='')
url = db.Column(db.String(1024), default='')
is_online = db.Column(db.Boolean, default=False)
last_collected = db.Column(db.DateTime, nullable=True)
details = db.Column(db.JSON, nullable=True)
@@ -55,13 +56,16 @@ def parse_infrastructure_conf():
if line[0] not in (' ', '\t'):
current_group = line.strip()
else:
entry = line.strip()
parts = line.strip().split(None, 1)
entry = parts[0] if parts else ''
url = parts[1] if len(parts) > 1 else ''
if '@' in entry:
user, host = entry.split('@', 1)
servers.append({
'group': current_group or 'Default',
'username': user.strip(),
'hostname': host.strip(),
'url': url.strip(),
})
except FileNotFoundError:
logger.error("infrastructure.conf not found at %s", INFRA_CONF_PATH)
@@ -204,6 +208,7 @@ def collect_all():
db.session.add(server)
server.group_name = entry['group']
server.url = entry.get('url', '')
server.is_online = result.get('is_online', False)
server.last_collected = datetime.now(timezone.utc)
server.details = result
@@ -271,6 +276,7 @@ def api_servers():
'username': s.username,
'hostname': s.hostname,
'primary_ip': s.primary_ip,
'url': s.url,
'is_online': s.is_online,
'last_collected': s.last_collected.isoformat() if s.last_collected else None,
'details': s.details,
@@ -327,6 +333,21 @@ def format_uptime(seconds):
return f"{hours}h {minutes}m"
@app.template_filter('temp_color')
def temp_color(temp_c):
try:
t = float(temp_c)
except (TypeError, ValueError):
return '#64748b'
if t >= 90:
return '#ef4444'
if t >= 75:
return '#f97316'
if t >= 60:
return '#eab308'
return '#22c55e'
@app.template_filter('usage_color')
def usage_color(percent):
try: