Share via

Require SQL query for non system drive disk free space

kumaravelu 111 Reputation points
2020-12-28T14:01:23.33+00:00

Hello All,

Need to find out the server starts from ABCDXXXX which server has the most free disk space on a non C: drive (e.g. D:,E:,F:,G: etc.)

kindly assist me on this

Thanks & Regards,
Kumar B

System Center Operations Manager
System Center Operations Manager

A family of System Center products that provide infrastructure monitoring, help ensure the predictable performance and availability of vital applications, and offer comprehensive monitoring for datacenters and cloud, both private and public.

0 comments No comments

1 answer

Sort by: Most helpful
  1. AlexZhu-MSFT 6,601 Reputation points Moderator
    2020-12-30T07:05:07.76+00:00

    Hi,

    To achieve our goal, we may try the following query.

    SELECT bme.Path as ServerName, ps.PerfmonInstanceName as DriveLetter, ROUND(pdav.SampleValue,0) as FreeSpace, pdav.TimeSampled as DateTime, r.RuleName 
    FROM PerformanceDataAllView (NOLOCK) AS pdav  
    INNER JOIN PerformanceSource (NOLOCK) ps ON pdav.PerformanceSourceInternalId = ps.PerformanceSourceInternalId 
    INNER JOIN Rules (NOLOCK) r ON ps.RuleId = r.RuleId 
    INNER JOIN BaseManagedEntity (NOLOCK) bme ON ps.BaseManagedEntityID = bme.BaseManagedEntityID 
    WHERE r.RuleName like 'Microsoft.Windows.Server.%%.LogicalDisk.FreeSpace.Collection' and ps.PerfmonInstanceName <> 'C:'
    AND pdav.TimeSampled = (SELECT MAX(TimeSampled) FROM PerformanceDataAllView WHERE PerformanceSourceInternalId = pdav.PerformanceSourceInternalId )
    --AND SampleValue < 20 /* To list drive having less than 20 percentage */
    --and bme.Path ='Server Name' /* add FQDN for specific server */
    ORDER BY path,PerfmonInstanceName
    

    Hope the above information helps.

    Alex Zhu


    If the response is helpful, please click "Accept Answer" and upvote it.

    Was this answer helpful?

    0 comments No comments

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.