DX NetOps

Expand all | Collapse all

parse key value pairs in event data

Jump to Best Answer
  • 1.  parse key value pairs in event data

    Posted 04-24-2017 06:24 PM

    I have a device that is sending important information to Spectrum via key value pairs.  I need to pull out the values so that I can present the value separate from the full string and also so that I can perform rules based on the value in specific key value pairs.


    For example, lets say event variable 110 has the following data


    tgn=3301, cic=91

    cause=parse error

    message=some batter information should be here"


    So, I need to pull out tgn and present it as a separate event variable so that I can show it in the alarm display as Trunk Group = {the value that I pull from tgn=}


    I need to pull the information from cause= to use as part of a dynamic alarm title.


    I have tried event procedures with GetRegexp, but the best that I can do is to get the entire key=value and what I want is the value.


    GetRegexp(GetEventVariable({U 110}), {S \"tgn=(\S*).*\"}, {U 0}) will give me "tgn=3301".  Then when I try to switch it to GetRegexp(GetEventVariable({U 110}), {S \"tgn=(\S*).*\"}, {U 1}) so that I get the contents of group #1 (\S*) I get errors in the event error file and it completely fails.


    The interesting thing is if I try this in various regex testers, it works.  I just can't seem to figure out how to do this in an EventProcedure.


    Any suggestions?

  • 2.  Re: parse key value pairs in event data
    Best Answer

    Posted 04-25-2017 08:36 AM

    you need to escape "\" in {S \"tgn=(\S*).*\"}, it should look like {S \"tgn=(\\\\\S*).*\"}.

  • 3.  Re: parse key value pairs in event data

    Posted 04-25-2017 10:15 AM

    You were right on with this one.  Thank you.

    Just one thing, and it is so easy to do. There is one extra "\" in your escape of the "\".  It should only be 4 "\" instead of 5.