5/01/2016

Troubleshooting tools for Performance Tuning: Analyzing db2diag log files using db2diag tool

Primary log files are for the use of database and administration notification log are for system administrators. The db2diag log files are for the use of IBM Software Support for troubleshooting.

Even administration notification log messages are also logged to the db2diag log files.

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 multiple databases in the instance we can get a diag log details by the database name using below command.

db2diag -g db=SAMPLE

db2diag

Example 2: Filtering the db2diag log files by process ID

The following command can be used to display all severe error messages produced by processes running on partitions 0,1,2, or 3 with the process ID (PID) 2200: 

db2diag -g level=Severe,pid=2200 -n 0,1,2,3


Example 3: Formatting the db2diag tool output

The following command filters all records occurring after January 1, 2006 containing non-severe and severe errors logged on partitions 0,1 or 2. It outputs the matched records such that the time stamp, partition number and level appear on the first line, pid, tid and instance name on the second line, and the error message follows thereafter: 

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"
For more information, issue the following commands:
  • 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

The following examples show how to only see messages from a specific facility (or from all of them) from within the database manager. The supported facilities are:

  • 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
  • OPTSTATS which returns records related to optimizer statistics
To read messages from the MAIN facility:
db2diag -facility MAIN

To display messages from the OPTSTATS facility and filter out records having a level of Severe:
db2diag -fac OPTSTATS -level Severe
db2diag

To display messages from all facilities available and filter out records having instance=harmistr and level=Error:
db2diag -fac all -g instance=harmistr,level=Error
db2diag

To display all messages from the OPTSTATS facility having a level of Error and then outputting the Timestamp and PID field in a specific format:
db2diag -fac optstats -level Error -fmt " Time :%{ts} Pid :%{pid}"

db2diag

Example 5: Archiving the db2diag log files

You can use the db2diag -archive (or -A) option, to archive the diagnostic log file on an instance-less client. 
For example:
db2diag


0 comments:

Post a Comment

ads