updates
This commit is contained in:
@@ -15,6 +15,16 @@ struct HealthReport: Codable {
|
||||
let schema: Int
|
||||
let host: String?
|
||||
let generatedAt: String?
|
||||
let uptimeSeconds: Int?
|
||||
var uptimeLabel: String? {
|
||||
guard let uptimeSeconds, uptimeSeconds >= 0 else { return nil }
|
||||
let days = uptimeSeconds / 86400
|
||||
let hours = (uptimeSeconds % 86400) / 3600
|
||||
let minutes = (uptimeSeconds % 3600) / 60
|
||||
if days > 0 { return "\(days)d \(hours)h \(minutes)m" }
|
||||
if hours > 0 { return "\(hours)h \(minutes)m" }
|
||||
return "\(minutes)m"
|
||||
}
|
||||
let overall: HealthStatus
|
||||
let counts: HealthCounts
|
||||
let groups: [HealthGroup]
|
||||
@@ -190,7 +200,7 @@ final class ServerMonitor: ObservableObject {
|
||||
let checks = report.checks + extra
|
||||
let counts = HealthCounts(ok: report.counts.ok, warn: report.counts.warn, fail: report.counts.fail + extra.count)
|
||||
let groups = report.groups + [HealthGroup(name: "Required services", status: .fail, missing: extra.map(\.name))]
|
||||
return HealthReport(schema: report.schema, host: report.host, generatedAt: report.generatedAt, overall: .fail,
|
||||
return HealthReport(schema: report.schema, host: report.host, generatedAt: report.generatedAt, uptimeSeconds: report.uptimeSeconds, overall: .fail,
|
||||
counts: counts, groups: groups, checks: checks, diagnostics: report.diagnostics, services: report.services)
|
||||
}
|
||||
var status: HealthStatus {
|
||||
|
||||
Reference in New Issue
Block a user