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
dotnet add package DotNetDiag.HealthChecks.NTPServer
Example Usage
With all of the following examples, you can additionally add the following parameters:
name: The health check name. Default if not specified isntpserver.failureStatus: TheHealthStatusthat should be reported when the health check fails. Default isHealthStatus.Unhealthy.tags: A list of tags that can be used to filter sets of health checks.timeout: ASystem.TimeSpanrepresenting the timeout of the check.
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) |