› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › List of ports in use
for a list of commonly used port numbers you probably want to avoid.
Thanks for the info.
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.
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
Thank you very much. Merry Christmas! 😀
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
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.
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
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.
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
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.
foreach site $sites {
if {[lempty [string trim $site]]} {continue}
Add the abone
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.
regexp — {nenvirons=(.*?)n} $iniData {} sites
to this:
regsub — {nenvirons=(.*?)n} $iniData {} sites
and now it works.
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
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