Thursday, January 20, 2011

Report CPU usage over 24 Hours

/* SQL to report CPU usage over 24 Hour period */
/* Make sure the collectintervals set correct */

select TheDate,
cast((cast((TheTime (format '99:99:99')) as char(8))) as time(0)) as TheTime,
(sum(CPUIdle) / TOTAL_CPU) * 100 AS CPUIdle,
(sum(CPUIoWait) / TOTAL_CPU) * 100 AS CPUIoWait,
(sum(CPUUServ) / TOTAL_CPU) * 100 AS CPUUServ,
(sum(CPUUExec) / TOTAL_CPU) * 100 AS CPUUExec,
SUM(CPUIdle + CPUIoWait + CPUUServ + CPUUExec) AS TOTAL_CPU,
(avg(CPUUServ + CPUUExec) / max(CPUUServ + CPUUExec)) * 100 AS CPUBusyParallelEff
from dbc.resusagespma
where thedate >= date - 1 and
collectintervals = '10'
group by 1,2
order by 1,2
;

Labels: , , , , ,

3 Comments:

Blogger Shrinivas Sagare said...

ResUsageSpam logs CPU time in centiseconds. Don't you think, it is better to calculate TotalCPU in seconds instead of centiseconds?

4:48 pm  
Blogger Siddharth said...

Hi Ranjith,
Can I get SQL for How I can find
Database growth.

9:47 am  
Blogger Siddharth said...

Hi Ranjith,
Can I get SQL for How I can find
Database growth.

9:49 am  

Post a Comment

Subscribe to Post Comments [Atom]

<< Home