I've pulled the highest count of a particular field (AsicErr) from a file, and filtered it as below:
grep AsicErr file.txt | sort -t: -k2nr | head
EGQ0 AsicErr : 3464363
EGQ0 AsicErr : 12312
EGQ0 AsicErr : 120
Based on this, I would like to further filter this file to pull the lines which have arrows next to them as per below:
Sample file structure
RP/0/RP0/CPU0:abc#show controllers fia statistics instance 0 location 0/0/CPU0 <<<<<<<<<<<<<<<
Tue Jun 4 11:00:07.521 UTC
Node ID: 0/0/CPU0
FIA Statistics Rack: 0, Slot: 0, Asic instance: 0 <<<<<<<<<<<<<<<
Total number of blocks: 12
Per Block Statistics:
EGQ counters:
EGQ0 CnmCntDrops : 0
EGQ0 CnmCntFlowControl : 0
EGQ0 CnmPktsCnt : 0
EGQ0 AsicErr : 3464363 <<<<<<<<<<<<<<<
EGQ0 CntProfileOffset1 : 0
EGQ0 CntProfileOffset2 : 0
EGQ0 CntProfileOffset3 : 0
EGQ0 CntProfileOffset4 : 0
EGQ0 CntProfileOffset5 : 0
EGQ0 CrcErrFabricCnt : 0
EGQ0 CrcErrOthersCnt : 0
RP/0/RP0/CPU0:abc#show controllers fia statistics instance 3 location 0/0/CPU0 <<<<<<<<<<<<<<<
Tue Jun 4 11:00:11.215 UTC
Node ID: 0/0/CPU0
FIA Statistics Rack: 0, Slot: 0, Asic instance: 3 <<<<<<<<<<<<<<<
Total number of blocks: 12
Per Block Statistics:
EGQ counters:
EGQ0 CnmCntDrops : 0
EGQ0 CnmCntFlowControl : 0
EGQ0 CnmPktsCnt : 0
EGQ0 AsicErr : 12312 <<<<<<<<<<<<<<<
EGQ0 CntProfileOffset1 : 0
EGQ0 CntProfileOffset2 : 0
EGQ0 CntProfileOffset3 : 0
EGQ0 CntProfileOffset4 : 0
EGQ0 CntProfileOffset5 : 0
EGQ0 CrcErrFabricCnt : 0
EGQ0 CrcErrOthersCnt : 0
RP/0/RP0/CPU0:abe#show controllers fia statistics instance 1 location 0/0/CPU0 <<<<<<<<<<<<<<<
Tue Jun 4 11:00:32.283 UTC
Node ID: 0/0/CPU0
FIA Statistics Rack: 0, Slot: 0, Asic instance: 1 <<<<<<<<<<<<<<<
Total number of blocks: 12
Per Block Statistics:
EGQ counters:
EGQ0 CnmCntDrops : 0
EGQ0 CnmCntFlowControl : 0
EGQ0 CnmPktsCnt : 0
EGQ0 AsicErr : 120 <<<<<<<<<<<<<<<
EGQ0 CntProfileOffset1 : 0
EGQ0 CntProfileOffset2 : 0
EGQ0 CntProfileOffset3 : 0
EGQ0 CntProfileOffset4 : 0
EGQ0 CntProfileOffset5 : 0
EGQ0 CrcErrFabricCnt : 0
EGQ0 CrcErrOthersCnt : 0
EGQ0 CupErrFabricCnt : 0
Desired output:
RP/0/RP0/CPU0:abc#show controllers fia statistics instance 0 location 0/0/CPU0
FIA Statistics Rack: 0, Slot: 0, Asic instance: 0
EGQ0 AsicErr : 3464363
RP/0/RP0/CPU0:abc#show controllers fia statistics instance 3 location 0/0/CPU0
FIA Statistics Rack: 0, Slot: 0, Asic instance: 3
EGQ0 AsicErr : 12312
RP/0/RP0/CPU0:abe#show controllers fia statistics instance 1 location 0/0/CPU0
FIA Statistics Rack: 0, Slot: 0, Asic instance: 1
EGQ0 AsicErr : 20
This would probably involve searching for the numerical value of the error, then reverse searching to get the FIA Statistics line, followed by reverse searching the show command to capture hostname of the device which is facing the issue.
If I could get some guidance on how to approach this it would be appreciated.
Thanks.