Package reference page maintained from the source documentation in src/HealthChecks.NTPServer.

NTP Server Health Check

This health check verifies that the local system clock is synchronized with an NTP server. It queries the server via UDP and compares the returned time to the local clock. The result is Healthy, Degraded, or Unhealthy based on a configurable tolerance.

NuGet

Nuget

dotnet add package DotNetDiag.HealthChecks.NTPServer

Example Usage

With all of the following examples, you can additionally add the following parameters:

Use default settings (pool.ntp.org, 10-second tolerance)

void Configure(IHealthChecksBuilder builder)
{
    builder.Services
        .AddHealthChecks()
        .AddNTPServer();
}

Specify a custom NTP server and tolerance

void Configure(IHealthChecksBuilder builder)
{
    builder.Services
        .AddHealthChecks()
        .AddNTPServer(options =>
        {
            options.NtpServer = "time.windows.com";
            options.ToleranceSeconds = 5.0;
        });
}

Specify a custom NTP server port

void Configure(IHealthChecksBuilder builder)
{
    builder.Services
        .AddHealthChecks()
        .AddNTPServer(options =>
        {
            options.NtpServer = "time.internal.example";
            options.NtpPort = 10123;
        });
}

Health status thresholds

Condition Returned status
\|offset\|ToleranceSeconds Healthy
ToleranceSeconds < \|offset\|ToleranceSeconds × 2 Degraded
\|offset\| > ToleranceSeconds × 2 FailureStatus (default Unhealthy)