List of ports in use

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf List of ports in use

  • Creator
    Topic
  • #49692
    Mark McDaid
    Participant

    What is the easiest way for me to get a list of all of the ports currently in use by the engine.

Viewing 18 reply threads
  • Author
    Replies
    • #63117
      Greg Eriksen
      Participant

      It might help to know which platform you are on, but for starters I think the netstat command will work on both Windows and AIX.  “netstat -a” or “netstat -an” (for ip numbers rather than DNS names) will probably give you a lot of output, so on AIX you could pipe it to grep (or redirect it to a temp file, and then grep that) to search to see if a particular number you want to use is in use.  On AIX you might also take a look at the /etc/services file to see port numbers that are already allocated for other use.  You can also check this website:

      http://keir.net/portlist.html

      for a list of commonly used port numbers you probably want to avoid.

    • #63118
      Mark McDaid
      Participant

      Greg,

      Thanks for the info.

    • #63119
      Bob Richardson
      Participant

      Greetings,

      You definitely want to avoid using ports that are reserved by convention with the networking community.  Also, for Cloverleaf Integrator starting with CIS5.3 (I believe?) you want to avoid the ephemeral range for multi-connect TCP/IP connections that you create in your sites – usually by default this is 32K thru 64K (configurable by your Operating Systems group).

      Ok.. beyond all that we have built a ksh script using awk to step through all the NetConfig files in each site and create a csv style file (comma delimited) to import into an Excel spreadsheet.  We run this for both Production and Test (we have two servers) and merge/sort them in an Excel spreadsheet.  Then pick a pair – for us, an even number for production; an odd number for test – that is not assigned.  As we are a CIS5.3 AIX5.2 shop, the sites are picked up in the code by reading the server.ini file for the environs values.

      Let me know if you would like the script for your evaluation.

      Enjoy.

    • #63120
      Mark McDaid
      Participant

      Wow, that’s funny that you said that, because I started writing a tcl script this morning that would parse the NetConfigs and give me a CSV file that I could import into Excel.  If you don’t mind sharing yours, I’d like to take a look at it.  Thanks.

    • #63121
      Bob Richardson
      Participant

      Folks,

      See attachment – if it does not show up then let me know and I will copy/paste the code into a post on this forum.

      By the way, the script was written by colleague, Ian Smith here at Allina.

      Enjoy.

      BobR

    • #63122
      Mark McDaid
      Participant

      Bob,

      Thank you very much.  Merry Christmas!  ðŸ˜€

    • #63123
      Bob Richardson
      Participant

      Folks,

      I donwloaded the attachment in my previous post and all the line terminators are scrubbed out.  So here is the human readable version.

      Enjoy.

      #!/bin/ksh

      # generate_port_doco.sh

      # the variable ROOT_LIST is set in .profile.local.end

      # If this is null, use $HCIROOT as the ROOT_LIST

      # Parse the environs line from $ROOT/server/server.ini for a list of all sites

      # Read through each site’s NetConfig and create a csv report

      # detailing Site, Thread, Host, Port, Client/Server

      HOSTNAME=`hostname`

      if -z $ROOT_LIST ; then

          ROOT_LIST=$HCIROOT

      fi

      echo “CLHost,Site,Thread,Host,Port,Client/Server” > ${HOSTNAME}_port_doco.csv

      for ROOT in $ROOT_LIST

      do

      for SITE in `awk -F = ‘/^environs/ { gsub(“;”,”n”,$2);print $2 }’ $ROOT/server/server.ini`

      do

      awk ‘

      /^protocol/  { ThreadName=$2 ; next }

      /HOST /      { sub(“{}”,”EMPTY”,$3) ; Host=$3 ; next }

      /ISSERVER 0/ { ClSrv=”CLIENT” ; next }

      /ISSERVER 1/ { ClSrv=”SERVER” ; next }

      / PORT/      { Port=$3 ; next }

      /tcpip/ { print ClHost”,”SiteName”,”ThreadName”,”Host”,”Port”,”ClSrv }

      ‘ SiteName=${SITE##*/} ClHost=$HOSTNAME $SITE/NetConfig >> ${HOSTNAME}_port_doco.csv

      done

      done

    • #63124
      Charlie Bursell
      Participant

      Seems to me if all you wanted were the ports and on Unix

         find $HCIROOT -name NetConfig -exec grep PORT {} ;

      would work.

      For those that are on Windows or want a Tcl solution for the task, I have enclsoed a simple little script.  If not on Windows remove the .htc extension.

    • #63125
      Russ Ross
      Participant

      Robert H Richardson:

      I wrote something crude also but never took it as far as I wanted.

      I ran your posted script and like the output better than mine for where I want to eventually go, which is to populate an extra column in our web stats page to list the port number of each thread.

      Since we are interested in boiling it down to port numbers in use, there is an extra step I want to eventually program (hint: maybe you will do it for me  ðŸ˜‰  ).

      If the NetConfig is using an alias name for a port, then its port number will be defined in the /etc/services file.

      It would be nice to replace the port alias name with the actual port number of that alias for display purposes.

      Russ Ross
      RussRoss318@gmail.com

    • #63126
      Mark McDaid
      Participant

      Charlie,

      I tried running findPorts.htc on our server (Windows platform) and it runs fine, no errors, prints the column headers, but there are no results.  I’ve looked through the script and am not sure what I am doing wrong.  The root and site are set when I run the script.  I do appreciate your posting this script for use.  Thanks.

    • #63127
      Russ Ross
      Participant

      I had the same problem with the findPorts.htc script and debugged down to where it is setting the sites using the server.ini file.

      After executing this command

      regexp — {nenvirons=(.*?)n} $iniData {} sites

      the sites variable is null and that is why I think we are not getting any stuff displayed because the following loop to do each site has a null list

      foreach site $sites {

      I’m not good with regexp off the top of my head and I’m telecommuting today so not likely I can determine any possible regexp issue today.

      Russ Ross
      RussRoss318@gmail.com

    • #63128
      Mark McDaid
      Participant

      I’m not good with regexp either, but at least now I know where to start looking.  Thanks for the info.

    • #63129
      Bob Richardson
      Participant

      Greetings,

      Russ Ross and company,

      I have attached a hcitcl version of our find port doco script that was previously posted to this forum under this topic.  If you use /etc/services

      for port aliases, this would be more adaptable to doing a search of that file (maybe read it into an array with the alias as the subscript?).  We do not use aliases for our ports in our shop here – can’t get the guys to buy into it right now.

      Again, colleague Ian Smith, crafted this script along with the ksh version.

      It actually runs a bit faster if you use the Unix utility ‘time’

      Hopefully it prove useful to you folks.

      Enjoy.

    • #63130
      Charlie Bursell
      Participant

      I left out a statement to handle the last, nul site.

      foreach site $sites {

         if {[lempty [string trim $site]]} {continue}

      Add the abone

    • #63131
      Mark McDaid
      Participant

      Charlie,

      I added the line of code:

                   if {[lempty [string trim $site]]} {continue}

      just inside the foreach site $sites loop and still get the same, no results listed.  I’ve tried printing the contents of the sites list and it appears that the list is empty.

    • #63132
      Mark McDaid
      Participant

      I just figured out why it wasn’t working.  I changed this line of code:

                        regexp — {nenvirons=(.*?)n} $iniData {} sites

      to this:

                        regsub — {nenvirons=(.*?)n} $iniData {} sites

      and now it works.

    • #63133
      Russ Ross
      Participant

      Mark:

      I did get better reults by doing what you suggested but it still mishandled the first site in the list of sites.

      When I used hcitcl to do some simple tests to debug, the regexp that Chalie used seemed to work but I eventually found an assumption that was not always true.

      The logic expects the (environs=) entry in the server.ini file to be terminated with n.

      This assumption will be incorrect when the (environs=site_1;site_2;…;site_N) entry is the last entry in the server.ini file and read in using the -nonewline option.

      Realizing this I cheked on how the file was read in by the script and sure enough it was using the -nonewline option.

      Knowing this made it a simple matter to get Charlie’s post of findPorts.htc to work at MD Anderson Cancer Center by changing the following line from

      set iniData [read_file -nonewline $iniPath]

      to

      set iniData [read_file $iniPath]

      The regexp used later in the script is looking for new-line as a terminator and will not find one if the (envorns=site1;site2;…;siteN) entry is the last entry in the server.ini file which is true in my case.

      Russ Ross
      RussRoss318@gmail.com

    • #63134
      Charlie Bursell
      Participant

      Good point Russ.  You can’t think of everything  ðŸ™‚

    • #63135
      Mark McDaid
      Participant

      Yeah, I discovered the problem with the first site after ‘environs= ‘ and to get around it I just used the siteName that was stripped off the end and then hard coded the join “C:/quovadx/qdx5.2/integrator” $siteName NetConfig.

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

Forum Statistics

Registered Users
5,125
Forums
28
Topics
9,294
Replies
34,439
Topic Tags
287
Empty Topic Tags
10