我已经从文件中提取了特定字段(AsicErr)的最高计数,并对其进行了过滤,如下所示:
grep AsicErr file.txt | sort -t: -k2nr | head
EGQ0 AsicErr : 3464363
EGQ0 AsicErr : 12312
EGQ0 AsicErr : 120基于此,我想进一步过滤此文件,以提取旁边有箭头的行,如下所示:
示例文件结构
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所需输出:
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 这可能涉及到搜索错误的数值,然后反向搜索以获得FIA Statistics行,然后反向搜索show命令以捕获面临该问题的设备的主机名。
如果我能得到一些关于如何实现这一点的指导,我将不胜感激。
谢谢。
发布于 2019-06-09 16:57:45
下面是一个标准的Linux awk脚本:
awk '/AsicDropErr/{print $4}' file1 file2 |sort |head您可以在awk命令中放入任意多的文件。
https://stackoverflow.com/questions/56512619
复制相似问题