Skip to content

Commit e8cb01e

Browse files
committed
Modified Script to capture All PerfMon counters
Modified Script to capture All PerfMon counters
1 parent 3ebbd70 commit e8cb01e

File tree

6 files changed

+387
-69
lines changed

6 files changed

+387
-69
lines changed
2.5 KB
Binary file not shown.

Backup-Restore/Backup-Restore.ssmssqlproj

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
<Items>
44
<LogicalFolder Name="Connections" Type="2" Sorted="true">
55
<Items>
6-
<ConnectionNode Name="(local):CORPORATE\adwivedi">
6+
<ConnectionNode Name="(local):MSI\ajayd">
77
<Created>2019-08-27T10:15:39.8361802+05:30</Created>
88
<Type>SQL</Type>
99
<Server>(local)</Server>
@@ -15,7 +15,7 @@
1515
<ConnectionProtocol>NotSpecified</ConnectionProtocol>
1616
<ApplicationName>Microsoft SQL Server Management Studio - Query</ApplicationName>
1717
</ConnectionNode>
18-
<ConnectionNode Name="LOCALHOST:CORPORATE\adwivedi">
18+
<ConnectionNode Name="LOCALHOST:MSI\ajayd">
1919
<Created>2019-10-08T18:02:23.4522102+05:30</Created>
2020
<Type>SQL</Type>
2121
<Server>LOCALHOST</Server>
@@ -74,8 +74,8 @@
7474
<FullPath>4) Script Out DB_Owner from Source.sql</FullPath>
7575
</FileNode>
7676
<FileNode Name="5) Set Compatibility Level as per Model.sql">
77-
<AssociatedConnectionMoniker />
78-
<AssociatedConnSrvName />
77+
<AssociatedConnectionMoniker>8c91a03d-f9b4-46c0-a305-b5dcc79ff907:(local):True</AssociatedConnectionMoniker>
78+
<AssociatedConnSrvName>(local)</AssociatedConnSrvName>
7979
<AssociatedConnUserName />
8080
<FullPath>5) Set Compatibility Level as per Model.sql</FullPath>
8181
</FileNode>
19.6 KB
Binary file not shown.

SQLDBATools-Inventory/Grafana-Queries.sql

Lines changed: 117 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -138,10 +138,121 @@ END;
138138

139139

140140

