Clovertech
› Clovertech Forums › Read Only Archives › Cloverleaf › Cloverleaf › Need utility for listing which threads use a given proc
Have a need for a utility which when given a proc name will list all threads which use it.
Has anyone written something like this and is willing to share it?
This proc returns an alphabetical tcl list of thread names defined in NetConfig.
proc getProcThreads {process} {
global HciSiteDir global hostData
if ![array exists hostData] { set netconfig [file join $HciSiteDir NetConfig] nfLoad $netconfig processData hostData xlateData NetFilePrologue }
set outList {} set threads [lsort -dictionary [array names hostData]] foreach thread $threads { set kl [list [array get hostData $thread]] set threadKeys [keylget kl $thread]
if ![string equal -nocase [keylget threadKeys PROCESSNAME] $process] {continue}
lappend outList $thread
} return $outList
}
Cheers
Chris
I grep the NetConfig for the proc or I edit it and do a search.
Give this a shot.
global env
if {$argc != 1} { puts “” puts “”procbythread puts “” exit } set procname [lindex $argv 0]
set fh [open $env(HCISITEDIR)/NetConfig “RDONLY”]
while 1 {
if {[eof $fh]} {break} set len [gets $fh line]
if {[string first “protocol” $line] == 0} { set threadname [lindex [split $line ” “] 1] } if {[string first [string toupper $procname] [string toupper $line]] >= 0} { puts “$threadname: $line” }
Save is as something like procbythread.tcl, set you site, and run it like:
hcitcl procbythread.tcl tps_log_hl7