Need utility for listing which threads use a given proc

Homepage Clovertech Forums Read Only Archives Cloverleaf Cloverleaf Need utility for listing which threads use a given proc

  • Creator
    Topic
  • #51862
    herm ernst
    Participant

    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?

Viewing 2 reply threads
  • Author
    Replies
    • #72026
      Chris Williams
      Participant

      This proc returns an alphabetical tcl list of thread names defined in NetConfig.

      Code:

      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

    • #72027
      Connie Kraska
      Participant

      I grep the NetConfig for the proc or I edit it and do a search.

    • #72028
      Kevan Riley
      Participant

      Give this a shot.

      Code:



      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

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

Forum Statistics

Registered Users
5,129
Forums
28
Topics
9,301
Replies
34,447
Topic Tags
288
Empty Topic Tags
10