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

Roc156
New Contributor

Oh wait! I think I cancelled it before giving it a chance. LOL.

I guess this dirty fix, will have to do.

Thanks again!

Miguel-Angel_RO
Valued Contributor II

Roc156,

It will return the the first line for all the ports and the serial if it meet the REGX pattern 1234

Example:

-------------------------------------------------------------------------------
Port: 4/46  Index: 676                Time: 230 days, 12:51:46
        ChassisId: Network address    IPv4  10.22.235.90
        PortId:    MAC address        00:08:5d:69:80:2f
        SysName:   Mitel IP Phone
        SysCap:    TB / TB            (Supported/Enabled)
        PortDesc:  port 0
        SysDescr:  Mitel IP Phone

 HWRev: 6865i                         FWRev: 5.1.0.5048
 SWRev: 5.1.0.5048                    SerialNumber: 00-08-5D-69-80-2F
 ManufName: Mitel                     ModelName: 6865i
 AssetID: 00-08-5D-69-80-2F
-------------------------------------------------------------------------------
Port: 3/44  Index: 677                Time: 230 days, 22:50:03
        ChassisId: MAC address        00:d8:61:48:5f:07
        PortId:    MAC address        00:d8:61:48:5f:07

-------------------------------------------------------------------------------
Sys capability: O-Other; R-Repeater; B-Bridge; W-WLAN accesspoint; r-Router;
T-Telephone; D-DOCSIS cable device; S-Station only.
Total neighbors: 43
XXX#sh lldp neighbor med inventory | match "(Port: .+\/.+).+|SerialNumber: .+80-2F"
Port: 1/49  Index: 1                  Time: 157 days, 01:09:35
Port: 3/49  Index: 3                  Time: 157 days, 04:30:24
Port: 1/37  Index: 422                Time: 179 days, 11:41:19
Port: 3/27  Index: 444                Time: 187 days, 11:24:38
Port: 1/25  Index: 453                Time: 187 days, 11:28:02
Port: 3/25  Index: 459                Time: 187 days, 11:30:27
Port: 3/15  Index: 461                Time: 187 days, 11:30:54
Port: 3/21  Index: 462                Time: 187 days, 11:31:22
Port: 3/8   Index: 477                Time: 187 days, 11:39:16
Port: 2/13  Index: 481                Time: 187 days, 11:40:58
Port: 3/23  Index: 493                Time: 187 days, 11:45:28
Port: 1/13  Index: 505                Time: 187 days, 11:49:03
Port: 1/31  Index: 536                Time: 187 days, 11:56:00
Port: 2/38  Index: 538                Time: 187 days, 11:56:21
Port: 2/8   Index: 539                Time: 187 days, 11:56:38
Port: 3/32  Index: 542                Time: 187 days, 12:02:14
Port: 1/27  Index: 556                Time: 187 days, 12:06:58
Port: 3/19  Index: 558                Time: 187 days, 12:07:27
Port: 2/12  Index: 574                Time: 187 days, 12:18:38
Port: 2/10  Index: 576                Time: 187 days, 12:20:16
Port: 1/40  Index: 578                Time: 187 days, 12:36:42
Port: 1/38  Index: 581                Time: 187 days, 12:49:10
Port: 2/14  Index: 592                Time: 188 days, 08:14:41
Port: 3/3   Index: 594                Time: 190 days, 01:42:30
Port: 3/12  Index: 595                Time: 190 days, 02:33:44
Port: 3/48  Index: 652                Time: 221 days, 20:10:38
Port: 1/46  Index: 657                Time: 227 days, 01:32:28
Port: 1/45  Index: 658                Time: 227 days, 01:32:30
Port: 2/46  Index: 659                Time: 227 days, 01:32:39
Port: 1/47  Index: 660                Time: 227 days, 01:32:46
Port: 2/48  Index: 661                Time: 227 days, 01:32:48
Port: 2/26  Index: 662                Time: 227 days, 01:33:28
Port: 4/47  Index: 663                Time: 227 days, 01:33:58
Port: 4/48  Index: 664                Time: 227 days, 01:33:59
Port: 1/42  Index: 665                Time: 227 days, 01:34:02
Port: 1/48  Index: 666                Time: 227 days, 01:34:09
Port: 1/29  Index: 668                Time: 227 days, 01:43:20
Port: 1/35  Index: 672                Time: 227 days, 01:45:14
Port: 1/36  Index: 673                Time: 227 days, 01:45:36
Port: 1/34  Index: 674                Time: 227 days, 01:46:09
Port: 1/26  Index: 675                Time: 228 days, 09:34:00
Port: 4/46  Index: 676                Time: 230 days, 12:51:46
 SWRev: 5.1.0.5048                    SerialNumber: 00-08-5D-69-80-2F

Port: 3/44  Index: 677                Time: 230 days, 22:50:03
XXX#

Up to you to adapt it 

Roc156
New Contributor

@Miguel-Angel RODRIGUEZ-GARCIA I tried the dirty solution, but it only returns the first line for all the ports.I guess since it is a limited set of regex supported, maybe this may not be possible on the ERS.

Thanks a bunch, though!

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

GTM-P2G8KFN