How to extract the IP address from a variable through Event Procedure and REGEX
search cancel

How to extract the IP address from a variable through Event Procedure and REGEX

book

Article ID: 215060

calendar_today

Updated On:

Products

CA Spectrum DX NetOps

Issue/Introduction

How to get the IP address from a variable through an Event Procedure and Regular Expression?

 

Environment

DX NetOps Spectrum all current Releases
Component : Spectrum Alarm & Event Management

Resolution

Use the following Site to validate your REGEX:

Regular Expressions 101

((?:\d+\.){3}\d+)

 

The following is an example:

The Event Procedure on 0x210d40 event code will generate the 0xfff0000e event code with the existing variable and it will grab the IP Address from the variable {S 4} and put it in the variable {S 6}.

0x210d40 E 0 P "CreateEventWithVariables({C CURRENT_MODEL}, {H 0xfff0000e}, \
                  SetEventVariable( \
                    GetEventVariableList(), \
                    {U 6}, \
                    GetRegexp(GetEventVariable({U 4}), \
                             {S \"((?:\\\\d+\\\\.){3}\\\\d+)\"}, \
                             {U 1}) \
                  ) \
               )"

0xfff0000e E 0

 

Additional Information

The following section of our online Spectrum TechDocs guide details using Escape Characters in Event Procedures:

TechDocs : DX NetOps Spectrum 22.2 : About Event Disposition Files