cancel
Showing results for 
Search instead for 
Did you mean: 

Regex to filter VoIP port given serial number

Regex to filter VoIP port given serial number

Roc156
New Contributor

I am trying to create a regular expression that will filter just the section of the port given the last numbers of the serial number using the command sh lldp neighbor med inventory

 

I have the following output:
Port: 1/3  Index: 48                 Time: 0 days, 00:02:32
        ChassisId: Network address    IPv4  x.x.x.x
        PortId:    MAC address        00:00:00:00:00:00
        SysName:   xxxxxxxxx
        SysCap:    TB / B             (Supported/Enabled) HWRev: 9620D02L                      FWRev: hb96xxua3_1_02_S.bin
 SWRev: ha96xxua3_1_02_S.bin          SerialNumber: 10FA00001231
 ManufName: Avaya                     ModelName: 9620
 AssetID:
-------------------------------------------------------------------------------
Port: 2/5   Index: 53                 Time: 0 days, 00:02:32
        ChassisId: Network address    IPv4  x.x.x.x
        PortId:    MAC address        00:00:00:00:00:00
        SysName:   x.x.x.x
        SysCap:    TB / B             (Supported/Enabled) HWRev: 9620D02L                      FWRev: hb96xxua3_1_02_S.bin
 SWRev: ha96xxua3_1_02_S.bin          SerialNumber: 10FA00001234
 ManufName: Avaya                     ModelName: 9620
 AssetID:
-------------------------------------------------------------------------------
Port: 3/40  Index: 54                 Time: 0 days, 00:02:33
        ChassisId: Network address    IPv4  x.x.x.x
        PortId:    MAC address        00:00:00:00:00:00
        SysName:   x.x.x.x
        SysCap:    TB / B             (Supported/Enabled) HWRev: 9620D02L                      FWRev: hb96xxua3_1_02_S.bin
 SWRev: ha96xxua3_1_02_S.bin          SerialNumber: 10FA00001235
 ManufName: Avaya                     ModelName: 9620
 AssetID:
-------------------------------------------------------------------------------

 

I would like to show the port for the serial number tat ends with 001234. So I would like the following output:


Port: 2/5   Index: 53                 Time: 0 days, 00:02:32
        ChassisId: Network address    IPv4  x.x.x.x
        PortId:    MAC address        00:00:00:00:00:00
        SysName:   x.x.x.x
        SysCap:    TB / B             (Supported/Enabled) HWRev: 9620D02L                      FWRev: hb96xxua3_1_02_S.bin
 SWRev: ha96xxua3_1_02_S.bin          SerialNumber: 10FA00001234
 ManufName: Avaya                     ModelName: 9620
 AssetID:
-------------------------------------------------------------------------------

 

So far I have tried the following regex expression, but it doesn’t display anything:

sh lldp neighbor med inventory | find /Port.001234/

1 ACCEPTED SOLUTION

Miguel-Angel_RO
Valued Contributor II

Roc156, Dilraj,

ERS is running on VxWorks with a limited support on regex expressions.

257b1ac9059f4483bd2d6f96d6be2daa_60933e68-65e0-4ddb-a62a-324a13c55db8.png
257b1ac9059f4483bd2d6f96d6be2daa_8c1fc0c1-9006-4d0f-b6f6-c153b9f59c7b.png

We cannot match the standard “\n” so the dirty solution I have is the following regex:

sh lldp neighbor med inventory | match "(Port: .+\/.+).+|SerialNumber: .+1234"

Regards

Mig

View solution in original post

20 REPLIES 20

Dilraj_Singh_Kh
Extreme Employee

Hi Miguel,

Thanks for your help. If you do a normal regex it works, even mine worked as well. The main thing here is to execute the regex directly on the CLI which doesn’t seems to be working.

 

Hi Roc156,

I understand what you are saying. Even I am getting the same in my lab test. Maybe there is some limitation. You might want to open up a GTAC case for this so that the behavior can be verified by the engineering team.

 

Regards,
DILRAJ

Miguel-Angel_RO
Valued Contributor II

Roc156,

 

Try with this (qick and dirty) regex: (Port: \d+\/\d+).+\n.+\n.+\n.+\n.+\n.+SerialNumber: (.+1234)

Playing on https://regex101.com/

As here:

f4d5b8df88794581b660b22910530bd8_056ef954-f5d4-41bc-91c5-d4961779b579.png

Catching the different occurrences of the Group1 will give the portids

 

Mig

Roc156
New Contributor

I don’t get an error, but it does not return anything.

Dilraj_Singh_Kh
Extreme Employee

Try this:

Port:\s\d+\/\d+.*\n.*\n.*\n.*\n.*\n.*SerialNumber:\s\S+001234\n.*\n.*

 

I think it has some problems processing space. I have now replaced it with “\s”

 

Let me know.

Roc156
New Contributor

Did you mean that I should copy the output to Notepad and run a RegEx with that output?

I thought the ACLI had regex filtering.

GTM-P2G8KFN