's'
This commit is contained in:
@@ -352,8 +352,6 @@ def _default_service_status(spec: ServiceSpec, detail: str) -> dict:
|
||||
|
||||
|
||||
async def query_service(spec: ServiceSpec) -> dict:
|
||||
if sys.platform == "win32":
|
||||
return _default_service_status(spec, "Linux-only stack integration")
|
||||
if not SERVICE_CTL.is_file():
|
||||
return _default_service_status(spec, "Service controller script is missing")
|
||||
code, output = await _run_command(["bash", str(SERVICE_CTL), spec.service_id, "status"])
|
||||
@@ -385,8 +383,6 @@ async def service_action(service_id: str, action: str) -> dict:
|
||||
spec = next((item for item in SERVICE_SPECS if item.service_id == service_id), None)
|
||||
if not spec:
|
||||
raise KeyError(f"Unknown service: {service_id}")
|
||||
if sys.platform == "win32":
|
||||
return _default_service_status(spec, "Linux-only stack integration")
|
||||
if not SERVICE_CTL.is_file():
|
||||
return _default_service_status(spec, "Service controller script is missing")
|
||||
|
||||
@@ -516,7 +512,7 @@ def network_iface_stats() -> dict[str, Any]:
|
||||
"""Linux /proc/net/dev 累计流量(自开机或计数器复位以来)。"""
|
||||
dev = Path("/proc/net/dev")
|
||||
interfaces: list[dict[str, int | str]] = []
|
||||
if sys.platform == "win32" or not dev.is_file():
|
||||
if not dev.is_file():
|
||||
return {"interfaces": interfaces}
|
||||
skip_prefixes = ("lo", "docker", "veth", "br-", "virbr", "tun", "tap")
|
||||
try:
|
||||
@@ -699,7 +695,7 @@ def _read_uptime_seconds() -> Optional[float]:
|
||||
|
||||
|
||||
def system_snapshot() -> dict:
|
||||
disk = shutil.disk_usage(BASE_DIR.anchor if sys.platform == "win32" else "/")
|
||||
disk = shutil.disk_usage("/")
|
||||
meminfo = _read_meminfo()
|
||||
load = os.getloadavg() if hasattr(os, "getloadavg") else (0.0, 0.0, 0.0)
|
||||
snapshot = {
|
||||
@@ -713,17 +709,16 @@ def system_snapshot() -> dict:
|
||||
"uptime_seconds": _read_uptime_seconds(),
|
||||
"netdata": {"available": False},
|
||||
}
|
||||
if sys.platform != "win32":
|
||||
try:
|
||||
with urlopen("http://127.0.0.1:19999/api/v1/info", timeout=1.5) as response:
|
||||
payload = json.loads(response.read().decode("utf-8", "replace"))
|
||||
snapshot["netdata"] = {
|
||||
"available": True,
|
||||
"version": payload.get("version", ""),
|
||||
"mirrored_hosts": payload.get("mirrored_hosts", []),
|
||||
}
|
||||
except Exception:
|
||||
pass
|
||||
try:
|
||||
with urlopen("http://127.0.0.1:19999/api/v1/info", timeout=1.5) as response:
|
||||
payload = json.loads(response.read().decode("utf-8", "replace"))
|
||||
snapshot["netdata"] = {
|
||||
"available": True,
|
||||
"version": payload.get("version", ""),
|
||||
"mirrored_hosts": payload.get("mirrored_hosts", []),
|
||||
}
|
||||
except Exception:
|
||||
pass
|
||||
return snapshot
|
||||
|
||||
|
||||
|
||||
Reference in New Issue
Block a user