0

On Db2 v11.5.7.0 I would like to enable CLI trace and perform some tests.

From official IBM documentation, CLI tracing can be done in two ways:

a) dynamic

b) with db2clini

A. DYNAMIC

  1. According to CLI documentation I did: db2trc on -cli -f dumpFile It returned: "Trace is turned on". I see file "dumpFile" is created with 465456 bytes.

  2. Now I am reproducing the problem. But dumpFile does not increases in size at all. It looks like nothing is traced.

  3. Turing off trace: db2trc off Output: "Trace is turned off".

  4. Format from binary to readable file: db2trc fmt -cli dumpFile clitrcfile.txt and output is:

    Trace truncated : NO

    Trace wrapped : NO

    Total number of trace records : 0

Nothing has been captured.

B: WITH DB2CLI.INI

Now to db2cli.ini documentation:

db2 UPDATE CLI CFG FOR SECTION COMMON USING Trace 1
db2 UPDATE CLI CFG FOR SECTION COMMON USING TracePathName C:\trace
db2 UPDATE CLI CFG FOR SECTION COMMON USING TraceComm 1
db2 UPDATE CLI CFG FOR SECTION COMMON USING TraceFlush 1
db2 UPDATE CLI CFG FOR SECTION COMMON USING TraceTimeStamp 3

Now reproduce the problem and turn off tracing.

db2 UPDATE CLI CFG FOR SECTION COMMON USING Trace 0

Nothing has been captured.

UPDATE: What is my problem? I have establish SSL between Db2 client and Db2 server using CLI. I can confirm with Wireshark network sniffing tool that SSL is really working. Now I would like to add hostname validation for CLI applications. From my database alias test1 I have added hostname validation:

db2 "UPDATE CLI CONFIGURATION FOR SECTION test1 USING SSLClientHostnameValidation Basic"

Now when I test the connection: db2 connect to test1 user using connection works true, but it shouldn't, because at Db2 client I have cataloged "localhost" to point to my virtual machine Db2 server, but in SSL certificate's Subject Alternative Name is my FQDM. If host validation if performed then connection should fail.

Now to the part of "reproducing problem". In the same window that "db2trc" or "db2 update cli" commands are executed I have executed "db2 connect to test1 user myuser using pass" and no CLI traces were produced.

6
  • Now reproduce the problem -- what is the problem, and how exactly are you reproducing it? Sorry about stating the obvious, but details are not in your question: you are enabling the trace in the same session on the client where you execute your CLI application, right?
    – mustaccio
    Commented Sep 6, 2022 at 12:35
  • I have updated the main post.
    – folow
    Commented Sep 6, 2022 at 13:08
  • db2 is not a CLI application; db2bp ("bp" stands for "background process"), which you can see among the running processes, is. You can also try db2cli instead.
    – mustaccio
    Commented Sep 6, 2022 at 13:10
  • I figure it out I can trace the process by specifying db2bp proces ID, but without "-cli" parameter. I tried: db2trc on -p <pid> -f dumpFile and trace is successfully created. In trace I can't find anything useful related to hostname validation. It is possible that hostname validation is not implemented for db2bp process. Maybe it is implemented only for CLI applications and ODBC applications. But I don't have any ODBC or CLI tool to test (I only use JDBC like tools).
    – folow
    Commented Sep 7, 2022 at 10:54
  • Why would the Db2 CLI driver do hostname validation? It's the responsibility of the underlying transport protocol (e.g. TCP/IP).
    – mustaccio
    Commented Sep 7, 2022 at 11:48

1 Answer 1

0

I have tested several options and for my case the best think working is the following procedure:

  1. Open two db2cmd programs with "Run as administrator".

  2. On Windows Db2 client kill all of the db2bp.exe processes: taskkill /F /IM db2bp.exe

  3. In one of db2cmd windows execute dummy command e.g. "db2 connect reset" in order that db2bp.exe process is created.

  4. Get the process ID of new created db2bp.exe. tasklist | find "db2bp.exe"

  5. In second column from previous command there is PID displayed, that we need the following command. In second db2cmd execute command: db2trc on -p <PID> -f trace.dmp

  6. Now back to first db2cmd window and reproduce what is desired to be included in trace file like true CLI validation: db2cli validate -dsn <db> -connect -user <user> -passwd <password>

  7. When previous step is finished go back to second db2cmd window and stop the trace: db2trc off

  8. Format traces:

db2trc flw -t -wc trace.dmp trace.flw

db2trc fmt trace.dmp trace.fm

db2trc fmt -c trace.dmp trace.fmtc

Three files are generated with detailed trace info included.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.