DX NetOps

Expand all | Collapse all

RegExp Syntax in Event Procedures

  • 1.  RegExp Syntax in Event Procedures

    Posted 10-14-2016 06:47 AM

    Hello,

    I receive the following trapmessage:

     

    SNMPv2-SMI::enterprises.23151.1.1.1.1 = STRING: "ERROR [SeeTec Cayuga] / [INR 6013256] [14:33:45]: Cannot establish stream to [10.27.79.134:80]/[DBUG-03-B2] from [10.27.79.211]."

     

    I want to grep the text inside the [ ] square brackets and give it to new variables. I only need the parts after the "Cannot establish stream" message.

    Example:

    var1 = 10.27.79.134:80

    var2 = DBUG-03-B2

    var3 = 10.27.79.211

    I've looked into the Event and Procedure Documentation. While I understand how to create a new event with eventvariables I do not comprehend the RegExp syntax Part.

     

    Can someone explain what the characters mean or do?

    S \"[(]([^)]+)\"

    S \"Service: *(.*?) +\"

    S \".*?:.*?:(.*)\"

     

    How do I get the RegExp to grep the text from the second and third square bracket?

     

    Regards,

     

    Jana.



  • 2.  Re:  RegExp Syntax in Event Procedures

    Posted 07-17-2017 08:23 AM

    Does this code work and you do not understand it? Or does the code not work at all?

     

    I would have written this as the following regex for function Event Procedure function GetRegexpList

     

    S \"Cannot establish stream to \[([^\]]+)[^\[]+\[([^\]]+)\] from \[([^\]]+)\"

     

    • S \"[(]([^)]+)\"   
      This probably does not work with the unmatched parentesis

    •  

      S \"Service: *(.*?) +\"
      I don't see how this would work considering the example does not have "Service" in it

    • S \".*?:.*?:(.*)\"
      "Grab everything after the second semi colon"
      Technically works, does not look like it fills your requirements though