regexp in alert tcl

Clovertech Forums Read Only Archives Cloverleaf Cloverleaf regexp in alert tcl

  • Creator
    Topic
  • #52108
    Kenadi Moore
    Participant

      Sorry – posted this in the wrong spot originally…

      I am working on an alert where the alert action is a tclproc.

      I am trying to take the info in %A and just display the first part.  For example:

      %A is:

      Thread outbound queue depth (523) of MY_THREAD is more than or equal to 500, currently {SOME_THREAD 0} {MY_THREAD 523} {SOME_OTHER_THREAD 6}

      I just want:

      Thread outbound queue depth (523) of MY_THREAD is more than or equal to 500, currently

      When I test on the command line, both of these seem to put the value I want into $alert:

      regexp ([^{]*){ %A match alert

      regexp ([^{]*){ %A match alert

      However, in the alert configurator, the first is not even allowed (errors with TCL code cannot contain unmatched braces) and the second fails to load properly so nothing happens.

      Is there some other escape character or something I should be using here to make this work?

      Thanks!

      -Kenadi Moore

      OhioHealth

    Viewing 4 reply threads
    • Author
      Replies
      • #73094
        Keith McLeod
        Participant

          The alrtMsg is an argument to the proc called in the alert configurator.  The ‘%A’ argumant would be the first argument in this case….

          proc someproc {alrtMsg variable1 varaible2}

          Try something like:

          depth .*? of (m.*?M) for your regular expression.

          hcitcl>set alrtMsg “Thread outbound queue depth (526) of megw_adts_out is between 500 and 1000, currently {megw_adts_out 526}”

          Thread outbound queue depth (526) of megw_adts_out is between 500 and 1000, currently {megw_adts_out 526}

          hcitcl>set thdPat {depth .*? of (m.*?M)}

          depth .*? of (m.*?M)

          hcitcl>regexp -nocase — $thdPat $alrtMsg match thdName

          1

          hcitcl>echo $thdName

          megw_adts_out

          Hope this helps….

        • #73095
          Kenadi Moore
          Participant

            Wouldn’t your example be specific to that particular thread (or any thread that starts with m)?  In my case, I want a generic proc that will strip everything from the first { onward.

            Thanks,

            Kenadi

          • #73096
            Keith McLeod
            Participant

              Actually that code will match and provide you with

              match = ‘depth (526) of megw_adts_out’

              thdName = ‘megw_adts_out’

              Are you looking for something like:

              >set alrtMsg “Thread outbound queue depth (526) of megw_adts_out is between 500 and 1000, currently {megw_adts_out 526}”

              Thread outbound queue depth (526) of megw_adts_out is between 500 and 1000, currently {megw_adts_out 526}

              hcitcl>string range $alrtMsg 0 [expr [string first { $alrtMsg]-1]

              Thread outbound queue depth (526) of megw_adts_out is between 500 and 1000, currently

            • #73097
              Keith McLeod
              Participant

                m M I beleive is the reference for a word boundary.  The . is any character.  The ? is non-greedy.

                m.*?M within the pattern pulls the threadname based on where it falls in the pattern.  The parentheses capture from left to right in order after the match variable.

                set alrtMsg “Thread outbound queue depth (526) of megw_adts_out is between 500 and 1000, currently {megw_adts_out 526}”

                Thread outbound queue depth (526) of megw_adts_out is between 500 and 1000, currently {megw_adts_out 526}

                hcitcl>set thdPat {depth .*? of (m.*?M)}

                depth .*? of (m.*?M)

                hcitcl>regexp -nocase — $thdPat $alrtMsg match thdName

                1

                hcitcl>echo $thdName

                megw_adts_out

                The thdPat(ie pattern to match) found in alrtMsg goes into variable named ‘match’ and what was contained in Parentheses goes into variable named ‘thdName’

              • #73098
                Keith McLeod
                Participant

                  One more shot after re-reading your original.

                  regexp — {([^{]*){} %A match alert

                  Basically saying capture anything that is not a left curly brace up to the left curly brace in %A and place the overall match in $match and that capture between the parentheses into $alert.

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