feat(api): include server IPs in status endpoint
This commit is contained in:
@ -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
|
||||
|
||||
@ -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:
|
||||
|
||||
Reference in New Issue
Block a user