September 6, 2013 at 2:23 am
Hi friends,
When I run the below procedure am getting as CPU utilization of the server is 185% ,300%. Where am I wrong in the script..
create procedure CPU
as
begin
declare @a as bigint, @b-2 as bigint, @val float
select @a=sum(cntr_value)
from sys.dm_os_performance_counters
where object_name = 'SQLServer:Resource Pool Stats' and cntr_type = 537003264
select distinct @b-2=cntr_value
from sys.dm_os_performance_counters
where object_name = 'SQLServer:Resource Pool Stats' and cntr_type = 1073939712
set @val=(select cast(@a as float) / cast(@b as float)*100 as [cpu])
print @val
declare @temp varchar(max)
set @temp='CPU utilization of server is '+CONVERT(VARCHAR(3),LEFT(@val,3))+'%'+' Check what is running in the server'
if(@val>50)
BEGIN
Exec msdb.dbo.sp_send_dbmail
@recipients='isdm@plintron.com',
@subject='Server utilization is high',
@body=@temp
END
end
Thanks in advance.
September 6, 2013 at 2:27 pm
It seams to be working correctly for me as well...
-- Itzik Ben-Gan 2001
Viewing 3 posts - 1 through 2 (of 2 total)
You must be logged in to reply to this topic. Login to reply