Database Management

DPA - Version 2024.2 Upgrade Database freespace Alert

The purpose of this article is to address the known upgrade issue to 2024.2 for the Database freespace alert status will be seen as broken after upgrading to DPA 2024.2.

First published date

5/16/2024 7:39 PM

Last published date

2/4/2026 12:15 AM

Overview

The Database freespace alert status will be seen as broken after upgrading to DPA 2024.2. This alert is supported for SQL Server, Azure SQL DB, ASMI, Sybase, Db2 database.

Currently, it is working only for Db2 and Sybase Database.

rtaImage.jpg

Execution of this alert failed due to the following error:
java.lang.illegalStateException: No DataSource set

image.png

Product section

Database Performance Analyzer

Cause

Below is a sample of an error like “java.lang.illegalStateException: No DataSource set“ in iwc.log file:
 

WARN  [AlertScheduler_Worker-2] {name=DATABASE_NAME} AbstractAlertTask:337
 - Error executing alert [Database Freespace] for database [DATABASE_NAME]
java.lang.IllegalStateException: No DataSource set
	at org.springframework.util.Assert.state(Assert.java:76) ~[spring-core-5.3.29.jar:5.3.29]
	at org.springframework.jdbc.support.JdbcAccessor.obtainDataSource(JdbcAccessor.java:86) ~[spring-jdbc-sw-5.3.29.jar:?]
	at org.springframework.jdbc.core.JdbcTemplate.execute(JdbcTemplate.java:378) ~[spring-jdbc-sw-5.3.29.jar:?]
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:470) ~[spring-jdbc-sw-5.3.29.jar:?]
	at org.springframework.jdbc.core.JdbcTemplate.query(JdbcTemplate.java:475) ~[spring-jdbc-sw-5.3.29.jar:?]
	at com.confio.iwc.alerts.definitions.DatabaseFreeSpaceAlert$FreeSpaceDao.getFreeSpaceFromSqlServer(SourceFile:150) ~[pi.jar:?]
	at com.confio.iwc.alerts.definitions.DatabaseFreeSpaceAlert$FreeSpaceDao.getDatabaseFreeSpace(SourceFile:118) ~[pi.jar:?]
	at com.confio.iwc.alerts.definitions.DatabaseFreeSpaceAlert.runAlert(SourceFile:78) ~[pi.jar:?]
	at com.confio.iwc.alerts.tasks.AbstractAlertTask.execute(SourceFile:314) [pi.jar:?]
	at com.confio.iwc.alerts.tasks.AlertTaskJob.execute(SourceFile:87) [pi.jar:?]
	at org.quartz.core.JobRunShell.run(JobRunShell.java:202) [quartz-2.3.2.jar:?]
	at org.quartz.simpl.SimpleThreadPool$WorkerThread.run(SimpleThreadPool.java:573) [quartz-2.3.2.jar:?]

Resolution

This issue is resolved in DPA 2024.3 and above.  If upgrade is not possible, please perform the workaround below:

The DPA User can create a custom alert with type 'Custom SQL Alert - Multiple Numeric Return' and add below query as Alert parameter for SQL Server.
 

-- Scripts are not supported under any SolarWinds support program or service.
-- Scripts are provided AS IS without warranty of any kind. SolarWinds further
-- disclaims all warranties including, without limitation, any implied warranties
-- of merchantability or of fitness for a particular purpose. The risk arising
-- out of the use or performance of the scripts and documentation stays with you.
-- In no event shall SolarWinds or anyone else involved in the creation,
-- production, or delivery of the scripts be liable for any damages whatsoever
-- (including, without limitation, damages for loss of business profits, business
-- interruption, loss of business information, or other pecuniary loss) arising
-- out of the use of or inability to use the scripts or documentation.

DECLARE @DatabaseName NVARCHAR(128)
DECLARE @tempTable TABLE (name NVARCHAR(128), Result DECIMAL(5,2));
DECLARE @SQLQuery NVARCHAR(MAX)
DECLARE db_cursor CURSOR FOR
SELECT name FROM sys.databases ORDER BY name;
OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @DatabaseName
WHILE @@FETCH_STATUS = 0
BEGIN
  SET @SQLQuery = 'USE ' + @DatabaseName +';'+' SELECT
      name as tName,
        CASE
            WHEN max_size = -1 AND growth > 0 THEN 100
            WHEN growth > 0 AND max_size > size THEN (100.0 * ((size - FILEPROPERTY(name, ''SpaceUsed'')) + (max_size - size))) / (size + (max_size - size))
            ELSE (100.0 * (size - FILEPROPERTY(name, ''SpaceUsed''))) / size
        END AS Result
      FROM sys.database_files WHERE type = 0'
  insert into @tempTable EXEC sp_executesql @SQLQuery;
  FETCH NEXT FROM db_cursor INTO @DatabaseName 
END
select * from @tempTable;
CLOSE db_cursor
DEALLOCATE db_cursor


For Azure SQL Database, use the following query:

-- Scripts are not supported under any SolarWinds support program or service.
-- Scripts are provided AS IS without warranty of any kind. SolarWinds further
-- disclaims all warranties including, without limitation, any implied warranties
-- of merchantability or of fitness for a particular purpose. The risk arising
-- out of the use or performance of the scripts and documentation stays with you.
-- In no event shall SolarWinds or anyone else involved in the creation,
-- production, or delivery of the scripts be liable for any damages whatsoever
-- (including, without limitation, damages for loss of business profits, business
-- interruption, loss of business information, or other pecuniary loss) arising
-- out of the use of or inability to use the scripts or documentation.

DECLARE @DatabaseName NVARCHAR(128)
DECLARE @tempTable TABLE (name NVARCHAR(128), Result DECIMAL(5,2));
DECLARE @SQLQuery NVARCHAR(MAX)

DECLARE db_cursor CURSOR FOR
SELECT name FROM sys.databases ORDER BY name;

OPEN db_cursor
FETCH NEXT FROM db_cursor INTO @DatabaseName

WHILE @@FETCH_STATUS = 0
BEGIN
  SET @SQLQuery = 'SELECT
      name as tName,
        CASE
            WHEN max_size = -1 AND growth > 0 THEN 100
            WHEN growth > 0 AND max_size > size THEN (100.0 * ((size - FILEPROPERTY(name, ''SpaceUsed'')) + (max_size - size))) / (size + (max_size - size))
            ELSE (100.0 * (size - FILEPROPERTY(name, ''SpaceUsed''))) / size
        END AS Result
      FROM sys.database_files WHERE type = 0'
  insert into @tempTable EXEC sp_executesql @SQLQuery;
  FETCH NEXT FROM db_cursor INTO @DatabaseName
END
select * from @tempTable;
CLOSE db_cursor
DEALLOCATE db_cursor