I know here are many questions and answers in regards to parsing snmpwalk response but I cant seem to find the relating answer here. I am not good in parsing texts but I am doing my best to learn things.
I am polling my Juniper device with command:
snmpwalk -v2c -c blablabla x.x.x.x iso.3.6.1.2.1.2.2.1.2
Getting response as follow:
iso.3.6.1.2.1.2.2.1.2.2548 = STRING: "xe-4/0/1.3461"
iso.3.6.1.2.1.2.2.1.2.2549 = STRING: "xe-4/0/2.3462"
iso.3.6.1.2.1.2.2.1.2.2550 = STRING: "xe-4/0/2.3461"
iso.3.6.1.2.1.2.2.1.2.2551 = STRING: "xe-4/0/3.3462"
iso.3.6.1.2.1.2.2.1.2.2552 = STRING: "xe-4/0/3.3461"
iso.3.6.1.2.1.2.2.1.2.2557 = STRING: "xe-4/2/1.1514"
iso.3.6.1.2.1.2.2.1.2.2558 = STRING: "xe-4/2/1.1634"
Output is ommited as there are many interfaces on this particular device. I need to parse through this output so that I can get only physical interfaces. For instance out of string:
iso.3.6.1.2.1.2.2.1.2.2557 = STRING: "xe-4/2/1.1514"
I need to extract only xe-4/2/1 and so on with other lines. Basicaly, after character " everything before dot. Please note that there lines like this:
iso.3.6.1.2.1.2.2.1.2.1664 = STRING: "xe-4/3/3"
iso.3.6.1.2.1.2.2.1.2.1665 = STRING: "xe-4/1/3.534"
iso.3.6.1.2.1.2.2.1.2.1666 = STRING: "xe-4/1/3.552"
iso.3.6.1.2.1.2.2.1.2.1667 = STRING: "xe-4/3/0.1613"
iso.3.6.1.2.1.2.2.1.2.1296 = STRING: "ae2.1464"
iso.3.6.1.2.1.2.2.1.2.1297 = STRING: "ae2.1503"
iso.3.6.1.2.1.2.2.1.2.1299 = STRING: "ae2.1596"
iso.3.6.1.2.1.2.2.1.2.1300 = STRING: "ae2.2020"
My final goal is to extract all physical interfaces out of this particular device. The only OID relating to interfaces seems to be iso.3.6.1.2.1.2.2.1.2 and when pooling the device it outputs all interfaces including physical and logical.
Many Thanks