#
# Shows connections for some users grouped by their duration for last 2 days
#
create or replace view cms_listconn as
select count(*) total, os_username,trunc(logoff_time, 'DD') day, round(((logoff_time-timestamp)*86400), -3) seconds
from dba_audit_session
where action_name='LOGOFF'
and username like 'CMS%'
and os_username in ('phedex', 'phtab')
and trunc(logoff_time, 'DD') in ( trunc(sysdate-1, 'DD'), trunc(sysdate-2, 'DD'), trunc(sysdate, 'DD'))
group by os_username, trunc(logoff_time, 'DD'), round(((logoff_time-timestamp)*86400), -3)
order by seconds, os_username;
#
# Show connections for some users with less than 100 secons for last 2 days
#
create or replace view cms_shortconn as
select username, os_username, timestamp, round((logoff_time-timestamp)*86400) duration
from dba_audit_session
where action_name='LOGOFF'
and os_username in ('phedex', 'phtab')
and trunc(logoff_time, 'DD') in ( trunc(sysdate-1, 'DD'), trunc(sysdate-2, 'DD'), trunc(sysdate, 'DD'))
and round(((logoff_time-timestamp)*86400), -2)
# define public synonym
create public synonym cms_listconn for cms_listconn;
create public synonym cms_shortconn for cms_shortconn;
# grant select to one user
grant select on cms_listconn to cms_transfermgmt;
grant select on cms_shortconn to cms_transfermgmt;
# test
select * from cms_listconn;
select * from cms_shortconn;
--
MiguelAnjo - 21 Mar 2005
Topic revision: r4 - 2005-11-29
- unknown