Skip to content

Oracle Health Indicator

Permite verificar el estado de un base de datos Oracle.

Registrar en el contenedor de IoC

Para registrar el HealthIndicator solo deberemos pasar como parámetro la cadena de conexión.

    public void Configure(IWebHostBuilder builder)
    {
      builder.ConfigureServices((ctx, c) =>
      {
      c.AddSingleton<IHealthIndicator, OracleHealthIndicator>(s =>
        new OracleHealthIndicator("User ID = ALERTEST; Password = *******; Data Source = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = 10.20.6.213)(PORT = 1521))(CONNECT_DATA = (SERVICE_NAME = ALERTEST))); Persist Security Info = False")
        );
      });
    }

Una vez que llamemos al /health endpoint, podremos visualizar lo siguiente:

{
    "status": {
        "code": "UP",
        "description": ""
    },
    "details": {
        "oracleHealthIndicator": {
            "status": {
                "code": "UP",
                "description": ""
            },
            "details": {
                "host": "dbobarsrv",
                "version": "11.2.0.3.0",
                "serviceName": "alertest",
                "database": "alertest"
            }
        }
    }
}