Homepage › Clovertech Forums › Cloverleaf › NetConfig Parse – Basic
- This topic has 11 replies, 4 voices, and was last updated 1 year, 4 months ago by JD.
-
CreatorTopic
-
May 18, 2023 at 10:36 am #120561JDParticipant
Hello – I’m trying to get familiar with how to parse the NetConfig file. Tried the commands below to try and access PORT information, and got errors. I think I’m using the right commands. Any details on what I’m doing wrong or on a better way to access basic NetConfig information are very much appreciated.
[dev_pt_mgmt]$ tcl
tcl>netconfig load
1
tcl>netconfig get version
3.20
tcl>netconfig get connection list
to_masimo_NPE_adt to_collectivemed_adt to_iecg_adt …..tcl>keylget to_masimo_NPE_adt PROTOCOL.PORT
Error: can’t read “to_masimo_NPE_adt”: no such variable
tcl>keylkeys to_masimo_NPE_adt
Error: can’t read “to_masimo_NPE_adt”: no such variable
tcl>- This topic was modified 1 year, 5 months ago by JD.
-
CreatorTopic
-
AuthorReplies
-
-
May 18, 2023 at 10:45 am #120563James CobaneParticipant
Attached is a script you can use for reference that pulls connection info from NetConfig. I had to add the .txt extension to get it to upload. Per Infor, future direction to get this type of info is via the Cloverleaf API (CLAPI), but I have not utilized that functionality yet.
Hope this helps.
Jim Cobane, Henry Ford Health
- This reply was modified 1 year, 5 months ago by James Cobane.
Attachments:
You must be logged in to view attached files.-
May 18, 2023 at 11:55 am #120568JDParticipant
Hello – thanks! Works great! A great reference for sure. Ideally need to capture site, process, source information (name, ip, port) , destination information (name, ip, port), xlate info, tcl info all in one line/record; your script seems like great starting place. Thanks again.
-
May 18, 2023 at 11:17 am #120566Jim KosloskeyParticipant
Here is what I coded using the API:
[catch {netconfig load $hciroot/$site_name/NetConfig} err] (use your site name in place of the variable $site_name)
The above loads the NetConfig and uses a catch in case there is an error.
Then:
[catch {set list_thread_names [netconfig get connection list]} err] <– This gets a list of the connections in the NetConfig.
Then:
Inside a foreach (working over the above list of connections)…
[catch {set list_thread_details [netconfig get connection data $thread_name]} err] <– gets the thread details.
set port_elem [keylget list_thread_details PROTOCOL.PORT] <– gets the PORT number/mnemonic
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
-
May 18, 2023 at 11:54 am #120567JDParticipant
Hello – thanks! Works great! A great reference for sure. Ideally need to capture site, process, source information (name, ip, port) , destination information (name, ip, port), xlate info, tcl info all in one line/record; your script seems like great starting place. Thanks again.
-
May 19, 2023 at 11:38 am #120573JDParticipant
Hello – found that I was missing one command in the sequence I was originally testing.
[dev_pt_mgmt]$ tcltcl>netconfig load1tcl>netconfig get version3.20tcl>netconfig get connection listto_masimo_NPE_adt to_collectivemed_adt to_iecg_adt …..///// was missing this commandtcl> set to_masimo_NPE_adt [netconfig get connection data to_masino_NPE_adt]{ AUTOSTART 1 }{ BITMAP {} }{ COORDS {0 0} }{ DATAFORMAT {{ FRLTYPE offlen }{ OFFLEN {{ LEN 0 }. . .tcl>keylget to_masimo_NPE_adt PROTOCOL.PORT10974tcl> keylkeys to_masimo_NPE_adtAUTOSTART BITMAP COORDS. . .tcl> -
May 25, 2023 at 11:07 pm #120590JDParticipant
Hello – still having some issues with the NetConfig read/parse script that I have been “playing” with. The script is based on feedback/input from this forum and its highly appreciated.
The script is mostly fuctional (?! 🙂 ), but it hits an error when the NetConfig that is being read/parsed has references to global variables. I’ve tried a few suggestions found in the forum, but I can’t get this to work.
For example, if setsite is set to dev_lab, and I ran the script the script throws errors when it reads the NetConfig for the devcb2a site because the NetConfig for devcb2a has references to global variables, but the global variables don’t exist in the dev_lab site or environment (at least that’s what I think the issue is). I believe I need to set the site to the site that corresponds to the NetConfig that is being read/parsed. How can I change or set the site (setsite) environment to the appropriate site? Thanks in advance.
Script segment below:
#!/bin/env tcl
#####################################################################
# need to reditect output to file to capture output
# based on clovertech sample
# Tcl program to obtain Routing info for each thread
# Author: James Cobane
#####################################################################global hciRoot global hciSite
global siteDirset hciRoot $env(HCIROOT)
set hciSite $env(HCISITE)
set siteDir $env(HCISITEDIR)set netConfigName [lindex $argv 0]
netcfgLoad $netConfigName
set connList [lsort [netcfgGetConnList]]
#jd
#headings
puts “Site#Process#SourceThrd#IbHost#IbPort#IbType#IbAutoStrt#IsSrvr#IbDirParseProc#IbFtpDir#SrcInDataProc#SrcOutDataProc#TrxID#RawRtProc#XlPreProc#XlPostProc#XlType#Xlate#DestThrd#ObHost#ObPort#ObType#ObAutoStrt#ObIsSrvr#ObFtpDir#DestInDataProc#DestOutDataProc”
#jd end
#set site1 “dev_misc”
set site1 “devcb2a”##if ![catch {netcfgLoad} err] {
##NCFG:ChangeSite $site1
##puts “>>>> CHANGING SITE pre netconfig load<<<<<”
##netcfgLoad
##puts “>>>> post netconfig load<<<<<”
##}
##exitset siteList [lsort $site1]
foreach site $siteList {
if ![catch {netcfgLoad $hciRoot/$site/NetConfig} err] {
NCFG:ChangeSite $site
netcfgLoad
if [string equal $err “1”] {
puts “>>>> $site ERROR HERE?!?! $err <<<<<”
exit
}
.
.
. -
May 26, 2023 at 9:24 am #120591Jim KosloskeyParticipant
Here is how I did it:
#Do the switch
set ret_cd [catch {eval [exec ${::env(HCIROOT)}/sbin/hcisetenv -site tcl $sitename]} err]
if {$ret_cd} {
echo “$module Switch to site >$sitename< failed…”
echo “$module with error >$err<. Aborting!”
return 0
}
return 1$sitename was gathered elsewhere.
The above code is actually part of a proc invoked by other procs specifically to switch to a specific site for the invoking proc to do its work.
- This reply was modified 1 year, 4 months ago by Jim Kosloskey. Reason: corrected spelling
email: jim.kosloskey@jim-kosloskey.com 29+ years Cloverleaf, 59 years IT - old fart.
-
May 26, 2023 at 11:27 am #120593JDParticipant
Hello – thanks for the code. I tried running a test, but still having probs. Below is that I have tested, and the output of the run. I run the script when setsite is “dev_lab”. Running CL version 20.1. Thanks
#!/bin/env tcl
#####################################################################
# need to reditect output to file to capture output
# based on clovertech sample
# Tcl program to obtain Routing info for each thread
# Author: James Cobane
##########################################################global hciRoot global hciSite
global siteDirset hciRoot $env(HCIROOT)
set hciSite $env(HCISITE)
set siteDir $env(HCISITEDIR)set netConfigName [lindex $argv 0]
netcfgLoad $netConfigName
#set connList [lsort [netcfgGetConnList]]#jd
#headings
puts “Site#Process#SourceThrd#IbHost#IbPort#IbType#IbAutoStrt#IsSrvr#IbDirParseProc#IbFtpDir#SrcInDataProc#SrcOutDataProc#TrxID#RawRtProc#XlPreProc#XlPostProc#XlType#Xlate#DestThrd#ObHost#ObPort#ObType#ObAutoStrt#ObIsSrvr#ObFtpDir#DestInDataProc#DestOutDataProc”
#jd end
#set site1 “dev_misc”
set site1 “devcb2a”# from clovertech
set ret_cd [catch {eval [exec ${::env(HCIROOT)}/sbin/hcisetenv -site tcl $site1]} err]
sleep 1
if {$ret_cd} {
echo “>>> Switch to site >$site1< failed… EXITING <<<”
exit
}if ![catch {netcfgLoad $hciRoot/$site1/NetConfig} err] {
if {$err} {
puts “>>> Failed to load NetConfig >$site1< failed EXITING <<< ”
exit
}
set connList [lsort [netcfgGetConnList]]
echo “CONN LIST: ” $connList
}
exit=== output ====
[hci WIP]$ ./tpsTest.tcl
Site#Process#SourceThrd#IbHost#IbPort#IbType#IbAutoStrt#IsSrvr#IbDirParseProc#IbFtpDir#SrcInDataProc#SrcOutDataProc#TrxID#RawRtProc#XlPreProc#XlPostProc#XlType#Xlate#DestThrd#ObHost#ObPort#ObType#ObAutoStrt#ObIsSrvr#ObFtpDir#DestInDataProc#DestOutDataProc
Global variable name ‘ukg’ not found
Global variable name ‘ukg_login’ not found
Global variable name ‘lawprod’ not found
Global variable name ‘lawprod’ not found
Global variable name ‘lawprod’ not found
Global variable name ‘lawprod’ not found
Global variable name ‘lawprod’ not found
Global variable name ‘lawprod’ not found
Global variable name ‘ftp_proview’ not found
Global variable name ‘ftp_gempos’ not found
Global variable name ‘lawprod’ not found
Global variable name ‘ftp_proview’ not found
>>> Failed to load NetConfig >devcb2a< failed EXITING <<<
-
May 26, 2023 at 10:51 pm #120594Charlie BursellParticipant
A lot of superfluous stuff going on 🙂
I have never been able to successfully set sites from a Tcl proc. If you want to do multiple site just use the site.ini file.
set root $::env(HCIROOT)
# read server.ini
set ini [read_file -nonewline [file join $root server server.ini]]# Get the environs line ( list of sites separated by 😉
set envStr “”
regexp -line {^environs=(.*?)$} $ini {} envStr# If you want error checking then if envStr empty, something wrong
# Full path of sites in a list
foreach site [split $envStr \;] {
# Note that file join will convert backslashes to forward if on Windows
netcfgLoad [file join $site NetConfig]
set connList [lsort [netcfgGetConnList]]echo \n\nSite $site Connections:
foreach conn $connList {echo \t$conn}
echo \n}
I will let you add the code you want to this. I hope it helps
-
-
AuthorReplies
- You must be logged in to reply to this topic.