Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase

Continually running SQL Trace Expand / Collapse
Author
Message
Posted Sunday, December 09, 2012 1:18 PM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Yesterday @ 3:16 AM
Points: 10, Visits: 140
Hi,
I am planning to run a server side trace on server. I am bit worried about the trace file growing and consuming all the C drive. I like to set a maximum size for this trace file and like old events to drop off in a FIFO manner. Can this be done? Please advise how to achieve this ?
Post #1394413
Posted Sunday, December 09, 2012 3:22 PM


SSC Veteran

SSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC VeteranSSC Veteran

Group: General Forum Members
Last Login: Saturday, March 30, 2013 9:39 AM
Points: 261, Visits: 966
Do you have any reason why you want to run these traces all the time? What do you want to achieve ? What's your task?


*************************************************************

The first is always the hardest
Post #1394417
Posted Monday, December 10, 2012 2:54 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Yesterday @ 3:16 AM
Points: 10, Visits: 140
Basically, for performance troubleshooting reasons we need to capture certain TSQL command from the Dynamics NAV2013 application, which sends the end user information as comments to the SQL server.

So I am planning to run a server side trace to capture this, applying the necessary filter. I am also planning to read this trace into a SQL table regularly. I considered using extended events but the events I am after is only fully supported in SQL2013. So this server side trace solution is only for SQL2008.
Post #1394506
Posted Monday, December 10, 2012 3:03 AM


SSCrazy

SSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazySSCrazy

Group: General Forum Members
Last Login: Tuesday, March 26, 2013 8:41 AM
Points: 2,562, Visits: 3,451
rama.mathanmohan (12/10/2012)
Basically, for performance troubleshooting reasons we need to capture certain TSQL command from the Dynamics NAV2013 application, which sends the end user information as comments to the SQL server.
always try to put some filters to minimize the logging plus space usage. in your care you can set a textdata filter for that TSQL command , it will give you all required information related with that


-------Bhuvnesh----------
While 1 = 1 (Learning SQL....)
Click to get fast response of your post
Post #1394510
Posted Monday, December 10, 2012 3:53 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Yesterday @ 3:16 AM
Points: 10, Visits: 140
Hi Bhuvnesh,

Thanks for your response. I am after a way in which you configure the server side trace so that it drops the old entries in a FIFO (first in first out) basis. Do you know how to do it ? Any script will be very handy.
Post #1394525
Posted Monday, December 10, 2012 4:00 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Today @ 1:24 AM
Points: 151, Visits: 1,038
When you choose "save to file" in profiler you have options "Enable file rollover" and "Set maximum file size", set them for your needs, set any additional parameters, choose only these events in which you interested in, set proper filters. Run and immediately stop trace choose "File->Export->Script Trace Definition" and you have script to set server trace with rollover file.
Post #1394528
Posted Monday, December 10, 2012 4:45 AM
Grasshopper

GrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopperGrasshopper

Group: General Forum Members
Last Login: Yesterday @ 3:16 AM
Points: 10, Visits: 140
Is the rollover option will limit the size of the files used in total with out stopping the trace from collecting data ? Please note, Since this is an "unmanned process" I am trying to ensure it will not consume the C drive eventually. Can you please confirm this.
Post #1394546
Posted Monday, December 10, 2012 6:15 AM
SSC-Enthusiastic

SSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-EnthusiasticSSC-Enthusiastic

Group: General Forum Members
Last Login: Today @ 1:24 AM
Points: 151, Visits: 1,038
I forgot, you must then add @filecount options to sp_trace_create in script generated by Profiler,
explanation and examples here: http://www.sqlservercentral.com/articles/SQL+Trace/71841/
http://msdn.microsoft.com/en-us/library/ms190362.aspx
Post #1394570
Posted Monday, December 10, 2012 6:18 AM


SSChampion

SSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampionSSChampion

Group: General Forum Members
Last Login: Today @ 11:35 AM
Points: 11,646, Visits: 27,750
rama.mathanmohan (12/10/2012)
Is the rollover option will limit the size of the files used in total with out stopping the trace from collecting data ? Please note, Since this is an "unmanned process" I am trying to ensure it will not consume the C drive eventually. Can you please confirm this.


yes, when the option TRACE_FILE_ROLLOVER is true, it limits the size of data captured,and will not stop the trace.
A specific example:
if you set the rollover option & number of files, then the oldest data will be pushed off in favor of the new data;

this exampel would keep 500 meg of data.
    declare @path nvarchar(256)    
declare @traceidout int
declare @maxfilesize bigint
declare @maxRolloverFiles int
declare @on bit

set @on = 1
set @maxRolloverFiles = 10 --10 files in total
set @maxfilesize = 50 --meg so we are keeping the "latest" 500 meg of changes(10 x 50M)

--we want the current trace folder
--ie c:\Program Files\Microsoft SQL Server\MSSQL.1\MSSQL\LOG
SELECT @path = REVERSE(SUBSTRING(REVERSE(path),CHARINDEX('\',REVERSE(path)),256)) FROM sys.traces WHERE is_default = 1
SET @path = @path + N'MyDMLtrace2' --system appends .trc automatically for the filename

exec sp_trace_create @traceid = @traceidout output,
@options = 2, -- TRACE_FILE_ROLLOVER = TRUE, SHUTDOWN_ON_ERROR = FALSE
@tracefile = @path,
@maxfilesize = @maxfilesize,
@stoptime = NULL,
@filecount = @maxRolloverFiles



Lowell

--There is no spoon, and there's no default ORDER BY in sql server either.
Actually, Common Sense is so rare, it should be considered a Superpower. --my son
Post #1394571
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse