forked from ktaranov/sqlserver-kit
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Get_SQL_Server_NUMA_Memory.sql
54 lines (53 loc) · 2.3 KB
/
Get_SQL_Server_NUMA_Memory.sql
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
/*
https://sql-sasquatch.blogspot.com/2019/09/placeholder.html
*/
WITH tgt AS (SELECT instance_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE counter_name = 'Target Node Memory (KB)'
UNION ALL
SELECT 'TOTAL', cntr_value
FROM sys.dm_os_performance_counters
WHERE counter_name = 'Target Server Memory (KB)'),
tot AS (SELECT instance_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE counter_name = 'Total Node Memory (KB)'
UNION ALL
SELECT 'TOTAL', cntr_value
FROM sys.dm_os_performance_counters
WHERE counter_name = 'Total Server Memory (KB)'),
dbc AS (SELECT instance_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE counter_name = 'Database Node Memory (KB)'
UNION ALL
SELECT 'TOTAL', cntr_value
FROM sys.dm_os_performance_counters
WHERE counter_name = 'Database Cache Memory (KB)'),
stl AS (SELECT instance_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE counter_name = 'Stolen Node Memory (KB)'
UNION ALL
SELECT 'TOTAL', cntr_value
FROM sys.dm_os_performance_counters
WHERE counter_name = 'Stolen Server Memory (KB)'),
fre AS (SELECT instance_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE counter_name = 'Free Node Memory (KB)'
UNION ALL
SELECT 'TOTAL', cntr_value
FROM sys.dm_os_performance_counters
WHERE counter_name = 'Free Memory (KB)'),
frn AS (SELECT instance_name, cntr_value
FROM sys.dm_os_performance_counters
WHERE counter_name = 'Foreign Node Memory (KB)'
UNION ALL
SELECT 'TOTAL', cntr_value = CONVERT(INT, NULL))
SELECT tgt.instance_name, target_kb = tgt.cntr_value,
total_kb = tot.cntr_value, dbCache_kb = dbc.cntr_value,
stolen_kb = stl.cntr_value, free_kb = fre.cntr_value,
foreign_kb = frn.cntr_value
FROM tgt
INNER JOIN tot ON tgt.instance_name = tot.instance_name
INNER JOIN frn ON tgt.instance_name = frn.instance_name
INNER JOIN dbc ON tgt.instance_name = dbc.instance_name
INNER JOIN stl ON tgt.instance_name = stl.instance_name
INNER JOIN fre ON tgt.instance_name = fre.instance_name;