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
                    
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="s4ndr0ne.Db2.HealthChecks" Version="1.0.0" />
                    
For projects that support PackageReference, copy this XML node into the project file to reference the package.
<PackageVersion Include="s4ndr0ne.Db2.HealthChecks" Version="1.0.0" />
                    
Directory.Packages.props
<PackageReference Include="s4ndr0ne.Db2.HealthChecks" />
                    
Project file
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 s4ndr0ne.Db2.HealthChecks --version 1.0.0
                    
#r "nuget: s4ndr0ne.Db2.HealthChecks, 1.0.0"
                    
#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 s4ndr0ne.Db2.HealthChecks@1.0.0
                    
#: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=s4ndr0ne.Db2.HealthChecks&version=1.0.0
                    
Install as a Cake Addin
#tool nuget:?package=s4ndr0ne.Db2.HealthChecks&version=1.0.0
                    
Install as a Cake Tool

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-friendly DbConnection factory setup.
  • Logging through Microsoft.Extensions.Logging when logging is registered.
  • Multi-target package: netstandard2.0, net8.0, and net10.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.0 target: supports factory/reflection-based connection creation. DbProviderFactories.GetFactory is only used on targets where it is available.
  • net8.0 and net10.0 targets: support DbProviderFactories.GetFactory with ProviderInvariantName as well as explicit factories.
  • A DbConnection returned by ConnectionFactory is disposed after every check by default. Set DisposeConnection = false only when returning an externally owned connection.
  • IncludeExceptionDetails defaults to false; 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 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. 
Compatible target framework(s)
Included target framework(s) (in package)
Learn more about Target Frameworks and .NET Standard.

NuGet packages

This package is not used by any NuGet packages.

GitHub repositories

This package is not used by any popular GitHub repositories.

Version Downloads Last Updated
1.0.0 105 8/11/2026
0.1.0 129 6/21/2026
0.0.2 172 3/15/2026
0.0.1 146 12/31/2025

Cross-platform packaging, netstandard2.0/net8.0/net10.0 support, configurable options, timeout support, provider/factory-based connection creation, logging, and improved diagnostics.