141-
USE DBA
142-
select collection_time as time, cntr_value as [Batch Requests/sec]
143-
from DBA.dbo.dm_os_performance_counters
141+
select master.dbo.local2utc(collection_time) as time, counter_name, cntr_value
142+
from DBA.dbo.dm_os_performance_counters as pc
143+
where 1 = 1
144+
and pc.object_name = 'SQLServer:Memory Manager' and counter_name not in ('Memory Grants Pending')
145+
--and collection_time BETWEEN master.dbo.utc2local($__timeFrom()) AND master.dbo.utc2local($__timeTo())
146+
147+
148+
select master.dbo.local2utc(collection_time) as time, counter_name, cntr_value
149+
from DBA.dbo.dm_os_performance_counters as pc
150+
where 1 = 1
151+
and pc.object_name = 'SQLServer:SQL Statistics' --and counter_name not in ('Memory Grants Pending')
152+
--and collection_time BETWEEN master.dbo.utc2local($__timeFrom()) AND master.dbo.utc2local($__timeTo())
153+
154+
155+
select master.dbo.local2utc(collection_time) as time, counter_name, cntr_value
156+
from DBA.dbo.dm_os_performance_counters as pc
144157
where 1 = 1
145-
--and collection_time BETWEEN master.dbo.utc2local($__timeFrom()) AND master.dbo.utc2local($__timeTo())
146-
and object_name = 'SQLServer:SQL Statistics' and counter_name in ('Batch Requests/sec')
147-
order by time asc
158+
and pc.object_name = 'SQLServer:Buffer Manager' --and counter_name not in ('Memory Grants Pending')
159+
--and collection_time BETWEEN master.dbo.utc2local($__timeFrom()) AND master.dbo.utc2local($__timeTo())
160+
161+
162+
select distinct object_name, counter_name, instance_name, cntr_type from DBA..dm_os_performance_counters as pc where object_name = 'SQLServer:Buffer Manager'
163+
164+
select * from sys.dm_os_performance_counters as pc
165+
where --object_name like 'SQLServer:Buffer Manager%'
166+
pc.counter_name like '%available%'
167+
--or pc.counter_name like 'SQL Compilations/sec%'
168+
--or pc.counter_name like 'SQL Re-Compilations/sec%'
169+
/*
170+
SQL Attention rate
171+
SQL Compilations/sec
172+
SQL Re-Compilations/sec
173+
*/
174+
175+
select master.dbo.local2utc(collection_time) as time, cast(free_memory_kb/1024 as decimal(20,2)) as [Available Mbytes], used_page_file_mb = cast(used_page_file_kb*1024 as decimal(30,2))
176+
from DBA.[dbo].[dm_os_sys_memory]
177+
where 1 = 1
178+
--and collection_time BETWEEN master.dbo.utc2local($__timeFrom()) AND master.dbo.utc2local($__timeTo())
179+
--and server_name = $server_name
180+
order by time asc
181+
182+
183+
select rtrim(object_name) as object_name, rtrim(counter_name) as counter_name, rtrim(instance_name) as instance_name, rtrim(cntr_type) as cntr_type
184+
from sys.dm_os_performance_counters as pc
185+
where rtrim(object_name) like 'SQLServer:Transactions%'
186+
--
187+
EXCEPT
188+
--
189+
select distinct rtrim(object_name) as object_name, rtrim(counter_name) as counter_name, rtrim(instance_name) as instance_name, rtrim(cntr_type) as cntr_type
190+
from DBA..dm_os_performance_counters as pc
191+
where rtrim(object_name) like 'SQLServer:Transactions'
192+
193+
;with t_counters as (
194+
select distinct top 100 rtrim(object_name) as object_name, rtrim(counter_name) as counter_name, rtrim(cntr_type) as cntr_type
195+
from sys.dm_os_performance_counters
196+
where ( object_name like 'SQLServer:Transactions%'
197+
and
198+
( counter_name like 'Free Space in tempdb (KB)%'
199+
or
200+
counter_name like 'Longest Transaction Running Time%'
201+
or
202+
counter_name like 'Transactions%'
203+
or
204+
counter_name like 'Version Store Size (KB)%'
205+
)
206+
)
207+
order by cntr_type, object_name, counter_name
208+
)
209+
select --*,
210+
' or
211+
( [object_name] like '''+object_name+'%'' and [counter_name] like '''+counter_name+'%'' )'
212+
from t_counters
213+
--where cntr_type = '272696576'
214+
order by cntr_type, object_name, counter_name
215+
216+
217+
select distinct object_name, counter_name, instance_name
218+
from dbo.dm_os_performance_counters
219+
order by object_name, counter_name, instance_name
220+
221+
222+
SELECT --TOP(5)
223+
--@current_time as collection_time,
224+
[type] AS memory_clerk,
225+
SUM(pages_kb) / 1024 AS size_mb
226+
--INTO DBA..dm_os_memory_clerks
227+
FROM sys.dm_os_memory_clerks WITH (NOLOCK)
228+
GROUP BY [type]
229+
HAVING (SUM(pages_kb) / 1024) > 0
230+
ORDER BY SUM(pages_kb) DESC
231+
232+
SELECT *
233+
FROM sys.dm_os_memory_cache_counters
234+
order by pages_kb DESC
235+
236+
SELECT objtype, cacheobjtype,
237+
AVG(usecounts) AS Avg_UseCount,
238+
SUM(refcounts) AS AllRefObjects,
239+
SUM(CAST(size_in_bytes AS bigint))/1024/1024 AS Size_MB
240+
FROM sys.dm_exec_cached_plans
241+
--WHERE objtype = 'Adhoc' AND usecounts = 1
242+
GROUP BY objtype, cacheobjtype;
243+
244+
245+
select top 1 collection_time as time
246+
,available_physical_memory_gb*1024 as decimal(20,0)) as available_physical_memory
247+
from DBA.[dbo].[dm_os_sys_memory]
248+
order by collection_time desc
249+
250+
select top 1 collection_time as time, (free_memory_kb*1.0)/1024 as [Available Memory]
251+
from DBA.[dbo].[dm_os_sys_memory]
252+
order by collection_time desc
253+
254+
select *
255+
from DBA..WhoIsActive_ResultSets as r
256+
where r.collection_time >= '2020-08-23 16:30:00'
257+
258+
select getdate()

SQLDBATools-Inventory/SCH-Waits-Stats-Collection.sql

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -161,3 +161,4 @@ DBCC SQLPERF
161161
"sys.dm_os_wait_stats" , CLEAR
162162
)
163163
WITH NO_INFOMSGS ;
164+

0 commit comments

Comments
 (0)