s4ndr0ne.Db2.HealthChecks
1.0.0
dotnet add package s4ndr0ne.Db2.HealthChecks --version 1.0.0
NuGet\Install-Package s4ndr0ne.Db2.HealthChecks -Version 1.0.0
<PackageReference Include="s4ndr0ne.Db2.HealthChecks" Version="1.0.0" />
<PackageVersion Include="s4ndr0ne.Db2.HealthChecks" Version="1.0.0" />
<PackageReference Include="s4ndr0ne.Db2.HealthChecks" />
paket add s4ndr0ne.Db2.HealthChecks --version 1.0.0
#r "nuget: s4ndr0ne.Db2.HealthChecks, 1.0.0"
#:package s4ndr0ne.Db2.HealthChecks@1.0.0
#addin nuget:?package=s4ndr0ne.Db2.HealthChecks&version=1.0.0
#tool nuget:?package=s4ndr0ne.Db2.HealthChecks&version=1.0.0
Db2.HealthChecks
Db2.HealthChecks integrates IBM Db2 probes with Microsoft.Extensions.Diagnostics.HealthChecks.
The package is designed to be portable and enterprise-friendly: it does not hard-code an OS-specific IBM driver dependency. Instead, it creates connections through an explicit connection factory, an ADO.NET DbProviderFactory, or the IBM Db2 provider loaded by the consuming application.
Features
- ASP.NET Core / Worker Service health check integration.
- Default lightweight Db2 query:
SELECT 1 FROM SYSIBM.SYSDUMMY1. - Custom probe query support.
- Configurable timeout and command timeout.
- Configurable failure status and tags.
- Connection-string,
DbProviderFactory, or DI-friendlyDbConnectionfactory setup. - Logging through
Microsoft.Extensions.Loggingwhen logging is registered. - Multi-target package:
netstandard2.0,net8.0, andnet10.0. - SourceLink and deterministic build metadata for NuGet consumers.
Supported platforms
The library itself is OS-independent. The actual runtime support depends on the IBM Db2 ADO.NET provider used by your application.
Typical provider packages:
| OS | Provider package |
|---|---|
| Windows | Net.IBM.Data.Db2 |
| Linux | Net.IBM.Data.Db2-lnx |
Note: the IBM provider must be installed by the consuming application. This avoids producing NuGet packages whose dependencies change depending on the OS used to pack the library.
Linux native dependencies
When using Net.IBM.Data.Db2-lnx, the IBM native client also needs Linux shared libraries available at runtime. On Debian/Ubuntu-based images this typically means:
apt-get update && apt-get install -y libxml2 libaio1t64
The IBM package copies clidriver next to your build output. If libdb2.so is not found, ensure the clidriver/lib directory is visible to the process, for example via LD_LIBRARY_PATH in containerized workloads.
Basic usage
Install this package and the appropriate IBM provider package for your deployment OS.
builder.Services.AddHealthChecks()
.AddDb2Check(
name: "db2",
connectionString: builder.Configuration.GetConnectionString("Db2")!,
tags: new[] { "db", "db2", "ready" },
timeout: TimeSpan.FromSeconds(5),
commandTimeoutSeconds: 3);
Advanced usage
Use the options overload for enterprise scenarios such as dynamic secrets, Key Vault integration, custom connection creation, or non-default failure status.
builder.Services.AddHealthChecks()
.AddDb2Check("db2", options =>
{
options.ConnectionString = builder.Configuration.GetConnectionString("Db2")!;
options.Query = "SELECT 1 FROM SYSIBM.SYSDUMMY1";
options.Timeout = TimeSpan.FromSeconds(5);
options.CommandTimeoutSeconds = 3;
options.FailureStatus = HealthStatus.Degraded;
options.Tags = new[] { "db", "db2", "critical" };
});
Custom connection factory
builder.Services.AddHealthChecks()
.AddDb2Check("db2", options =>
{
options.ConnectionFactory = serviceProvider =>
{
var connectionString = serviceProvider
.GetRequiredService<IConfiguration>()
.GetConnectionString("Db2")!;
// Requires the IBM provider package in the consuming application.
return new IBM.Data.Db2.DB2Connection(connectionString);
};
});
Provider factory
builder.Services.AddHealthChecks()
.AddDb2Check("db2", options =>
{
options.ProviderFactory = IBM.Data.Db2.DB2Factory.Instance;
options.ConnectionString = builder.Configuration.GetConnectionString("Db2")!;
});
Kubernetes / production endpoints
Recommended pattern:
/health/live: process liveness only, no database dependency./health/ready: includes Db2 readiness check, internal/private endpoint.
Example:
app.MapHealthChecks("/health/ready", new HealthCheckOptions
{
Predicate = registration => registration.Tags.Contains("ready")
});
Avoid exposing detailed health check output publicly. If needed, set:
options.IncludeExceptionDetails = false;
Compatibility notes
netstandard2.0target: supports factory/reflection-based connection creation.DbProviderFactories.GetFactoryis only used on targets where it is available.net8.0andnet10.0targets: supportDbProviderFactories.GetFactorywithProviderInvariantNameas well as explicit factories.- A
DbConnectionreturned byConnectionFactoryis disposed after every check by default. SetDisposeConnection = falseonly when returning an externally owned connection. IncludeExceptionDetailsdefaults tofalse; enable it only on protected diagnostics endpoints.
The library deliberately does not bundle an IBM Db2 driver. Install the provider selected by the
consuming application, such as Net.IBM.Data.Db2 on Windows or Net.IBM.Data.Db2-lnx on Linux.
The provider can be registered with DbProviderFactories, supplied through ProviderFactory, or
used by a custom ConnectionFactory. This keeps IBM driver versions, native dependencies, and
licensing under application control.
Development
dotnet restore
dotnet build
dotnet test
dotnet pack src/Db2.HealthChecks/Db2.HealthChecks.csproj -c Release
Security
Do not log or expose Db2 connection strings. See SECURITY.md for vulnerability reporting.
| Product | Versions Compatible and additional computed target framework versions. |
|---|---|
| .NET | net5.0 was computed. net5.0-windows was computed. net6.0 was computed. net6.0-android was computed. net6.0-ios was computed. net6.0-maccatalyst was computed. net6.0-macos was computed. net6.0-tvos was computed. net6.0-windows was computed. net7.0 was computed. net7.0-android was computed. net7.0-ios was computed. net7.0-maccatalyst was computed. net7.0-macos was computed. net7.0-tvos was computed. net7.0-windows was computed. 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 is compatible. 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. |
| .NET Core | netcoreapp2.0 was computed. netcoreapp2.1 was computed. netcoreapp2.2 was computed. netcoreapp3.0 was computed. netcoreapp3.1 was computed. |
| .NET Standard | netstandard2.0 is compatible. netstandard2.1 was computed. |
| .NET Framework | net461 was computed. net462 was computed. net463 was computed. net47 was computed. net471 was computed. net472 was computed. net48 was computed. net481 was computed. |
| MonoAndroid | monoandroid was computed. |
| MonoMac | monomac was computed. |
| MonoTouch | monotouch was computed. |
| Tizen | tizen40 was computed. tizen60 was computed. |
| Xamarin.iOS | xamarinios was computed. |
| Xamarin.Mac | xamarinmac was computed. |
| Xamarin.TVOS | xamarintvos was computed. |
| Xamarin.WatchOS | xamarinwatchos was computed. |
-
.NETStandard 2.0
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.4)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.4)
-
net10.0
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.4)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.4)
-
net8.0
- Microsoft.Extensions.Diagnostics.HealthChecks (>= 10.0.4)
- Microsoft.Extensions.Logging.Abstractions (>= 10.0.4)
NuGet packages
This package is not used by any NuGet packages.
GitHub repositories
This package is not used by any popular GitHub repositories.
Cross-platform packaging, netstandard2.0/net8.0/net10.0 support, configurable options, timeout support, provider/factory-based connection creation, logging, and improved diagnostics.