vrkumar01 (10/25/2010)
Hi Team,i am very new to this forum.... we have SCOM R2 which monitors all our SQL servers which is quite ok and satisfied with the default SQL MP's.
today i got a query from my DBA team to create a monitor for long running transactions. This is the script (Procedure) which is installed by the DBA team on all the SQL servers in my environment to the master databases.
Need your help in creating a monitor.
CREATE procedure [dbo].[p_open_tran_check]
(
@min-2 int
)
-----------------------------------------------------------------------
-- Functional Area: DB Administration
-- Purpose:
--
-- Parameters:
--
--
-- Deployment Notes:
-- resolve_db
--
-- History:
-- ?.?.? ?/??/2008 resolve_author Created.
-----------------------------------------------------------------------
-- Copyright 2008 Inc. All Rights Reserved.
-----------------------------------------------------------------------
-- Unit Test
/***
***/
--
as
set nocount on
-- convert @min-2 to milliseconds
select count(*) as qty
from master.dbo.sysprocesses (readpast)
where open_tran > 0
and last_batch < dateadd( minute, @min-2, getDate() )
and cmd <> 'GHOST CLEANUP'
--and datediff(minute, last_batch, getDate() ) >= @min-2
return
Go to Authoring Console then... >Create Monitor >Script Monitor
_____________________________________
Pablo (Paul) Berzukov
Author of Understanding Database Administration available at Amazon and other bookstores.
Disclaimer: Advice is provided to the best of my knowledge but no implicit or explicit warranties are provided. Since the advisor explicitly encourages testing any and all suggestions on a test non-production environment advisor should not held liable or responsible for any actions taken based on the given advice.