Script: report on archived log history

Report archived logs generated in last 2 weeks

set lines 300 pages 4000
col "00" for a5
col "01" for a5
col "02" for a5
col "03" for a3
col "04" for a3
col "05" for a3
col "06" for a3
col "07" for a3
col "08" for a3
col "09" for a3
col "10" for a3
col "11" for a3
col "12" for a3
col "13" for a3
col "14" for a3
col "15" for a3
col "16" for a3
col "17" for a3
col "18" for a3
col "19" for a3
col "20" for a3
col "21" for a3
col "22" for a3
col "23" for a3
col day for a17
select substr(to_char(FIRST_TIME,'YYYY/MM/DD, DY'),1,15) DAY,
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'00',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'00',1,0))) "00",
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'01',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'01',1,0))) "01",
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'02',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'02',1,0))) "02",
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'03',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'03',1,0))) "03",
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'04',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'04',1,0))) "04",
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'05',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'05',1,0))) "05",
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'06',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'06',1,0))) "06",
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'07',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'07',1,0))) "07",
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'08',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'08',1,0))) "08",
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'09',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'09',1,0))) "09",
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'10',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'10',1,0))) "10",
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'11',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'11',1,0))) "11",
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'12',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'12',1,0))) "12",
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'13',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'13',1,0))) "13",
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'14',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'14',1,0))) "14",
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'15',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'15',1,0))) "15",
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'16',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'16',1,0))) "16",
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'17',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'17',1,0))) "17",
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'18',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'18',1,0))) "18",
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'19',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'19',1,0))) "19",
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'20',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'20',1,0))) "20",
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'21',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'21',1,0))) "21",
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'22',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'22',1,0))) "22",
decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'23',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'23',1,0))) "23"
from sys.v_$log_history
group by substr(to_char(FIRST_TIME,'YYYY/MM/DD, DY'),1,15)
order by 1;

A sample output

DAY               00    01    02    03  04  05  06  07  08  09  10  11  12  13  14  15  16  17  18  19  20  21  22  23
----------------- ----- ----- ----- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
2011/01/13, THU   -     -     -     -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   -   2   4   3   4   4
2011/01/14, FRI   6     1     2     4   1   2   3   3   4   3   4   6   4   4   6   5   6   6   7   6   6   4   4   6
2011/01/15, SAT   5     2     3     5   2   2   4   5   5   4   6   5   4   4   11  6   5   6   7   4   2   2   2   4
2011/01/16, SUN   5     2     3     5   2   2   2   2   3   3   3   3   4   2   7   2   2   2   2   2   2   2   2   5
2011/01/17, MON   4     1     2     2   3   4   4   6   4   6   7   6   8   8   8   8   8   14  9   8   6   3   5   5
2011/01/18, TUE   5     2     7     5   2   3   5   6   6   9   8   8   9   10  9   9   9   11  9   8   6   3   5   5
2011/01/19, WED   6     2     7     5   4   4   6   7   7   9   8   9   8   9   10  9   10  11  13  10  8   6   6   6
2011/01/20, THU   7     3     8     6   3   4   8   8   10  9   10  7   9   12  14  13  11  12  14  15  10  5   9   7
2011/01/21, FRI   11    4     8     7   4   7   11  10  12  11  12  12  11  13  13  13  13  13  13  10  8   5   10  7
2011/01/22, SAT   10    4     8     4   4   4   8   7   10  9   8   7   10  12  13  12  11  13  13  9   6   6   5   7
2011/01/23, SUN   11    4     8     5   5   4   5   8   10  7   8   8   5   5   6   9   5   4   6   4   5   4   5   6
2011/01/24, MON   17    4     12    10  6   6   9   11  12  13  12  14  15  15  18  16  15  16  16  19  13  9   9   9
2011/01/25, TUE   21    6     12    8   5   6   12  12  14  14  14  16  13  13  15  15  11  13  15  23  13  7   9   8
2011/01/26, WED   14    -     8     3   1   -   1   2   7   4   6   6   7   4   3   3   4   3   3   6   4   3   4   4
2011/01/27, THU   8     -     8     4   1   -   1   3   7   4   9   9   9   6   4   1   -   -   -   -   -   -   -   -

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: