Search

Wednesday, July 27, 2011

SQL 2005/2008 code to get memory,cpu utilization and more

This query will give you the number of cores you have on an server ( does not work for Itanium since they are not treated as cores in the same way. For itanium it will reports each core as an CPU), the CPU utilization since last restart, max memoery settings, available memory in the box, how much memory the instance is really using and some more. Nice to have when checking if we have given to much or to little memory to an instance e.g.

select
cpu_count/hyperthread_ratio as 'Physical CPU(cores for Itanium)',
cpu_count ,
hyperthread_ratio,
ms_ticks/1000/60/60 as uptime_in_hours,
cpu_ticks as clock_cyckles ,
cpu_ticks_in_ms/1000/60 as 'CPU time in minutes',
physical_memory_in_bytes/1024/1024/1024 as 'Physical Memory in Gb',
virtual_memory_in_bytes/1024/1024/1024 as 'Virtual Memory in Gb',
(SELECT value_in_use FROM sys.configurations where name ='min server memory (MB)') as 'min server memory',
(SELECT value_in_use FROM sys.configurations where name ='max server memory (MB)') as 'Max server memory',
cast(bpool_commit_target as float)*8/1024/1024 as 'Used memory in Gb',
os_error_mode,
os_priority_class
,max_workers_count,
(SELECT value_in_use FROM sys.configurations where name ='awe enabled') as AWE,
(SELECT value_in_use FROM sys.configurations where name ='max degree of parallelism') as 'Max degree of paralelism'
from
Sys.dm_os_sys_info

No comments:

Post a Comment