When creating an event monitor you must determine where
the information it collects is to be stored. A pipe event monitor
streams event records directly from the event monitor, to a named
pipe.
Before you begin
- You need SQLADM or DBADM authority to create a pipe event monitor.
- This task assumes the named pipe is already
created. To create a named pipe on UNIX or Linux® systems,
use the mkfifo command provided on those systems.
About this task
It is the responsibility of the monitoring application to
promptly read the data from the pipe as the event monitor writes the
event data. If the event monitor is unable to write data to the pipe
(for example, if it is full), monitor data will be lost.Pipe event
monitors are defined with the CREATE EVENT MONITOR
statement.
Procedure
- Indicate that event monitor data is to be directed to a
named pipe.
CREATE EVENT MONITOR myevmon FOR eventtype
WRITE TO PIPE '/home/dbadmin/dlevents'
myevmon
is the name of the event
monitor.
/home/dbadmin/dlevents
is the name of
the named pipe (on UNIX) to
where the event monitor will direct the event records. The CREATE EVENT MONITOR
statement supports UNIX and Windows pipe naming syntax.
The named pipe specified
in the CREATE EVENT MONITOR
statement must be present
and open when you activate the event monitor. If you specify that
the event monitor is to start automatically, the named pipe must exist
before the event monitor's creation.
- Specify the types of events to be monitored.
You can monitor one or more event types with a single event monitor.
CREATE EVENT MONITOR myevmon FOR BUFFERPOOLS, TABLESPACES
WRITE TO PIPE '/home/dbadmin/myevents'
This event monitor will monitor for the BUFFERPOOLS
and TABLESPACES event types.
- Specify if the event monitor is to be activated automatically
each time the database starts. By default, event monitors are not
activated automatically when the database starts.
- To create an event monitor that starts automatically when
the database starts, issue the following statement:
CREATE EVENT MONITOR myevmon FOR BUFFERPOOLS, TABLESPACES
WRITE TO PIPE '/home/dbadmin/myevents'
AUTOSTART
- To create an event monitor that does not start automatically
when the database starts, issue the following statement:
CREATE EVENT MONITOR myevmon FOR BUFFERPOOLS, TABLESPACES
WRITE TO PIPE '/home/dbadmin/myevents
MANUALSTART
- Start the client application that
reads from the named pipe. For example, you can start the db2evmon
tool to process the data as it is delivered to the pipe.
- To activate or deactivate an event monitor, use the
SET EVENT MONITOR STATE
statement.
Results
After a pipe event monitor is created and activated, it will
record monitoring data as its specified events occur.