November 17, 2010 at 12:05 pm
Not sure this is a totally accurate indicator of utilization, but might be "in the ballpark":
-- Low-Budget Way to Get CPU Utilization
DECLARE @CPUStart INT,
@CPUEnd INT,
@IdleStart INT,
@IdleEnd INT,
@TotalStart INT,
@TotalEnd INT;
-- Make First Measurement
SELECT @CPUStart = @@CPU_BUSY,
@IdleStart = @@IDLE;
-- Delay 1 Seconds
WAITFOR DELAY '000:00:01';
-- Make Second Measurement
SELECT @CPUEnd = @@CPU_BUSY,
@IdleEnd = @@IDLE;
-- Compute Totals
SELECT @TotalStart = (@IdleStart + @CPUStart);
SELECT @TotalEnd = (@IdleEnd + @CPUEnd);
-- Compute Delta
DECLARE @DeltaCPU FLOAT;
SELECT @DeltaCPU = 100.0 * (@CPUEnd - @CPUStart) / (@TotalEnd - @TotalStart);
SELECT CONVERT(DECIMAL(12, 2), @DeltaCPU) AS 'PercentCPU';
November 17, 2010 at 1:05 pm
SSC-Enthusiastic: Becoz thats where we observe the max utilization and we can do max optimization!!
November 17, 2010 at 4:25 pm
My only concern with using 3rd party monitoring tools is that they could suddenly present you with a load of measurements/alerts which you don't fully understand!
We are currently building up our list of checks one at a time (real-time alert + nightly reports). That way we fully understand what each counter means and what is typlical for our environment.
That said, I've evaluated a selection of the tools (redgate, quest etc) and they do look great. I expect we will end up investing.
Good article.
Thanks
David
November 17, 2010 at 4:57 pm
Why is it so complicated? You should use resources available in MS SQL server to monitor bottle neck: CPU, Hard drive, Memory, and Network. Use Perfmon from windows. Set up with counter logs to monitor counters.
November 17, 2010 at 4:58 pm
Why is it so complicated? You should use resources available in MS SQL server to monitor bottle neck: CPU, Hard drive, Memory, and Network. Use Perfmon from windows. Set up with counter logs to monitor counters.
November 17, 2010 at 9:32 pm
dukedba (11/17/2010)
Why is it so complicated? You should use resources available in MS SQL server to monitor bottle neck: CPU, Hard drive, Memory, and Network. Use Perfmon from windows. Set up with counter logs to monitor counters.
Can you get Perfmon to send an email notification on an event like when the CPU has been at 90% for a minute or more?
--Jeff Moden
Change is inevitable... Change for the better is not.
November 17, 2010 at 10:12 pm
hi sir,
It is very good. but tell me more some idea to decreas cpu utilization..
November 18, 2010 at 5:01 am
I might be wrong,
but want to know that how the alert is connecting your job or knowing the threshold limit of cpu usage which you mentioned in vbs.
----------
Ashish
November 18, 2010 at 5:31 am
hi crazy4sql,
the connection between the vb script and the alert is the raiserror command. when the error hits the sql server error log, the sql server alert service sees it and fires the email.
thanks for reading.
November 18, 2010 at 5:35 am
i see....
I tried to play with it...have configured vbs as CPU utilisation as 1% but not getting any alert....
so i am thinking of 2 reason:-
1)server not constantly more than 2%. It might be coming down and going up very frequently.
2) I am wrong and need more modification in vbs.
----------
Ashish
November 18, 2010 at 6:01 am
crazy4sql ,
the server must be over the threshold for 10 consecutive loops.
if you want to test, use something to cause your CPU to run over the threshold for at least 1 minute.
November 18, 2010 at 6:29 am
Jeff Moden: Yes, we can
November 18, 2010 at 7:52 pm
Boxer (11/18/2010)
Jeff Moden: Yes, we can
Cool! I'll have to give it a try. In the meantime, someone should write an article on that! 🙂
--Jeff Moden
Change is inevitable... Change for the better is not.
November 19, 2010 at 10:01 am
Geoff - nice article, thanks for posting.
One thing I wanted to mention on security, if the account that SQL Agent runs with is denied access to run a command line script (CmdExec), a workaround would be to create a Proxy for CmdExec and then map an account that does have rights to run this job.
Although I have never tried this with SQL 2000, I have with 2005+ and the documentation seems to imply you can do it: http://support.microsoft.com/kb/890775
This keeps all security concerns happy because it elevates permissions to run the command line (VBScript in your case) only for a specific job or jobs.
Overall a very resourceful solution. I've been working on a "roll my own" solution to monitor several parameters of my servers through WMI hooks for some time now - disk free%, CPU Utilization, memory, I/O, etc. Who knows when I'll ever get it completed/tested but if I do I'll be sure to share!
Cheers.
November 19, 2010 at 1:46 pm
BobSaint,
yes, I am hard at work learning what powershell and SSRS can do.... one day, when it is all finished I will write an article on how I created this SQL Server Dashboard. (for FREE)
Viewing 15 posts - 31 through 45 (of 59 total)
You must be logged in to reply to this topic. Login to reply