Adding server uptime to status pages.

This commit is contained in:
Roland 2025-12-26 10:05:13 -07:00
parent b408d11ea1
commit d4f1cfb859
No known key found for this signature in database
GPG key ID: 1BA620CE6C9A4680
6 changed files with 107 additions and 3 deletions

View file

@ -341,6 +341,25 @@ def get_processes_status() -> list[dict]:
return processes
def get_uptime_status() -> dict:
"""
Get system uptime information.
Returns format:
dict with keys: boot_time (ISO timestamp), uptime_seconds (int)
"""
from datetime import datetime
boot_time = psutil.boot_time()
boot_datetime = datetime.fromtimestamp(boot_time)
uptime_seconds = int((datetime.now() - boot_datetime).total_seconds())
return {
"boot_time": boot_datetime.isoformat(),
"uptime_seconds": uptime_seconds,
}
IGNORED_DISK_NAMES = ('loop', 'ram')