Threshold login triggers for Oracle 10046 event trace collection
Tuesday Jul 11, 2006
There are multiple ways to gather trace data. You can instrument the application, pick an oracle sid from sysdba, turn on tracing for all users (ouch), or use a login trigger to narrow down to a specific user. Each of these methods have merit, but recently I desired to gather traces at various user levels.
The problem with most packaged applications, is that they all use the *same* userid. For this Oracle 10G environment, I used this fact to filter only connections of the type that I wanted to sample. I wanted to gather 10046 event trace data when the number of connections was 10, 20, or 30. To achieve this, I used a logon trigger and sampled the number of sessions from v$session to come up with the connection count. I have found this little trick to be very useful in automating collection without modifying the application. I hope this can be useful to you as well.
create or replace trigger trace_my_user after logon on database DECLARE mycnt int; BEGIN SELECT count(*) INTO mycnt FROM v$session WHERE username='GLENNF'; if (user='GLENNF') and ((mycnt=10) or (mycnt=20) or (mycnt=30)) then dbms_monitor.session_trace_enable(null,null,true,true); end if; end; /
Tags: 10046 databases dbms_monitor event hotsos oracle orasrp performance session_trace_enable solaris sun trace trigger











Posted by KG on July 11, 2006 at 11:51 AM PDT #