fiomon.sql
上传用户:rjj0351
上传日期:2007-01-07
资源大小:9k
文件大小:2k
源码类别:

Oracle数据库

开发平台:

SQL

  1. set serveroutput on
  2. set verify  off
  3. set feedback off
  4. declare
  5. type CurrStatTabTyp is table of v$filestat%ROWTYPE index by binary_integer;
  6. type PrevStatTabTyp is table of v$filestat%ROWTYPE index by binary_integer;
  7. Curr_Tab CurrStatTabTyp;
  8. Prev_Tab PrevStatTabTyp;
  9. t_records  number := &1;
  10. t_interval number := &2;
  11. t_count    number := &3;
  12. t_delta    varchar2(20) :='&4';
  13. t_filename v$dbfile.name%TYPE;
  14. counter0 BINARY_INTEGER := 0;
  15. counter1 BINARY_INTEGER := 0;
  16. counter2 BINARY_INTEGER := 0;
  17. cursor c1 IS
  18. select *
  19.   from v$filestat
  20.  order by file#;
  21.   
  22. begin
  23.  for c1rec IN c1 loop
  24.    Prev_Tab(counter1) := c1rec;
  25.    counter1 := counter1 + 1;
  26.  end loop; 
  27.  if t_delta = 'delta'
  28.  then
  29.    dbms_lock.sleep(t_interval);
  30.    for c1rec in c1 loop
  31.      Curr_Tab(counter2) := c1rec;
  32.      counter2 := counter2 + 1;
  33.    end loop; 
  34.    dbms_output.put_line('ID  FILENAME                          (in this interval) READS  WRITES');
  35.    counter2 := 0;
  36.    while counter2 < counter1 loop
  37.     select name
  38.       into t_filename
  39.       from v$dbfile d
  40.      where d.file# = Prev_Tab(counter2).file#;
  41.     dbms_output.put_line(rpad(ltrim(to_char(Prev_Tab(counter2).file#,'990')),4)            ||
  42.                          rpad(ltrim(t_filename),50)                                        ||
  43.                          lpad(ltrim(to_char(Curr_Tab(counter2).phyrds - 
  44.                                             Prev_Tab(counter2).phyrds,'9999990')),8)       ||
  45.                          lpad(ltrim(to_char(Curr_Tab(counter2).phywrts - 
  46.                                             Prev_Tab(counter2).phywrts,'9999990')),8) );
  47.        counter2 := counter2 + 1;
  48.    end loop; 
  49.  else
  50.    dbms_output.put_line('ID  FILENAME                    (since database startup) READS  WRITES');
  51.    counter2 := 0;
  52.    while counter2 < counter1 loop
  53.     select name
  54.       into t_filename
  55.       from v$dbfile d
  56.      where d.file# = Prev_Tab(counter2).file#;
  57.     dbms_output.put_line(rpad(ltrim(to_char(Prev_Tab(counter2).file#,'990')),4)            ||
  58.                          rpad(ltrim(t_filename),50)                                        ||
  59.                          lpad(ltrim(to_char(Prev_Tab(counter2).phyrds,'9999990')),8)       ||
  60.                          lpad(ltrim(to_char(Prev_Tab(counter2).phywrts,'9999990')),8) );
  61.        counter2 := counter2 + 1;
  62.    end loop; 
  63.  end if;
  64. END;
  65. /