feat(api): include server IPs in status endpoint

This commit is contained in:
ReturnFI
2025-09-18 21:21:10 +00:00
parent 677634c25c
commit fd969af7ff
2 changed files with 9 additions and 0 deletions

View File

@ -1,4 +1,5 @@
from pydantic import BaseModel
from typing import Optional
# We can't return bytes because the underlying script is returning human readable values which are hard to parse it
@ -8,6 +9,8 @@ class ServerStatusResponse(BaseModel):
# System Info
uptime: str
boot_time: str
server_ipv4: str
server_ipv6: str
cpu_usage: str
ram_usage: str
total_ram: str

View File

@ -46,6 +46,8 @@ def __parse_server_status(server_info: str) -> ServerStatusResponse:
data = {
'uptime': 'N/A',
'boot_time': 'N/A',
'server_ipv4': 'N/A',
'server_ipv6': 'N/A',
'cpu_usage': '0%',
'total_ram': '0MB',
'ram_usage': '0MB',
@ -88,6 +90,10 @@ def __parse_server_status(server_info: str) -> ServerStatusResponse:
uptime_part, _, boottime_part = value.partition('(')
data['uptime'] = uptime_part.strip()
data['boot_time'] = boottime_part.replace('since ', '').replace(')', '').strip()
elif 'server ipv4' in key:
data['server_ipv4'] = value
elif 'server ipv6' in key:
data['server_ipv6'] = value
elif 'cpu usage' in key:
data['cpu_usage'] = value
elif 'used ram' in key: