Results 1 to 7 of 7

Thread: @@cpu_busy and @@idle

  1. #1
    Join Date
    Jun 2003
    Posts
    13

    @@cpu_busy and @@idle

    Should these two stats added together give me the time (ms) since SQL Server has been restarted? Maybe I don't understand but @@cpu_busy is the amount of time sql server has accessed the cpu and @@idle is the amount of time sql server has no cpu activity. When I add these two figures together, I don't get the total amount of time (ms) SQL Server has been running. What am I not doing? Any help is appreciated.
    Thanks

  2. #2
    Join Date
    Sep 2002
    Posts
    5,938
    Other processes on the server use cpu time as well.

  3. #3
    Join Date
    Jun 2003
    Posts
    13

    @@cpu_busy further explination

    Thanks. @@cpu_busy and @@idle are both reset to 0 when SQL service is restarted. I restarted this service several hours ago but when I enter select (@@cpu_busy + @@idle) the time returned is only about 25 minutes (converted from milliseconds). I'm pretty sure I'm doing the conversion right but this number doesn't match the expected return time. Do I understand what these two procedures return?

  4. #4
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    How many CPUs you have in your machine, you may have to account for that too.

  5. #5
    Join Date
    Jun 2003
    Posts
    13

    @@cpu

    how would I account for the number of cpus in the following: select (@@cpu_busy + @@idle)/1000/60 which converts the milliseconds to minutes? The returned value is incorrect for both a 1 cpu and 2 cpu server. the returned value is a lot lower than it should be.

  6. #6
    Join Date
    Nov 2002
    Location
    New Jersey, USA
    Posts
    3,932
    According to BOL, @@IDLE time is idle time for SQL Server where as @@CPU_BUSY is busy time for CPU.

    So they can't be added to get the uptime.

    You can query sysprocesses tablet to get the time when sql server was started and find the difference with current date to get uptime

    select datediff("mi",login_time,getdate()) 'Uptime in Minutes' from master..sysprocesses where spid=1

  7. #7
    Join Date
    Jun 2003
    Posts
    13
    Thanks for the feedback! I'll use the sysprocesses to get uptime. I guess however, I'd still like to understand better the definition of idle. I understand cpu_busy; the # of ms the sql server process accessed the cpu. What does idle mean? Using the word idle in the definition doesn't help because to me, idle means no cpu activity...so my question is still out there...wouldn't cpu_busy + idle = total time in ms? Am I mnissing something? Thanks for your feedback!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •