Philiprehberger.HealthCheckKit
0.1.1
There is a newer version of this package available.
See the version list below for details.
See the version list below for details.
dotnet add package Philiprehberger.HealthCheckKit --version 0.1.1
NuGet\Install-Package Philiprehberger.HealthCheckKit -Version 0.1.1
This command is intended to be used within the Package Manager Console in Visual Studio, as it uses the NuGet module's version of Install-Package.
<PackageReference Include="Philiprehberger.HealthCheckKit" Version="0.1.1" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="Philiprehberger.HealthCheckKit" Version="0.1.1" />
<PackageReference Include="Philiprehberger.HealthCheckKit" />
For projects that support Central Package Management (CPM), copy this XML node into the solution Directory.Packages.props file to version the package.
paket add Philiprehberger.HealthCheckKit --version 0.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
#r "nuget: Philiprehberger.HealthCheckKit, 0.1.1"
#r directive can be used in F# Interactive and Polyglot Notebooks. Copy this into the interactive tool or source code of the script to reference the package.
#:package Philiprehberger.HealthCheckKit@0.1.1
#:package directive can be used in C# file-based apps starting in .NET 10 preview 4. Copy this into a .cs file before any lines of code to reference the package.
#addin nuget:?package=Philiprehberger.HealthCheckKit&version=0.1.1
#tool nuget:?package=Philiprehberger.HealthCheckKit&version=0.1.1
The NuGet Team does not provide support for this client. Please contact its maintainers for support.
Philiprehberger.HealthCheckKit
Composable health checks for ASP.NET Core with built-in URL, disk space, memory, and custom check support.
Installation
dotnet add package Philiprehberger.HealthCheckKit
Usage
using Philiprehberger.HealthCheckKit;
builder.Services.AddHealthCheckKit(checks => checks
.AddUrlCheck("https://api.example.com/health")
.AddDiskSpaceCheck(minimumFreeBytes: 500_000_000)
.AddMemoryCheck(maximumBytes: 1_073_741_824));
app.MapHealthChecks("/health");
Register Health Checks
using Philiprehberger.HealthCheckKit;
builder.Services.AddHealthCheckKit(checks => checks
.AddUrlCheck("https://api.example.com/health", timeout: TimeSpan.FromSeconds(3))
.AddDiskSpaceCheck(minimumFreeBytes: 1_000_000_000, drivePath: "C:\\")
.AddMemoryCheck(maximumBytes: 512_000_000));
Built-in Checks
using Philiprehberger.HealthCheckKit;
// URL check — Healthy on 2xx, Degraded on timeout, Unhealthy otherwise
builder.Services.AddHealthCheckKit(checks => checks
.AddUrlCheck("https://downstream-service.example.com/ping"));
// Disk space check — Unhealthy when free space drops below threshold
builder.Services.AddHealthCheckKit(checks => checks
.AddDiskSpaceCheck(minimumFreeBytes: 500_000_000));
// Memory check — Unhealthy when managed memory exceeds limit
builder.Services.AddHealthCheckKit(checks => checks
.AddMemoryCheck(maximumBytes: 1_073_741_824));
Custom Checks
using Microsoft.Extensions.Diagnostics.HealthChecks;
using Philiprehberger.HealthCheckKit;
builder.Services.AddHealthCheckKit(checks => checks
.AddCustomCheck("database", async cancellationToken =>
{
// Run your custom health logic
var isHealthy = await CheckDatabaseConnectionAsync(cancellationToken);
return isHealthy
? HealthCheckResult.Healthy("Database is reachable.")
: HealthCheckResult.Unhealthy("Database is unreachable.");
}));
API
HealthCheckKitBuilder
| Method | Description |
|---|---|
AddUrlCheck(string url, TimeSpan? timeout = null) |
Adds an HTTP GET check for the given URL |
AddDiskSpaceCheck(long minimumFreeBytes, string? drivePath = null) |
Adds a disk free space check |
AddMemoryCheck(long maximumBytes) |
Adds a managed memory usage check |
AddCustomCheck(string name, Func<CancellationToken, Task<HealthCheckResult>> check) |
Adds a custom delegate-based check |
ServiceCollectionExtensions
| Method | Description |
|---|---|
AddHealthCheckKit(this IServiceCollection services, Action<HealthCheckKitBuilder> configure) |
Registers all configured health checks with the DI container |
UrlHealthCheck
| Member | Description |
|---|---|
UrlHealthCheck(string url, TimeSpan? timeout = null) |
Creates a URL health check with optional timeout (default 5s) |
CheckHealthAsync(context, cancellationToken) |
Returns Healthy (2xx), Degraded (timeout), or Unhealthy |
DiskSpaceHealthCheck
| Member | Description |
|---|---|
DiskSpaceHealthCheck(long minimumFreeBytes, string drivePath = "/") |
Creates a disk space check for the given drive |
CheckHealthAsync(context, cancellationToken) |
Returns Healthy if free space meets minimum, Unhealthy otherwise |
MemoryHealthCheck
| Member | Description |
|---|---|
MemoryHealthCheck(long maximumBytes) |
Creates a memory check with the given byte limit |
CheckHealthAsync(context, cancellationToken) |
Returns Healthy if within limit, Unhealthy otherwise |
Development
dotnet build src/Philiprehberger.HealthCheckKit.csproj --configuration Release
License
MIT
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net8.0 is compatible. net8.0-android was computed. net8.0-browser was computed. net8.0-ios was computed. net8.0-maccatalyst was computed. net8.0-macos was computed. net8.0-tvos was computed. net8.0-windows was computed. net9.0 was computed. net9.0-android was computed. net9.0-browser was computed. net9.0-ios was computed. net9.0-maccatalyst was computed. net9.0-macos was computed. net9.0-tvos was computed. net9.0-windows was computed. net10.0 was computed. net10.0-android was computed. net10.0-browser was computed. net10.0-ios was computed. net10.0-maccatalyst was computed. net10.0-macos was computed. net10.0-tvos was computed. net10.0-windows was computed. |
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.
-
net8.0
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.