mirror of
https://github.com/okieselbach/AutopilotMonitor.git
synced 2026-11-15 20:55:22 +00:00
Show the NTP clock skew in the right direction
The agent's ntp_time_check reports offsetSeconds = NTP time - device time, so a positive value means the device clock is BEHIND. The session card said "ahead of UTC" for it (a device 10 h behind showed as 10 h ahead), and ANALYZE-DEV-007 named its two signals the wrong way round. - SessionInfoCard: the direction comes from deviceClockDirection (sessionInfoLogic.ts, pinned by a test with both signs). - ANALYZE-DEV-007 1.1.1: offsetSeconds > 120 is clock_behind, < -120 is clock_ahead. Conditions, thresholds and text are unchanged. Co-Authored-By: Claude Opus 5.5 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -5,7 +5,7 @@
|
||||
"description": "The device's real-time clock deviates from NTP by more than two minutes. Microsoft documents that a clock off by several minutes causes TPM attestation errors (self-deploying/pre-provisioning) and ESP timeouts.",
|
||||
"severity": "warning",
|
||||
"category": "device",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.1",
|
||||
"author": "Autopilot Monitor",
|
||||
"enabled": true,
|
||||
"evaluateOn": [
|
||||
@@ -17,7 +17,7 @@
|
||||
"confidenceThreshold": 50,
|
||||
"conditions": [
|
||||
{
|
||||
"signal": "clock_ahead",
|
||||
"signal": "clock_behind",
|
||||
"source": "event_data",
|
||||
"eventType": "ntp_time_check",
|
||||
"dataField": "offsetSeconds",
|
||||
@@ -26,7 +26,7 @@
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"signal": "clock_behind",
|
||||
"signal": "clock_ahead",
|
||||
"source": "event_data",
|
||||
"eventType": "ntp_time_check",
|
||||
"dataField": "offsetSeconds",
|
||||
|
||||
+3
-3
@@ -1654,7 +1654,7 @@
|
||||
"description": "The device's real-time clock deviates from NTP by more than two minutes. Microsoft documents that a clock off by several minutes causes TPM attestation errors (self-deploying/pre-provisioning) and ESP timeouts.",
|
||||
"severity": "warning",
|
||||
"category": "device",
|
||||
"version": "1.1.0",
|
||||
"version": "1.1.1",
|
||||
"author": "Autopilot Monitor",
|
||||
"enabled": true,
|
||||
"evaluateOn": [
|
||||
@@ -1666,7 +1666,7 @@
|
||||
"confidenceThreshold": 50,
|
||||
"conditions": [
|
||||
{
|
||||
"signal": "clock_ahead",
|
||||
"signal": "clock_behind",
|
||||
"source": "event_data",
|
||||
"eventType": "ntp_time_check",
|
||||
"dataField": "offsetSeconds",
|
||||
@@ -1675,7 +1675,7 @@
|
||||
"required": false
|
||||
},
|
||||
{
|
||||
"signal": "clock_behind",
|
||||
"signal": "clock_ahead",
|
||||
"source": "event_data",
|
||||
"eventType": "ntp_time_check",
|
||||
"dataField": "offsetSeconds",
|
||||
|
||||
@@ -4,6 +4,7 @@ import { useState } from "react";
|
||||
import { Session } from "@/types";
|
||||
import { SessionStatusBadge } from "@/components/SessionStatusBadge";
|
||||
import FailureSnapshotBlock from "./FailureSnapshotBlock";
|
||||
import { deviceClockDirection } from "./sessionInfoLogic";
|
||||
import { formatDuration } from "@/lib/formatting";
|
||||
|
||||
interface SessionInfoCardProps {
|
||||
@@ -125,7 +126,7 @@ export default function SessionInfoCard({ session, enrollmentDuration, displaySt
|
||||
</svg>
|
||||
<span>
|
||||
<strong>Clock Skew:</strong> Device clock is {Math.abs(ntpOffset.offsetSeconds).toFixed(1)}s
|
||||
{ntpOffset.offsetSeconds > 0 ? " ahead of" : " behind"} UTC
|
||||
{" "}{deviceClockDirection(ntpOffset.offsetSeconds)} UTC
|
||||
{ntpOffset.ntpServer && <> (NTP: {ntpOffset.ntpServer})</>}
|
||||
</span>
|
||||
</div>
|
||||
|
||||
+14
@@ -0,0 +1,14 @@
|
||||
import { describe, expect, it } from "vitest";
|
||||
import { deviceClockDirection } from "../sessionInfoLogic";
|
||||
|
||||
describe("deviceClockDirection", () => {
|
||||
it("reads a positive NTP offset as a device clock behind UTC", () => {
|
||||
// NTP 12:37:07, device 02:36:56 -> offsetSeconds = NTP - device = +36010.3
|
||||
expect(deviceClockDirection(36010.3)).toBe("behind");
|
||||
});
|
||||
|
||||
it("reads a negative NTP offset as a device clock ahead of UTC", () => {
|
||||
// NTP 10:21:22, device 19:21:22 -> offsetSeconds = -32400.3
|
||||
expect(deviceClockDirection(-32400.3)).toBe("ahead of");
|
||||
});
|
||||
});
|
||||
@@ -0,0 +1,8 @@
|
||||
/**
|
||||
* Direction of the device clock relative to NTP, read from the agent's `ntp_time_check`
|
||||
* event. The agent computes `offsetSeconds = NTP time − device time`
|
||||
* (`NtpTimeCheckService`), so a positive value means the device clock is BEHIND.
|
||||
*/
|
||||
export function deviceClockDirection(offsetSeconds: number): "ahead of" | "behind" {
|
||||
return offsetSeconds > 0 ? "behind" : "ahead of";
|
||||
}
|
||||
Reference in New Issue
Block a user