INF: How to Monitor Free Space in a User Database with PerfMonLast reviewed: April 10, 1997Article ID: Q163036 |
The information in this article applies to:
SUMMARYMany database administrators (DBAs) need to know how to schedule alerts indicating that a database is full. SQL Server is tightly integrated with the Windows NT Server Performance Monitor, providing numerous pre-defined counters. One of these counters monitors a database's log percent filled, but none of the counters monitors the database itself. However, you can add this functionality by using the user-defined SQL Server counters.
MORE INFORMATIONTo set up user-defined performance counters, do the following:
drop procedure dbo.sp_user_counterXgo
/* This procedure returns an integer value representing how full a userdatabase is, as a percentage full. This procedure does not monitor the master, and does not track logs. */ CREATE PROCEDURE sp_user_counterX AS DECLARE @dbsize dec(15,0) DECLARE @allocatedpages dec(15,0) SELECT @dbsize = sum(convert(dec(15),size)) FROM sysusages WHERE dbid = (SELECT dbid FROM sysdatabases WHERE name = 'DBNAME') AND (segmap & 4) != 4 SELECT @allocatedpages = (SELECT sum(convert(dec(15), reserved)) FROM DBNAME..sysindexes --Note: No quotes WHERE indid in (0,1,255) AND (ID <> 8))SELECT convert(tinyint,(@allocatedpages / @dbsize) * 100) GO GRANT EXECUTE ON dbo.sp_user_counterX TO probe GO *********Script End************ Use the existing Performance Monitor counters to monitor the log. This procedure does not work for databases that include both data and log segments on the same fragment. For more information, see the following article in the Microsoft Knowledge Base:
ARTICLE-ID: Q110904 TITLE : How to Set Up SQL Performance Monitor Database Alerts |
Additional query words: sql60 sql65
© 1998 Microsoft Corporation. All rights reserved. Terms of Use. |