Db2

Db2

Connect with Db2, Informix, Netezza, open source, and other data experts to gain value from your data, share insights, and solve problems.

 View Only
Expand all | Collapse all

Db2 for Linux 11.5 and Datadog

  • 1.  Db2 for Linux 11.5 and Datadog

    Posted Tue April 01, 2025 10:35 AM

    Hello,

    we are using Datadog to monitor our Db2 for Linux 11.5 fp 9 database server. Datadog and Db2 are managed as a Linux service to start and stop them. We have noticed that when the server reboots Db2 gets error ADM7007E on the listener tcp/ip port and nobody is able to connect to the database via listener, using netstat we see the listener port in TIME_WAIT instead LISTENING. We have found that if Datadog starts immediately after Db2 it binds the Db2 listener and put it in TIME_WAIT status; as workaround we have delayed 60 seconds the Datadog service startup (added ExecStartPre=/bin/sleep 60 in Datadog service) so Db2 has enough time to complete its startup procedure and put the listener port in LISTENING.

    Has anyone already experienced the behaviour described above ? if yes, how fixed it ?

    Thanks in advance. Ciao. Roberto



    ------------------------------
    Roberto Stradella
    ------------------------------


  • 2.  RE: Db2 for Linux 11.5 and Datadog

    Posted Fri April 04, 2025 03:35 AM

    Just a suggestion - can you specify that Datadog service is dependent on Db2 service?



    ------------------------------
    Jan Nelken
    Support engineer
    Persistent Systems Ltd
    Cracow
    +48 783 109 863
    ------------------------------



  • 3.  RE: Db2 for Linux 11.5 and Datadog

    Posted Fri April 04, 2025 05:49 AM

    Hello Jan, thanks for the answer.

    In datadog service we have:

    [Unit]
    After=network.target db2fmcd.service
     
    [Service]
    ExecStartPre=/bin/sleep 60
    without the sleep 60 the Db2 listener is not operable.
    In our environment we have multiple Db2 Instances and we are trying to avoid to update the datadog.service every time we add or remove a Db2 Instance.
    Thanks. Ciao. Roberto


    ------------------------------
    Roberto Stradella
    ------------------------------



  • 4.  RE: Db2 for Linux 11.5 and Datadog

    Posted Fri April 04, 2025 06:07 AM
    Edited by Jan Nelken Fri April 04, 2025 06:08 AM

    Hi Roberto,

    What I had in mind was that in BGV (Bill Gates Virus) you can specify dependencies of the services; I am not sure whether those dependencies are observed during startup: if service X depends on service Y - then service X won't be started until service Y is started - or those dependencies are only existential: - if service Y is absent then service X won't start.



    I was wondering whether Linux service manager has similar controls - or you need to have home-grown service starter which has to be configured with dependencies info.

    Just my 2 cents ... (CDN)



    ------------------------------
    Jan Nelken
    Support engineer
    Persistent Systems Ltd
    Cracow
    +48 783 109 863
    ------------------------------



  • 5.  RE: Db2 for Linux 11.5 and Datadog

    Posted Mon April 07, 2025 09:09 AM

    Hi,

    you are inquiring about the various service dependencies in a Linux environment. The major service managers like systemd and init.d in Linux have built-in support for defining dependencies related to services.

    Systemd Dependency
    In systemd, you may use After and Requires directives in the service file to specify the dependencies.

    Types of Dependency
    There are actually two kinds of dependencies:

    1. A hard dependency: the service does not start when the dependent service is not running.
    2. A soft dependency: The service will start but may not run correctly with the dependent service not running.



    ------------------------------
    Suman
    Jhajjar, Haryana, India
    ------------------------------



  • 6.  RE: Db2 for Linux 11.5 and Datadog

    Posted Fri April 04, 2025 07:53 AM
    Hello.
     
    ADM7007E means that something listens DB2 port when it tries to do the same on its startup.
    Is there any chance, that this Datadog service tries to start listening DB2 port instead of connecting to it?
     
    You may try to check it, for example, with a startup script like below.
    #!/bin/bash
     
    PORT=${1?"Port must be specified"}
    SEC=${2?"Max seconds to run must be specified"}
    start=${SECONDS}
     
    while [ $((SECONDS-start)) -lt ${SEC} ]; do
      str=$(netstat -nlp | grep ":${PORT} ") && echo "$(date +'%F-%H.%M.%S'): ${str}"
    done
     
    You may put its call into some unit file starting before the db2fmcd.service like this:
     
    ExecStart=sh -c "/path/to/script/check_port.sh 25000 180 > /tmp/db2port_usage.log"
     
     
    Note, that db2fmcd doesn't immediately start any DB2 instance.
    db2fmcd is a daemon which just checks if some DB2 instance (you may have a number of them in the system) must be started, and it may really start your DB2 instance after some hardly predicted delay.



    ------------------------------
    Mark Barinstein
    ------------------------------



  • 7.  RE: Db2 for Linux 11.5 and Datadog

    Posted Fri April 04, 2025 07:58 AM

    Mark,
    I think that Datadog intercepts the port Db2 is listening on - using sort of MiM (Man in the middle) approach - so it listens on Db2 port, intercepts and analyses requests and passes it to Db2 when approved. One way to verify it is to check what port Db2 listens to after successful Datadog and Db2 startup.



    ------------------------------
    Jan Nelken
    Support engineer
    Persistent Systems Ltd
    Cracow
    +48 783 109 863
    ------------------------------



  • 8.  RE: Db2 for Linux 11.5 and Datadog

    Posted Fri April 04, 2025 09:11 AM

    Hello,

    thanks for the answers you provide me. We are currently doing problem determination, we have found that it is not a problem related to reboot only but occurs also when we restart an instance. If datadog service is up and running and we perform db2stop + db2start the db2start shows the following message:

    FUNCTION: DB2 UDB, common communication, sqlcctcpconnmgr, probe:46

    MESSAGE : ADM7007E The SVCENAME DBM configuration parameter, "50012", is configured with a port or a service name. When it is configured with a service name, the TCP/IP services files is used to map the service name to a port number. The port specified in this field is being used by another process. Resolve this problem by either deleting the process using the port or use another port.

    This is what we have seen on our system:

    Db2 instance (db2sysc) and datadog service is up and running:

    ss -tanp | grep 50010

    ESTAB     0      0      172.29.112.12:50010   172.29.112.10:39024 users:(("db2sysc",pid=2354,fd=1614))

    Db2 instance (db2sysc) has been stopped:

    ss -tanp | grep 50010

    TIME-WAIT 0      0              [::1]:50010           [::1]:50010 

    Db2 instance (db2sysc) has been restarted

    ADM7007E The SVCENAME DBM configuration parameter, "50012", is configured with a port or a service name. When it is configured with a service name, the TCP/IP services files is used to map the service name to a port number. The port specified in this field is being used by another process. Resolve this problem by either deleting the process using the port or use another port.

    ss -tanp | grep 50010

    TIME-WAIT 0      0              [::1]:50010           [::1]:50010

    Datadog seems that one time it binds the listener port never release it.

    Thanks. Ciao. Roberto



    ------------------------------
    Roberto Stradella
    ------------------------------



  • 9.  RE: Db2 for Linux 11.5 and Datadog

    Posted Fri April 04, 2025 11:38 AM

    Roberto,

    I was looking for more information about Datadog agent - I couldn't find on Datadog site anything about Db2 as a supported monitored database - am I looking for a wrong Datadog site?

    https://docs.datadoghq.com/database_monitoring/



    ------------------------------
    Jan Nelken
    Support engineer
    Persistent Systems Ltd
    Cracow
    +48 783 109 863
    ------------------------------



  • 10.  RE: Db2 for Linux 11.5 and Datadog

    Posted Fri April 04, 2025 12:44 PM

    Hello Jan,

    here you can find info about monitoring IBM DB2 with Datadog:

    https://docs.datadoghq.com/integrations/ibm_db2/?tab=host

    https://www.datadoghq.com/blog/monitor-db2-with-datadog/

    Thanks. Ciao. Roberto



    ------------------------------
    Roberto Stradella
    ------------------------------



  • 11.  RE: Db2 for Linux 11.5 and Datadog

    Posted Fri April 04, 2025 09:24 AM
    Edited by Mark Barinstein Fri April 04, 2025 09:28 AM

    Jan,

    AFAIK DB2 doesn't use the SO_REUSEPORT socket option when it binds to its port.
    For example, you can use 2 netcat instances like `nc -lv 25000` from different sessions, since `nc` uses this option.
    But if you run `nc -lv 25000` and a db2 instance listening the same port, you get an error from anyone started last (DB2 returns ADM7007E).
    There are no any other "socket intercept" ways.

    So, if Datadog really tries to listen DB2 service port, then it's an inappropriate behavior.



    ------------------------------
    Mark Barinstein
    ------------------------------



  • 12.  RE: Db2 for Linux 11.5 and Datadog

    Posted Mon April 14, 2025 01:03 PM
    Hello Jan and Mark,
    we have fixed the problem (thanks to IBM Db2 support that pointed me to it): we are using Datadog and Db2 in the same Linux server and are doing local connection with Db2 via localhost (127.0.0.1). The /etc/datadog-agent/conf.d/ibm_db2.d/conf.yaml was configured as follows:
     
    - db: <db name>
        username: <datadog userid>
        password: <password>
        port: 50004
        host: localhost
     
    changing the host value from localhost to the server ip address the listener never goes in TIME-WAIT state, Datadog waits until the lister goes to LISTEN state before to try to connect to the database.
    Thanks a lot for the help provided. Ciao. Roberto.


    ------------------------------
    Roberto Stradella
    ------------------------------