Using a SPECTRUM Event procedure to extract a substring from a varbind to populate a new varbind (Legacy KB ID CNC TS31039 )

Document ID : KB000051979
Last Modified Date : 14/02/2018
Show Technical Document Details
This can be done using an Event Procedure.


In the following Event procedure using the above requirement as an example, for the current model event 0xabcd0000 is associated with, the Event Procedure will take the input varbind 4 (U 4), apply a regular expression looking for the characters between the dots(.) (as in an ip address) and save the result to a new varbind 20 (U 20) and pass all the varbind variables including the new varbind 20 to new event 0xabcd0001.



0xabcd0000 E 50 P "                                                   \
 CreateEventWithAttributes(                                \
   { C CURRENT_MODEL },                                        \
   { H 0xabcd0001 },                                                     \
   SetEventAttribute(                                                 \
     GetEventAttributeList(),                                    \
     { U 20 },                                                                      \
     GetRegexp( GetEventAttribute( { U 4 } ), \
                { S \".*?:.*?:(.*)\" },                                   \
                { U 1 } )                                                             \
     )                                                                 &nbs.p;                   \
 )"

.

Related Issues/Questions:
Using a SPECTRUM Event procedure to extract a substring from a varbind to populate a new varbind

Problem Environment:
SPECTRUM 08.01.00.00
SPECTRUM 09.00.00.00
CallT0000225075
Event Procedure
A user had the following requirement:


Is there any way to pull a substring out of a trap variable?



I am attempting to use the Event Configuration Editor to discriminate traps using trap variable contents. The trap variable 4 contains an IP address, which means that I could receive more than one trap of this condition per device.


Natively, SPECTRUM can't clear these traps automatically, even if I use an event discriminator. The reason is the trap variable 4 contents are not the same in the "clear" event as they are in the "set" event.


Set event:     M:"G700 deregistered from this controller:192.168.2.150:2"
Clear event:  M:"G700 registered successfully:192.168.2.150:2"
   
As I understand discriminators, these 2 variables would have to match EXACTLY in order for the clear event to know how to clear the alarm that is set by the set event.


I have not found any way to pull a substring out of a trap variable and pass it to another event as its own event variable. I can pass one or more event variables to a new event, and I can change the order of the variables, but as far as I know, I cannot break them apart.
   
e.g. if the trap msg is M:"G700 registered successfully:192.168.2.150:2" in order to get the IP Address, I'd have to somehow extract the 3rd  text string delimited by ":" characters...and the use of double-quotes compound things even more.



Additional Information:
The above Event Procedure is an sample using this specific requirement as an example. Please refer to the SPECTRUM 9.0 Event Configuration User Guide for more information about using Event Procedures.


(Legacy KB ID CNC TS31039 )