Event monitor in DB2
Event monitors are used to collect information about the database and any connected applications when specified events occur. Â An Event monitor collects various database activity using transactions. Â It can gather specific data while the even monitor is active. Â Events represent transitions in database activity: for instance, connections, deadlocks, statements, and transactions. You can define an event monitor by the type of event or events you want it to monitor. For example, a deadlock event monitor waits for a deadlock to occur; when one does, it collects information about the applications involved and the locks in contention. Â It can be used to tune performance and analyze locking issues.
Here is a simple example for creating and formating event monitor output. First ensure the monitor switches are all turned on.
db2 create event monitor evmon1 for connections, statements write to file <‘path to file’>
db2 set event monitor evmon1 state 1
Run the SQLS Â and when all of them are completed
db2 flush event monitor evmon1
db2 set event monitor evmon1 state 0
db2evmon -db <database name> -evm evmon1Â > evmon1.output