![](http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2.luw.admin.trb.doc/doc/IC-im-sm.gif)
Analyzing db2diag log files using db2diag tool
http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/index.jsp?topic=/com.ibm.db2.luw.admin.trb.doc/doc/c0020701.html
The primary log file intended for use by database and system administrators is the administration notification log. The db2diag log files are intended for use by DB2® Support for troubleshooting purposes.
Administration notification log messages are also logged to the db2diag log files using a standardized message format.
The db2diag tool serves to filter and format the volume of information available in the db2diag log files. Filtering db2diag log file records can reduce the time required to locate the records needed when troubleshooting problems.
Example 1: Filtering the db2diag log files by database name
If there are several databases in the instance, and you want to only see those messages which pertain to the database "SAMPLE", you can filter the db2diag log files as follows:
db2diag -g db=SAMPLE
2006-02-15-19.31.36.114000-300 E21432H406 LEVEL: Error
PID : 940 TID : 660 PROC : db2syscs.exe
INSTANCE: DB2 NODE : 000 DB : SAMPLE
APPHDL : 0-1056 APPID: *LOCAL.DB2.060216003103
FUNCTION: DB2 UDB, base sys utilities, sqleDatabaseQuiesce, probe:2
MESSAGE : ADM7507W Database quiesce request has completed successfully.
Example 2: Filtering the db2diag log files by process ID
db2diag -g level=Severe,pid=2200 -n 0,1,2,3
2006-02-13-14.34.36.027000-300 I18366H421 LEVEL: Severe
PID : 2200 TID : 660 PROC : db2syscs.exe
INSTANCE: DB2 NODE : 000 DB : SAMPLE
APPHDL : 0-1433 APPID: *LOCAL.DB2.060213193043
FUNCTION: DB2 UDB, data management, sqldPoolCreate, probe:273
RETCODE : ZRC=0x8002003C=-2147352516=SQLB_BAD_CONTAINER_PATH
"Bad container path"
Example 3: Formatting the db2diag tool output
db2diag -time 2006-01-01 -node "0,1,2" -level "Severe, Error" | db2diag -fmt
"Time: %{ts}
Partition: %node Message Level: %{level} /nPid: %{pid} Tid: %{tid}
Instance: %{instance}/nMessage: @{msg}/n"
Time: 2006-02-15-19.31.36.099000 Partition: 000 Message Level: Error
Pid: 940 Tid:940 Instance: DB2
Message: ADM7506W Database quiesce has been requested.
- db2diag -help provides a short description of all available options
- db2diag -h brief provides descriptions for all options without examples
- db2diag -h notes provides usage notes and restrictions
- db2diag -h examples provides a small set of examples to get started
- db2diag -h tutorial provides examples for all available options
- db2diag -h all provides the most complete list of options
Example 4: Filtering messages from different facilities
- ALL which returns records from all facilities
- MAIN which returns records from DB2 general diagnostic logs such as the db2diag log files and the administration notification log
- OPSTATS which returns records related to optimizer statistics
db2diag -facility MAIN
db2diag -fac OPSTATS -level Severe
db2diag -fac all -g instance=harmistr,level=Error
db2diag -fac opstats -level Error -fmt " Time :%{ts} Pid :%{pid}"
Example 5: Merging files and sorting records according to timestamps
This example shows how to merge two or more db2diag log files and sort the records according to timestamps.
- db2diag.0.log ; contains records of Level:Error with the following timestamps:
- 2009-02-26-05.28.49.822637
- 2009-02-26-05.28.49.835733
- 2009-02-26-05.28.50.258887
- 2009-02-26-05.28.50.259685
- db2diag.1.log ; contains records of Level:Error with the following timestamps:
- 2009-02-26-05.28.11.480542
- 2009-02-26-05.28.49.764762
- 2009-02-26-05.29.11.872184
- 2009-02-26-05.29.11.872968
db2diag -merge db2diag.0.log db2diag.1.log -fmt %{ts} -level error
- 2009-02-26-05.28.11.480542
- 2009-02-26-05.28.49.764762
- 2009-02-26-05.28.49.822637
- 2009-02-26-05.28.49.835733
- 2009-02-26-05.28.50.258887
- 2009-02-26-05.28.50.259685
- 2009-02-26-05.29.11.872184
- 2009-02-26-05.29.11.872968
Example 6: Merging split diagnostic directory path files from a single host and sorting records by timestamps
db2 update dbm cfg using diagpath '"$n"'
- ~/sqllib/db2dump/NODE0000/db2diag.log
- ~/sqllib/db2dump/NODE0001/db2diag.log
- ~/sqllib/db2dump/NODE0002/db2diag.log
db2diag -merge
Example 7: Merging split diagnostic directory path files from multiple hosts and database partitions
db2 update dbm cfg using diagpath '"$h$n"'
- ~/sqllib/db2dump/HOST_bower/NODE0000/db2diag.log
- ~/sqllib/db2dump/HOST_bower/NODE0001/db2diag.log
- ~/sqllib/db2dump/HOST_bower/NODE0002/db2diag.log
- ~/sqllib/db2dump/HOST_horton/NODE0003/db2diag.log
- ~/sqllib/db2dump/HOST_horton/NODE0004/db2diag.log
- ~/sqllib/db2dump/HOST_horton/NODE0005/db2diag.log
db2diag -global
db2diag –global –merge –sdir /temp/keon –fmt %{ts}where /temp/keon is a shared directory, shared by the hosts bower and horton , to store temporary merged files from each host during processing.
![](http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.help.doc/images/concept_obj.gif)
( Feedback )
Last updated: 2009-12-14
http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/topic/com.ibm.db2.luw.admin.trb.doc/doc/c0020701.html