query engine for process, thread name. Possible?

Clovertech Forums Read Only Archives Cloverleaf Tcl Library query engine for process, thread name. Possible?

  • Creator
    Topic
  • #53239
    John Boyles
    Participant

      Hi,

      I need to run a given TCL proc on a large number of threads and need each instance of the proc to be aware of it’s location within the engine. From within a TCL proc, does anyone know of a method of querying the engine to retrieve the site, process, and thread name from which the proc was called?

      Thanks!

    Viewing 4 reply threads
    • Author
      Replies
      • #77011
        John Boyles
        Participant

          I answered my own question. The global $HciConnName will give you the thread. From there, site and process can be taken from the directory path.

          set workDir [pwd]

          set site “UNKNOWN”; set process “UNKNOWN”

          regexp {/[wd.]+/[wd.]+/integrator/(.+)/exec/processes/(.+)} ${workDir} na site process

          echo $site

          echo $process

          echo $HciConnName

        • #77012
          James Cobane
          Participant

            John,

            You can also add these commands in your script to obtain the info from the environment variables:

            global hciRoot

            global hciSite

            global siteDir

            set hciRoot $env(HCIROOT)

            set hciSite $env(HCISITE)

            set siteDir $env(HCISITEDIR)

            Hope this helps.

            Jim Cobane

            Henry Ford Health

          • #77013
            Chad Flodman
            Participant

              Depending on what you’re doing check out the msiAttach options in the documentation as well…

            • #77014
              David Barr
              Participant

                You can also read the process name from the command line arguments. The simple way to get them is to look at $::argv, but I think Cloverleaf clears that out. You can also get them from the /proc filesystem.

                Code:

                set process [lindex [split [read_file “/proc/[pid]/cmdline”] ”] 4]
                echo process = $process
                echo site = $::HciSite
                echo thread = $::HciConnName

                “set process [file tail [pwd]]” is probably simplest.

              • #77015
                Charlie Bursell
                Participant

                  For process name:

                  set process [file tail [pwd]]

              Viewing 4 reply threads
              • The forum ‘Tcl Library’ is closed to new topics and replies.