How to find available ports in the engine?

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf How to find available ports in the engine?

  • Creator
    Topic
  • #51788
    Sheetal Kairawala
    Participant

      Hello all,

      Does anybody know how to find the available ports in the cloverleaf engine?

      Thanks

      Sheetal

    Viewing 4 reply threads
    • Author
      Replies
      • #71753
        David Barr
        Participant

          You just need to pick a port that doesn’t conflict with anything else.

          You can use the “netstat” command to see which ports are currently in use.

          Don’t pick the port that the host server uses.

        • #71754
          Sheetal Kairawala
          Participant

            Thanks David

          • #71755
            Russ Ross
            Participant

              If I have a port number I want to use like 23456 and want to know if it is already in use I do the following steps on all my cloverleaf servers since we require all port numbers be unique across all our cloverleaf servers:

              list_ports.ksh | grep 23456

              grep 23456 /etc/services

              netstat -a | grep 23456

              In the future my dream list has me creating a list of all the available ports and when we want a new port we remove one from that list.

              As mentioned earlier stay away from using ports in the ephemeral range and if you don’t know what that means start by keeping all you port numbers less than 32768 (32K).

              Some places have designated certain port ranges for test and prod and I also like that idea even though it is too late for us.

              Here is the script list_ports.ksh I worte to help with seeing if a cloverleaf site is already using a given port number:

              #!/usr/bin/ksh
              #
              # Begin Module Header ==============================================================================
              #
              #——
              # Name:
              #——
              #
              # list_ports.ksh
              #
              #———
              # Purpose:
              #———
              #
              # list all the ports defined in the NetConfig for all sites
              #
              #——-
              # Notes:
              #——-
              #
              # Assumption:
              #
              # – all sites have a NetConfig file
              #
              # Normal Usage:
              #
              # list_ports.ksh > x.x
              #
              #———
              # History:
              #———
              #
              # 2001.01.30 Russ Ross
              #
              [code]#!/usr/bin/ksh
              #
              # Begin Module Header ==============================================================================
              #
              #


              # Name:
              #


              #
              # list_ports.ksh
              #
              #


              # Purpose:
              #


              #
              # list all the ports defined in the NetConfig for all sites
              #
              #


              # Notes:
              #


              #
              # Assumption:
              #
              # – all sites have a NetConfig file
              #
              # Normal Usage:
              #
              # list_ports.ksh > x.x
              #
              #


              # History:
              #


              #
              # 2001.01.30 Russ Ross
              #

              Russ Ross
              RussRoss318@gmail.com

            • #71756
              Russ Ross
              Participant

                I’m on AIX/Unix which has the lsof command which can be useful especially if you have a port conflict and need to find out what interface processes are in conflict.

                Here are some typical lsof example usages I’ve found handy:

                lsof -i tcp

                lsof | grep “port#”

                The second column of the lsof output is the process ID which can then be used something like this to see the names of the processes using that port

                ps -ef |grep “pid#”

                Here is an example I just ran on our test server to help illustrate:

                Code:


                (mdahub4:hci) /usr/local/scripts > lsof | grep 23312
                hciengine 1351730     hci   22u  IPv4   0xf100020003a4db98                0t0        TCP *:23312 (LISTEN)
                (mdahub4:hci) /usr/local/scripts > ps -ef |grep 1351730
                    hci  790700 2490522   0 15:32:59 pts/18  0:00 grep 1351730
                    hci 1351730 1192030   0   Mar 19      –  0:35 /quovadx/qdx5.6/integrator/bin/hciengine -S test_bdm_rxtfc -p ib_cs_allergy -s jr_cs_allergy_23312  
                (mdahub4:hci) /usr/local/scripts >

                From this example I would know to look in the test_bdm_rxtfc site at thread jr_cs_allergy_23312, which is in the ib_cs_allergy process.

                Russ Ross
                RussRoss318@gmail.com

              • #71757
                David Barr
                Participant

                  On Linux, you can use either “lsof” or “netstat -p” to find the process associated with an open connection.

              Viewing 4 reply threads
              • The forum ‘Cloverleaf’ is closed to new topics and replies.