db2top -d and db2top -h

Today, I’m going to start writing about db2top command line options. There are many. I’ll start with -h (help) and -d (database). The -h option gives you the key to all the others:

db2top -h
Licensed Materials - Property of IBM
Copyright IBM Corp. 2005, 2006 All Rights Reserved.

Usage: db2top [-d dbname] [-n nodename] [-u username] [-p password] [-V schema] [-i interval] [-P <part>]

[-a] [-B] [-R] [-k] [-x] [-f file <+time> ] [-b options [-s ] [-D separator] <-X>] -o outfile]] [-C] [-m duration]
db2top -h

-d : Database name (default DB2DBDFT)
-n : Node name
-u : User name
-p : User password
-V : Default explain schema
-i : Interval in seconds between snapshots
-b : background mode
option: d=database, l=sessions, t=tablespaces, b=bufferpools, T=tables, D=Dynamic SQL, s=Statements, U=Locks, u=Utilities, F=Federation, m=Memory -X=XML Output, -L=Write queries to ALL.sql, -A=Performance analysis
-o : output file for background mode
-a : Monitor only active objects
-B : enable bold
-R : Reset snapshot at startup
-k : Display cumulated counters
-x : Extended display
-P : Partition snapshot (number or current)
-f : Replay monitoring session from snapshot data collector file, can skip entries when +seconds is specified
-D : Delimiter for -b option
-C : Run db2top in snapshot data collector mode
-m : Max duration in minutes for -b and -C
-s : Max # of samples for -b
-h : this help

Parameters can be set in $HOME/.db2toprc, type w in db2top to generate resource configuration file

DB2 Interactive Snapshot Monitor V2.0
Build Jan 4 2010 17:37:09

Licensed Materials - Property of IBM
Copyright IBM Corp. 2005, 2006 All Rights Reserved.
US Government Users Restricted Rights
Use, duplication or disclosure restricted by GSA ADP Schedule Contract with IBM Corp.

Now let’s look at the -d switch. It takes one argument, which is the name of the database that you want db2top to report on. All the switches are optional, even this one. If you do not specify the -d switch, db2top will look up the database name specified in your .db2toprc file in your home directory and report on that database as if you had specified it for the -d switch. If you do not have a .db2toprc file, db2top will look up the database name specified in the DB2DBDFT registry variable. If your DB2DBDFT registry variable also does not exist (check this using db2set -all), you will get the error message:

*************************************************************************
***                                                                   ***
*** Error: Can't find database name                                   ***
***                                                                   ***
*************************************************************************

Otherwise, you will successfully start db2top.