chages in profiles

This commit is contained in:
Mateusz Gruszczyński
2026-05-28 09:01:14 +02:00
parent a611113d2a
commit 1651075f40
4 changed files with 27 additions and 25 deletions

View File

@@ -1,6 +1,7 @@
from __future__ import annotations
from .client import *
from .. import poller_control
import shlex
def scgi_diagnostics(profile: dict) -> dict:
@@ -64,7 +65,12 @@ def scgi_diagnostics(profile: dict) -> dict:
def profile_diagnostics(profile: dict) -> dict:
"""Lightweight per-profile diagnostics for save/test UI."""
started = time.perf_counter()
result = {"profile_id": profile.get("id"), "ok": False, "checks": {}}
profile_id = profile.get("id")
try:
slow_threshold_ms = float(poller_control.get_settings(int(profile_id)).get("slow_response_threshold_ms") or poller_control.DEFAULTS["slow_response_threshold_ms"])
except Exception:
slow_threshold_ms = float(poller_control.DEFAULTS["slow_response_threshold_ms"])
result = {"profile_id": profile_id, "ok": False, "checks": {}, "slow_threshold_ms": slow_threshold_ms}
try:
c = client_for(profile)
version = str(c.call("system.client_version") or "")
@@ -96,7 +102,7 @@ def profile_diagnostics(profile: dict) -> dict:
free_disk[base] = {"error": str(exc)}
result.update({
"ok": True,
"status": "online",
"status": "normal",
"version": version,
"library_version": library,
"base_paths": paths,
@@ -106,7 +112,8 @@ def profile_diagnostics(profile: dict) -> dict:
})
except Exception as exc:
result.update({"ok": False, "status": "error", "error": str(exc), "response_time_ms": round((time.perf_counter() - started) * 1000, 2)})
if result.get("ok") and result.get("response_time_ms", 0) > 1500:
# Note: Profile diagnostics uses the same slow-response threshold as Tools -> Poller for this profile.
if result.get("ok") and result.get("response_time_ms", 0) > slow_threshold_ms:
result["status"] = "slow"
return result