The only drawback of sqldiag is that it does not periodically query system views,
So if you add the Perfstatsscript.sql monitor script output, it's more comprehensive.
Perfstatsscript: Description: Set up two stored procedures,
1) sp_perf_stats09:– lists the most time-consuming requests and finds the source of the blockage, #tmp_requests: queries the current active request, task, and other basic information – #tmp_requests2: According to #tmp_requests query the current active transaction, The blocked process
2) sp_perf_stats_infrequent09: Collects performance counters for SQL Server, such as memory management, CLR, etc. sys.dm_os_performance_counters,cpu operation, I/O conditions
Executes SP_PERF_STATS09 every 10 minutes, sp_perf_stats_infrequent09 per hour
Custom Execution SQL
<customtask enabled= "true" Groupname= "BYRONSP" taskname= "Reuseplanpercentage" type= "Tsql_command" point= "Startup "Wait=" Onlyonshutdown "cmd=" exec tempdb.dbo.GetTable "/>
Output results in:
Sqldi\taskname_startup.out
SQL is executed once and it's over, and if you want to do it multiple times,
The sppollsp stored procedure is called and executed periodically.
If object_id (' DBO.SPPOLLSP ') is not null– added to Msdiagprocs.sql
DROP PROC DBO.SPPOLLSP
GO
PRINT '
RAISERROR (' = = = = = Set Stored procedure DBO.SPPOLLSP to repeat calls to other stored procedures ', 0, 1)
With NOWAIT
GO
CREATE PROC dbo.sppollsp @spName sysname, @interval char (8) = ' 00:01:00 '
As
DECLARE @SQL NVARCHAR (200)
SET @SQL = ' EXEC ' [email protected] + '; WAITFOR DELAY ' + @interval + '
While 1=1
EXEC (@SQL)
GO
SQLdiag parameters
such as: sqldiag-pc:\sqldiag/b +00:01:00/e +00:10:00/n 1/l
The execution starts in 1 minutes and stops after 10 minutes. Continuous operation
Run as a service until 10:19 ticks stop
Sqldiag-p "C:\sqldiag"-e20120508_10:23:00-n2-r
net start SQLdiag
Unloading:
net stop SQLdiag
Sqldiag-u
Log file to CSV file:
Relog SQLDIAG. Blg-f Csv-o "C:\sqldiag\SQLDIAG_00001\a
. csv "
Relog sqldiag.blg-q-o counter.txt-Check Register
/I Configuration_file
Sets the configuration file to be used by the SQLDIAG. By default,/I is set to SQLDiag.Xml.
/O Output_folder_path
Redirects the SQLdiag output to the specified folder. If the/O option is not specified, the SQLDIAG output is written to a subfolder named SQLdiag under the SQLdiag Startup folder. If the SQLDIAG folder does not exist, SQLDIAG will attempt to create the folder.
/P Support_folder_path
Set the Support folder path. By default, the/P setting holds the folder for the SQLdiag executable file.
/b [+]start_time
Specify the date and time to begin collecting diagnostic data in the following format:
Specify the date and time to begin collecting diagnostic data in the following format:
YYYYMMDD_HH:MM:SS
with + and without a date (using only HH:MM:SS), you can specify a time relative to the current date and time. For example, if you specify/b +02:00:00, SQLdiag will start collecting information after 2 hours.
Do not insert a space between + and the specified start_time.
/E [+]stop_time
Specify the date and time to stop collecting diagnostic data in the following format:
Using the/b +02:00:00/e +03:00:00 to specify the start time and end time, the SQLDIAG will start collecting information after 2 hours and after 3 hours of information collection stop collecting and exiting.
/R
Register SQLdiag as a service. Any command-line arguments that you specify when you register SQLdiag as a service are reserved for later use to run the service.
/u
Revoke the SQLDIAG service registration.
/n output_folder_management_option, such as: sqldiag/n 1
Sets whether SQLdiag overwrites or renames the output folder when it starts. The available options are:
1 = Overwrite output folder (default)
2 = When SQLdiag is started, the output folder is renamed to Sqldiag_00001, Sqldiag_00002, and so on. After renaming the current output folder, SQLdiag writes the output to the default output folder SQLdiag.
-
/L: Continuous Operation SQLdiag
5, the General setting outline is: Record two hours, record every 4 seconds, record a day, every 30 seconds record, record 5 days, every 180 seconds to record once, so as not to affect the system performance, and can show the system lasting changes.