Homepage › Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › List of ports in use
- This topic has 19 replies, 5 voices, and was last updated 16 years, 9 months ago by Mark McDaid.
-
CreatorTopic
-
December 11, 2007 at 8:58 pm #49692Mark McDaidParticipant
What is the easiest way for me to get a list of all of the ports currently in use by the engine. -
CreatorTopic
-
AuthorReplies
-
-
December 11, 2007 at 9:17 pm #63117Greg EriksenParticipant
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: for a list of commonly used port numbers you probably want to avoid.
-
December 12, 2007 at 2:03 pm #63118Mark McDaidParticipant
Greg, Thanks for the info.
-
December 12, 2007 at 4:41 pm #63119Bob RichardsonParticipant
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.
-
December 12, 2007 at 4:46 pm #63120Mark McDaidParticipant
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. -
December 12, 2007 at 5:12 pm #63121Bob RichardsonParticipant
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
-
December 12, 2007 at 5:16 pm #63122Mark McDaidParticipant
Bob, Thank you very much. Merry Christmas! 😀
-
December 12, 2007 at 5:18 pm #63123Bob RichardsonParticipant
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
-
December 12, 2007 at 9:28 pm #63124Charlie BursellParticipant
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.
-
December 13, 2007 at 1:59 pm #63125Russ RossParticipant
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 -
December 13, 2007 at 2:54 pm #63126Mark McDaidParticipant
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.
-
December 13, 2007 at 3:03 pm #63127Russ RossParticipant
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 {} sitesthe 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 -
December 13, 2007 at 3:06 pm #63128Mark McDaidParticipant
I’m not good with regexp either, but at least now I know where to start looking. Thanks for the info. -
December 13, 2007 at 3:07 pm #63129Bob RichardsonParticipant
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.
-
December 13, 2007 at 3:17 pm #63130Charlie BursellParticipant
I left out a statement to handle the last, nul site. foreach site $sites {
if {[lempty [string trim $site]]} {continue}
Add the abone
-
December 13, 2007 at 3:39 pm #63131Mark McDaidParticipant
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.
-
December 13, 2007 at 3:54 pm #63132Mark McDaidParticipant
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.
-
December 13, 2007 at 5:53 pm #63133Russ RossParticipant
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 $iniPath]-nonewlineto
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 -
December 13, 2007 at 7:29 pm #63134Charlie BursellParticipant
Good point Russ. You can’t think of everything 🙂 -
December 13, 2007 at 8:00 pm #63135Mark McDaidParticipant
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.
-
-
AuthorReplies
- The forum ‘Cloverleaf’ is closed to new topics and replies.