cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
2052
Views
5
Helpful
2
Replies

Nexus command to properly filter interface discards

clavister
Level 1
Level 1

Hello,

We are getting interface discards on some of out ports on our nexus switches. Unfortunately, our monitoring tool could not generate the graph of the top 10 devices with discards. 

I am trying to generate the output manually by just filtering the interfaces only with discard values.

The result removed the "0 input discard" and "0 output discard" but it still showed the other interfaces that are not necessary to the output or my expected result.

Here are the commands I tried.

This one removes the "0 input/output discard" but still includes the unnecessary interfaces that don't have input/output discards. The Output is on Discard 2 attachment.

 

show interface | exclude "0 input discard" | exclude "0 output discard" | include ignore-case "Port-Channel|Ethernet|discard"

 

This one shows the interfaces and discards including the 0 input/output discards. The sample is on Discard 1 attachment

show interface | include ignore-case "discard|Ethernet"

 

 

1 Accepted Solution

Accepted Solutions

Sergiu.Daniluk
VIP Alumni
VIP Alumni

Hi @clavister 

So you want to display only the interfaces with in/out discards, right?

I would suggest you try filtering the "show int counters errors" output since it is much simpler and has better structure.

Since you want to make a graph, I suppose you are not doing the parsing manually. So you can also take advantage of the NXOS built-in programmability features. For example, use " | json " at the end of a command, and you will get the output in json format.

 

If you really want to go the "hard way" and filter the show interface, you can try this:

 show interface | exclude " 0 input discard" | exclude " 0 output discard" | grep "port\-cha\|Ethernet[1-9]\|discard" | grep -B 1 discard

The command will basically display 1 line before discard line which is either another discard value, either the corresponding interface.

 

Also, I made some adjustments on the cmd to not display the "Hardware" lines.

 

Cheers,

Sergiu

View solution in original post

2 Replies 2

Sergiu.Daniluk
VIP Alumni
VIP Alumni

Hi @clavister 

So you want to display only the interfaces with in/out discards, right?

I would suggest you try filtering the "show int counters errors" output since it is much simpler and has better structure.

Since you want to make a graph, I suppose you are not doing the parsing manually. So you can also take advantage of the NXOS built-in programmability features. For example, use " | json " at the end of a command, and you will get the output in json format.

 

If you really want to go the "hard way" and filter the show interface, you can try this:

 show interface | exclude " 0 input discard" | exclude " 0 output discard" | grep "port\-cha\|Ethernet[1-9]\|discard" | grep -B 1 discard

The command will basically display 1 line before discard line which is either another discard value, either the corresponding interface.

 

Also, I made some adjustments on the cmd to not display the "Hardware" lines.

 

Cheers,

Sergiu

this is quite helpful.

Getting Started

Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: