Skip to content

A modern and easy to use dashboard. 80+ integrations. 20K+ icons built in. Authentication out of the box. No YAML, drag and drop configuration.

fix(glances): unable to parse uptime of 1 day (#5226)

Meier Lukas3091ed6358d8
diff --git a/packages/integrations/src/glances/glances-integration.ts b/packages/integrations/src/glances/glances-integration.ts
index e4e859151..2d1f8601f 100644
--- a/packages/integrations/src/glances/glances-integration.ts
+++ b/packages/integrations/src/glances/glances-integration.ts
@@ -95,7 +95,18 @@ export class GlancesIntegration extends Integration implements ISystemHealthMoni
}
}
-const regex = /^(?:(?<days>\d+) days, )?(?<hours>\d+):(?<minutes>\d+):(?<seconds>\d+)$/m;
+// Glances is written in python and uses the following code to format uptime:
+// from datetime import datetime
+// uptime = datetime.now() - datetime.fromtimestamp(1773395580)
+// str(uptime).split(".")[0]
+// This results in one of the following formats:
+// - 71 days, 9:51:35
+// - 1 day, 9:50:23
+// - 9:51:24
+// - 0:22:02
+// - 0:00:17
+// See https://github.com/nicolargo/glances/blob/4139b10c5c3a98afc67a19ae67d66d2d94d7db6a/glances/plugins/uptime/__init__.py#L58
+const regex = /^(?:(?<days>\d+) days?, )?(?<hours>\d+):(?<minutes>\d+):(?<seconds>\d+)$/m;
const allSchema = z.object({
cpu: z.object({