Hi All,

I am looking to monitor the Database data file space on all my databases using PRTG with the below query

SELECT 
    [FILE_Name] = A.name
    ,[FILEGROUP_NAME] = fg.name
    ,[FILESIZE] = CONVERT(DECIMAL(10,2),A.SIZE/128.0) * 1024 * 1024
    ,[USEDSPACE] = CONVERT(DECIMAL(10,2),A.SIZE/128.0 - ((SIZE/128.0) - CAST(FILEPROPERTY(A.NAME, 'SPACEUSED') AS INT)/128.0)) * 1024 * 1024
    ,[FREESPACE] = CONVERT(DECIMAL(10,2),A.SIZE/128.0 - CAST(FILEPROPERTY(A.NAME, 'SPACEUSED') AS INT)/128.0) * 1024 * 1024
    ,[FREESPACE_%] = CONVERT(DECIMAL(10,2),((A.SIZE/128.0 - CAST(FILEPROPERTY(A.NAME, 'SPACEUSED') AS INT)/128.0)/(A.SIZE/128.0))*100)
FROM sys.database_files A LEFT JOIN sys.filegroups fg ON A.data_space_id = fg.data_space_id 
WHERE A.type_desc LIKE 'ROWS'
order by A.TYPE desc, A.NAME; 

I have setup the channel to read data from columns 3,4,5 and 6

The problem I have is that I have 20 + database on the server alone and over 70 SQL servers so is there a way to have this dynamically create a sensor for each database on each server


Article Comments

Hi there,

The script should help you to accomplish that:


Jul, 2018 - Permalink