Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 SQL Server Administration (2000)
 Performance Monitoring

Author  Topic 

TonyTheDBA
Posting Yak Master

121 Posts

Posted - 2006-12-15 : 07:22:01
Ok so I can monitor how SQL Server is performing, and I do it through a couple of options (Run Perfmon, log to SQL Server, analyse log results via analysis server OR Spotlight on SQL Server - No Log Or trend analysis though)

We are about to consolidate our existing SQL Servers onto new hardware. This will involve a new costing model for our user departments, and what I've been asked is Can we monitor how much SQL resource a particular database/applciation is using at a given point in time?

Now I use this stored procedure to log basic stats on a 5 minute periodic basis, but anyone got any ideas how to do this on a DB/user/process id
CREATE PROCEDURE dbo.sp_HowBusy ( @Over INT = 60 ) AS
BEGIN

/****************************************************************************
Procedure Name : sp_HowBusy
Procedure Desc :
:
Parameters :
:
Returns : 0 If Execution Completed Without Errors
: 1 If Execution Failed Due To Errors
Date Created : DD-MMM-2005
Author : <Your Name Here> - BBC
Last Amended : DD-MMM-CCYY : :
****************************************************************************/

DECLARE @ProcName varchar(32)
DECLARE @UserId varchar(32)
DECLARE @s VARCHAR(8)
DECLARE @busy INT, @idle INT, @io INT, @start DATETIME
Declare @ServerID Integer

SET NOCOUNT ON

-- Get the current ServerID from the SQLAudit Database

Select @ServerID = ServerID from SQLAudit.dbo.Servers Where Name = @@Servername

-- Remove Rows Greater than 24 Hours Old

DELETE FROM SQLAudit.dbo.tempServersPerformance
WHERE StartMeasure < DATEADD(hh , -24 , GETDATE() )

SELECT @ProcName = 'sp_HowBusy'
IF @UserId = Null SELECT @UserId = SUSER_SNAME ( SUSER_SID ( ) )

CREATE TABLE #tempwaits ( type varchar ( 40 )
, requests int
, waittime numeric ( 19 , 3 )
, signalwaittime numeric ( 19 , 3 ) )

SELECT @busy = @@CPU_BUSY
, @idle = @@IDLE
, @io = @@IO_BUSY
, @start = GETDATE()
, @s = CONVERT(VARCHAR(8), DATEADD(SECOND,@Over,0), 8)

DBCC SQLPERF (waitstats, clear)

WAITFOR DELAY @s

INSERT INTO #tempwaits EXEC ('dbcc sqlperf (waitstats)')

Insert Into SQLAudit.dbo.tempServersPerformance
SELECT @ServerID
, @start -- AS StartMeasure
, GETDATE() -- AS EndMeasure
, 100.0 * (@@CPU_BUSY-@busy) / ((@@CPU_BUSY+@@IDLE)-(@busy+@idle)) -- AS CpuBusyInPercent
, 100.0 * (@@IO_BUSY-@io) / ((@@CPU_BUSY+@@IDLE)-(@busy+@idle)) -- AS IoBusyInPercent
, 100.0 * (SUM(waittime - signalwaittime)/SUM(waittime)) -- AS "% Resource Waits"
, 100.0 * (SUM(signalwaittime)/SUM(waittime)) -- AS "%cpu waits"
, SUM(signalwaittime) -- AS "Signal Wait Time"
, SUM(waittime - signalwaittime) -- AS "Resource Wait Time"
FROM #tempwaits

IF @@ERROR = 0 RETURN 0 ELSE RETURN 1

END /******* END OF PROCEDURE sp_HowBusy ***************/


--
Regards
Tony The DBA

vaddi
Posting Yak Master

145 Posts

Posted - 2006-12-15 : 11:19:57
Can I execute this procedure on a single server to get the statistics . And probable changes should I make.

Thanks
Go to Top of Page

JoeNak
Constraint Violating Yak Guru

292 Posts

Posted - 2006-12-15 : 11:55:44
This might give you some ideas...
http://vyaskn.tripod.com/sp_who3.htm
Go to Top of Page
   

- Advertisement -