fromHealthz static method

ServerStats? fromHealthz(
  1. String? body
)

null for anything but an ObservANT camera's /healthz that carries stats.

Implementation

static ServerStats? fromHealthz(String? body) {
  final health = ObservantHealth.parse(body);
  if (health == null || !health.hasStats) {
    return null;
  }
  final uptime = health.wholeStat('uptime_s');
  return ServerStats(
    captureFps: health.stat('capture_fps'),
    configuredFps: health.frameFps,
    modelMs: health.stat('model_ms'),
    modelRunsPerSecond: health.stat('model_runs_per_s'),
    cpuPercent: health.stat('cpu_percent'),
    cores: health.wholeStat('cores'),
    rssMb: health.stat('rss_mb'),
    load1m: health.stat('load_1m'),
    temperatureC: health.stat('temperature_c'),
    uptime: uptime == null ? null : Duration(seconds: uptime),
    viewers: health.viewers,
  );
}