PL/SQL Packages and Types Reference 10g Release 1 (10.1) Part Number B10802-01 |
|
|
View PDF |
The DBMS_MONITOR package let you use PL/SQL for controlling additional tracing and statistics gathering.
The chapter contains the following topics:
This procedure will disable statistics accumulation for all instances and remove the accumulated results from V$CLIENT_STATS
view enabled by the CLIENT_ID_STAT_ENABLE
Procedure.
DBMS_MONITOR.CLIENT_ID_STAT_DISABLE( client_id IN VARCHAR2);
Parameter | Description |
---|---|
|
The Client Identifier for which statistic aggregation is disabled. |
To disable accumulation:
EXECUTE DBMS_MONITOR.CLIENT_ID_STAT_DISABLE('janedoe');
This procedure enables statistic gathering for a given Client Identifier. Statistics gathering is global for the database and persistent across instance starts and restarts. That is, statistics are enabled for all instances of the same database, including restarts. Statistics are viewable through V$CLIENT_STATS
views.
DBMS_MONITOR.CLIENT_ID_STAT_ENABLE( client_id IN VARCHAR2);
Parameter | Description |
---|---|
|
The Client Identifier for which statistic aggregation is enabled. |
To enable statistic accumulation for a client with a given client ID:
EXECUTE DBMS_MONITOR.CLIENT_ID_STAT_ENABLE('janedoe');
This procedure will disable tracing enabled by the CLIENT_ID_TRACE_ENABLE
Procedure.
DBMS_MONITOR.CLIENT_ID_TRACE_DISABLE( client_id IN VARCHAR2);
Parameter | Description |
---|---|
|
The Client Identifier for which SQL tracing is disabled. |
EXECUTE DBMS_MONITOR.CLIENT_ID_TRACE_DISABLE ('janedoe');
This procedure will enable the trace for a given client identifier globally for the database.
DBMS_MONITOR.CLIENT_ID_TRACE_ENABLE( client_id IN VARCHAR2, waits IN BOOLEAN DEFAULT TRUE, binds IN BOOLEAN DEFAULT FALSE);
EXECUTE DBMS_MONITOR.CLIENT_ID_TRACE_ENABLE('janedoe', TRUE, FALSE);
This procedure will disable statistics accumulation and remove the accumulated results from V$SERV_MOD_ACT_STATS
view. Statistics disabling is persistent for the database. That is, service statistics are disabled for instances of the same database (plus dblinks that have been activated as a result of the enable).
DBMS_MONITOR.SERV_MOD_ACT_STAT_DISABLE( service_name IN VARCHAR2, module_name IN VARCHAR2, action_name IN VARCHAR2 DEFAULT ALL_ACTIONS);
This procedure enables statistic gathering for a given combination of Service Name, MODULE
and ACTION
. Calling this procedure enables statistic gathering for a hierarchical combination of Service name, MODULE
name, and ACTION
name on all instances for the same database. Statistics are accessible by means of the V$SERV_MOD_ACT_STATS
view.
DBMS_MONITOR.SERV_MOD_ACT_STAT_ENABLE( service_name IN VARCHAR2, module_name IN VARCHAR2, action_name IN VARCHAR2 DEFAULT ALL_ACTIONS);
Enabling statistic aggregation for the given combination of Service/Module/Action names is slightly complicated by the fact that the Module/Action values can be empty strings which are indistinguishable from NULLs. For this reason, we adopt the following conventions:
A special constant (unlikely to be a real action names) is defined:
ALL_ACTIONS constant VARCHAR2 := '###ALL_ACTIONS';
Using ALL_ACTIONS
for a module specification means that aggregation is enabled for all actions with a given module name, while using NULL (or empty string) means that aggregation is enabled for an action whose name is an empty string.
To enable statistic accumulation for a given combination of Service name and MODULE
:
EXECUTE DBMS_MONITOR.SERV_MOD_ACT_STAT_ENABLE( 'APPS1','PAYROLL');
To enable statistic accumulation for a given combination of Service name, MODULE
and ACTION
:
EXECUTE DBMS_MONITOR.SERV_MOD_ACT_STAT_ENABLE('APPS1','GLEDGER','DEBIT_ENTRY');
If both of the preceding commands are issued, statistics are accumulated as follows:
PAYROLL
Module.DEBIT_ENTRY
Action within the GLEDGER
Module.This procedure will disable the trace at ALL
enabled instances for a given combination of Service Name, MODULE
, and ACTION
name globally.
DBMS_MONITOR.SERV_MOD_ACT_TRACE_DISABLE( service_name IN VARCHAR2, module_name IN VARCHAR2, action_name IN VARCHAR2 DEFAULT ALL_ACTIONS, instance_name IN VARCHAR2 DEFAULT NULL);
Specifying NULL
for the module_name
parameter means that statistics will no longer be accumulated for the sessions which do not set the MODULE
attribute.
To enable tracing for a Service named APPS1:
EXECUTE DBMS_MONITOR.SERV_MOD_ACT_TRACE_ENABLE('APPS1', DBMS_MONITOR.ALL_MODULES, DBMS_MONITOR.ALL_ACTIONS,TRUE, FALSE,NULL);
To disable tracing specified in the previous step:
EXECUTE DBMS_MONITOR.SERV_MOD_ACT_TRACE_DISABLE('APPS1');
To enable tracing for a given combination of Service
and MODULE
(all ACTION
s):
EXECUTE DBMS_MONITOR.SERV_MOD_ACT_TRACE_ENABLE('APPS1','PAYROLL', DBMS_MONITOR.ALL_ACTIONS,TRUE,FALSE,NULL);
To disable tracing specified in the previous step:
EXECUTE DBMS_MONITOR.SERV_MOD_ACT_TRACE_DISABLE('APPS1','PAYROLL');
This procedure will enable SQL tracing for a given combination of Service Name, MODULE
and ACTION
globally unless an instance_name
is specified.
DBMS_MONITOR.SERV_MOD_ACT_TRACE_ENABLE( service_name IN VARCHAR2, module_name IN VARCHAR2 DEFAULT ANY_MODULE, action_name IN VARCHAR2 DEFAULT ANY_ACTION, waits IN BOOLEAN DEFAULT TRUE, binds IN BOOLEAN DEFAULT FALSE, instance_name IN VARCHAR2 DEFAULT NULL);
MODULE
and ACTION
name. The specification is strictly hierarchical: Service Name or Service Name/MODULE
, or Service Name, MODULE, and ACTION
name must be specified. Omitting a qualifier behaves like a wild-card, so that not specifying an ACTION
means all ACTION
s. Using the ALL_ACTIONS
constant achieves the same purpose.MODULE
and optionally known ACTION
is experiencing poor service levels.instance_name
parameter is provided to restrict tracing to named instances that are known, for example, to exhibit poor service levels.trcsess
tool to collect it into a single file.NULL
for the module_name
parameter means that statistics will be accumulated for the sessions which do not set the MODULE
attribute.To enable tracing for a Service named APPS1
:
EXECUTE DBMS_MONITOR.SERV_MOD_ACT_TRACE_ENABLE('APPS1', DBMS_MONITOR.ALL_MODULES, DBMS_MONITOR.ALL_ACTIONS,TRUE, FALSE,NULL);
To enable tracing for a given combination of Service and MODULE
(all ACTION
s):
EXECUTE DBMS_MONITOR.SERV_MOD_ACT_TRACE_ENABLE('APPS1','PAYROLL', DBMS_MONITOR.ALL_ACTIONS,TRUE,FALSE,NULL);
This procedure will disable the trace for a given database session at the local instance.
DBMS_MONITOR.SESSION_TRACE_DISABLE( session_id IN BINARY_INTEGER DEFAULT NULL, serial_num IN BINARY_INTEGER DEFAULT NULL);
Parameter | Description |
---|---|
|
Name of the service for which SQL trace is disabled. |
|
Serial number for this session. |
If serial_num
is NULL
but session_id
is specified, a session with a given session_id is no longer traced irrespective of its serial number. If both session_id
and serial_num
are NULL
, the current user session is no longer traced. It is illegal to specify NULL
session_id
and non-NULL
serial_num
. In addition, the NULL
values are default and can be omitted.
To enable tracing for a client with a given client session ID:
EXECUTE DBMS_MONITOR.SESSION_TRACE_ENABLE(7,4634, TRUE, FALSE);
To disable tracing specified in the previous step:
EXECUTE DBMS_MONITOR.SESSION_TRACE_DISABLE(7,4634);;
This procedure enables a SQL trace for the given Session ID on the local instance
DBMS_MONITOR.SESSION_TRACE_ENABLE( session_id IN BINARY_INTEGER DEFAULT NULL, serial_num IN BINARY_INTEGER DEFAULT NULL, waits IN BOOLEAN DEFAULT TRUE, binds IN BOOLEAN DEFAULT FALSE)
The procedure enables a trace for a given database session, and is still useful for client/server applications. The trace is enabled only on the instance to which the caller is connected, since database sessions do not span instances. This tracing is strictly local to an instance.
If serial_num
is NULL
but session_id
is specified, a session with a given session_id is traced irrespective of its serial number. If both session_id
and serial_num
are NULL
, the current user session is traced. It is illegal to specify NULL
session_id
and non-NULL
serial_num
. In addition, the NULL
values are default and can be omitted.
To enable tracing for a client with a given client session ID:
EXECUTE DBMS_MONITOR.SESSION_TRACE_ENABLE(7,4634, TRUE, FALSE);
To disable tracing specified in the previous step:
EXECUTE DBMS_MONITOR.SESSION_TRACE_DISABLE(7,4634);
Either
EXECUTE DBMS_MONITOR.SESSION_TRACE_ENABLE(5);
or
EXECUTE DBMS_MONITOR.SESSION_TRACE_ENABLE(5, NULL);
traces the session with session ID of 5, while either
EXECUTE DBMS_MONITOR.SESSION_TRACE_ENABLE();
or
EXECUTE DBMS_MONITOR.SESSION_TRACE_ENABLE(NULL, NULL);
traces the current user session. Also,
EXECUTE DBMS_MONITOR.SESSION_TRACE_ENABLE(NULL, NULL, TRUE, TRUE);
traces the current user session including waits and binds. The same can be also expressed using keyword syntax:
EXECUTE DBMS_MONITOR.SESSION_TRACE_ENABLE(binds=>TRUE);