Ad Widget

Collapse

SQL database size monitoring

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Dozent
    Junior Member
    • Oct 2021
    • 10

    #1

    SQL database size monitoring

    I use the key to monitor the size of the base
    Code:
    perf_counter["\SQLServer:Databases(DB)\Data File(s) Size (KB)"]
    Throws the error Cannot obtain performance information from collector. tell me what could be wrong. thanks
    command was executed
    Code:
    cd \windows\system32
    lodctr /R
  • niveastn
    Member
    • Oct 2021
    • 82

    #2
    Hi!

    if you do it via query, wouldn't it meet what you need?

    Query
    Code:
    SELECT DB_NAME() AS DbName,
        name AS FileName,
        type_desc,
        size/128.0 AS CurrentSizeMB,  
        size/128.0 - CAST(FILEPROPERTY(name, 'SpaceUsed') AS INT)/128.0 AS FreeSpaceMB
    FROM sys.database_files
    WHERE type IN (0,1);
    This query will get a list of databases file with size and free space for a database in SQL Server. You configure it with a db.odbc.get, and use regex to do create dependent items for each column. You can play around with regex here https://regex101.com/ . It has tips, reference, an explanation of what you are doing and even convert your regex to be used with different languages

    Comment

    Working...