Tuesday, February 9, 2010

Playing around with db2diag

Over the past few days I have been playing with db2diag. It is the log analysis tool and it allows you to search, filter, and format the DB2 diagnostic logs. One of the simple examples is that I wanted to see when errors or warnings were produced on my test system. I could do that by calling:

db2diag -l Error,Warning -fmt "%ts %level %db"

This would only print the timestamp, the "error" level, and, if it was for a specific database, the database name.

2010-02-05-13.05.51.947000 Warning
2010-02-05-13.05.52.449000 Error PUREDB
2010-02-05-13.05.52.449000 Error PUREDB
2010-02-05-14.10.24.619000 Warning

The output is much quicker to digest than the diagnostic itself. And I could also use the output as input for some other scripts. Have you used db2diag in the past?