{"id":153,"date":"2009-05-25T08:50:02","date_gmt":"2009-05-25T13:50:02","guid":{"rendered":"http:\/\/appcrawler.com\/wordpress\/?p=153"},"modified":"2011-07-06T09:55:46","modified_gmt":"2011-07-06T14:55:46","slug":"cpu-used-by-service","status":"publish","type":"post","link":"http:\/\/appcrawler.com\/wordpress\/2009\/05\/25\/cpu-used-by-service\/","title":{"rendered":"CPU used by service"},"content":{"rendered":"<p>What is below will query AWR and print CPU for a given service in a three instance cluster.  This hardcodes the three instances, as well as eight processors with half hour AWR samples (14,400 seconds of CPU available).<\/p>\n<pre lang=\"sql\" line=\"1\">\r\nset serveroutput on pages 100 feedback off verify off\r\n\r\nvariable service_name varchar2(100)\r\nexec :service_name := '&service_name'\r\n\r\nvariable start_time number\r\nbegin\r\n  select min(snap_id) into :start_time from dba_hist_snapshot where begin_interval_time > sysdate - &start_time;\r\nend;\r\n\/\r\n\r\nvariable end_time number\r\nbegin\r\n  select min(snap_id) into :end_time from dba_hist_snapshot where begin_interval_time > sysdate - &end_time;\r\nend;\r\n\/\r\n\r\nprint start_time\r\nprint end_time\r\nprint service_name\r\n\r\nselect *\r\n  from (select distinct begin_interval_time,\r\n                        trunc(inst1\/10000\/14400) inst1,\r\n                        trunc(inst2\/10000\/14400) inst2,\r\n                        trunc(inst3\/10000\/14400) inst3\r\n          from (select to_char(begin_interval_time,'YYYY_MM_DD HH24:MI') begin_interval_time,\r\n                       dhss.instance_number,\r\n                       value - lag(value, 1, 0) over (order by dhss.instance_number, dhss.snap_id) as value_delta\r\n                  from dba_hist_snapshot dhs,\r\n                       dba_hist_service_stat dhss\r\n                  where dhs.snap_id = dhss.snap_id\r\n                    and dhs.instance_number = dhss.instance_number\r\n                    and stat_name = 'DB CPU'\r\n                    and service_name = :service_name\r\n                    and dhss.snap_id between :start_time and :end_time\r\n                  order by 1) c\r\n          model\r\n            ignore nav\r\n            dimension by(c.instance_number i,\r\n                         c.begin_interval_time begin_interval_time)\r\n            measures(c.value_delta value_delta,\r\n                     0 inst1,\r\n                     0 inst2,\r\n                     0 inst3)\r\n            rules(inst1[any,any] = value_delta[i = 1, cv(begin_interval_time)],\r\n                  inst2[any,any] = value_delta[i = 2, cv(begin_interval_time)],\r\n                  inst3[any,any] = value_delta[i = 3, cv(begin_interval_time)])\r\n          order by 1)\r\n  where (inst1 >= 0 and inst2>= 0 and inst3>= 0)\r\n\/\r\n<\/pre>\n","protected":false},"excerpt":{"rendered":"<p>What is below will query AWR and print CPU for a given service in a three instance cluster. This hardcodes the three instances, as well as eight processors with half hour AWR samples (14,400 seconds of CPU available). set serveroutput&hellip;<\/p>\n<p class=\"more-link-p\"><a class=\"more-link\" href=\"http:\/\/appcrawler.com\/wordpress\/2009\/05\/25\/cpu-used-by-service\/\">Read more &rarr;<\/a><\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"open","ping_status":"open","sticky":false,"template":"","format":"standard","meta":{"_mi_skip_tracking":false,"footnotes":""},"categories":[19,22],"tags":[],"_links":{"self":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/153"}],"collection":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/comments?post=153"}],"version-history":[{"count":10,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/153\/revisions"}],"predecessor-version":[{"id":990,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/posts\/153\/revisions\/990"}],"wp:attachment":[{"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/media?parent=153"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/categories?post=153"},{"taxonomy":"post_tag","embeddable":true,"href":"http:\/\/appcrawler.com\/wordpress\/wp-json\/wp\/v2\/tags?post=153"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}