mirror of
https://github.com/lrnselfreliance/wrolpi.git
synced 2026-11-26 09:56:17 -05:00
Adding server uptime to status pages.
This commit is contained in:
parent
b408d11ea1
commit
d4f1cfb859
6 changed files with 107 additions and 3 deletions
|
|
@ -38,6 +38,7 @@ from controller.lib.status import (
|
|||
get_load_status,
|
||||
get_memory_status,
|
||||
get_primary_drive_status,
|
||||
get_uptime_status,
|
||||
)
|
||||
from controller.lib.status_worker import status_worker_loop
|
||||
from controller.lib.systemd import get_all_services_status
|
||||
|
|
@ -118,6 +119,7 @@ async def dashboard(request: Request):
|
|||
memory = cached.get("memory_stats") or {}
|
||||
load = cached.get("load_stats") or {}
|
||||
iostat = cached.get("iostat_stats") or {}
|
||||
uptime = cached.get("uptime_stats") or {}
|
||||
drives = cached.get("drives_stats") or []
|
||||
primary_drive = None
|
||||
for drive in drives:
|
||||
|
|
@ -130,6 +132,7 @@ async def dashboard(request: Request):
|
|||
memory = get_memory_status()
|
||||
load = get_load_status()
|
||||
iostat = get_iostat_status()
|
||||
uptime = get_uptime_status()
|
||||
primary_drive = get_primary_drive_status()
|
||||
|
||||
# Format storage data
|
||||
|
|
@ -141,6 +144,15 @@ async def dashboard(request: Request):
|
|||
"free_gb": round(free_bytes / (1024 ** 3), 1),
|
||||
}
|
||||
|
||||
# Format uptime
|
||||
uptime_seconds = uptime.get("uptime_seconds", 0)
|
||||
if uptime_seconds:
|
||||
days = uptime_seconds // 86400
|
||||
hours = (uptime_seconds % 86400) // 3600
|
||||
uptime_formatted = f"{days}d {hours}h" if days > 0 else f"{hours}h {(uptime_seconds % 3600) // 60}m"
|
||||
else:
|
||||
uptime_formatted = "--"
|
||||
|
||||
# Get service status
|
||||
if is_docker_mode():
|
||||
if can_manage_containers():
|
||||
|
|
@ -175,6 +187,10 @@ async def dashboard(request: Request):
|
|||
"iostat": {
|
||||
"percent_iowait": iostat.get("percent_iowait"),
|
||||
},
|
||||
"uptime": {
|
||||
"formatted": uptime_formatted,
|
||||
"seconds": uptime_seconds,
|
||||
},
|
||||
|
||||
# Real service status
|
||||
"services": services,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue