CPU and perfmon counters from T-SQL

  • Does anyone know if there's a way to get the server's cpu utilisation and the SQL Server Perfmon counters from within SQL?

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • Look at sysperfinfo..it will give you a poor man's way of monitoring the perfmon counters from within T-SQL...you can write scripts around it to do some trend analysis.

  • sysperfinfo doesn't hold any CPU data, though. It only holds SQLServer counters, not system counters. There's no way that I know of for getting this information directly from the SQLServer using SQL2000.

    However, if you install Windows Resource Kit, there is a command-line utility called TypePerf that you can use. You can easily write both system and SQLServer perfmon counter data to a .CSV file, and then import this into a table and muck around with the data in there.

  • Thanks. That's great.

    The windows resource kit may not be possible. My server is an IA-64 machine. I don't know if there is a resource kit for it.

    The perfinfo is very useful. What I'm trying to do is write a job that does index rebuilds over a weekend but before it starts a rebuild checks to ensure that the machine isn't too busy and that the log is not about to run out of space. All too often I've seen rebuilds fail when the tran log fills up. I should be able to get sufficient info from perfinfo to do that.

    Gail Shaw
    Microsoft Certified Master: SQL Server, MVP, M.Sc (Comp Sci)
    SQL In The Wild: Discussions on DB performance with occasional diversions into recoverability

    We walk in the dark places no others will enter
    We stand on the bridge and no one may pass
  • You can also set up a new counter log in perfmon to send data directly to SQL.

Viewing 5 posts - 1 through 4 (of 4 total)

You must be logged in to reply to this topic. Login to reply