Cisco – Command for showing unused ports over time on Cisco switches

ciscocisco-catalystcisco-commandsinterfaceswitch

I was looking at a previous question about this where a command was given to look for all ports that had not been used in 6 weeks. I ran the command but it doesn't give the port names just the line in the output that has the last input. I'm not a regular expression person so is there someone who can change this to show the port names as well.

Command:

show int | i proto.*notconnect|proto.*administratively down|Last in.* [6-9]w|Last in.* [0-9][0-9]w|[0-9]y|disabled|Last input never, output never, output hang never

Output:
  Last input never, output 7w5d, output hang never
  Last input never, output 7w5d, output hang never
  Last input never, output 17w1d, output hang never
  Last input never, output never, output hang never
  Last input never, output never, output hang never
  Last input never, output never, output hang never
  Last input never, output 21w6d, output hang never
  Last input never, output 21w3d, output hang never
  Last input never, output never, output hang never
  Last input never, output never, output hang never
  Last input never, output never, output hang never
  Last input never, output 7w1d, output hang never
  Last input never, output 7w5d, output hang never
  Last input never, output 8w4d, output hang never
  Last input never, output never, output hang never
  Last input never, output never, output hang never
  Last input never, output never, output hang never
  Last input never, output never, output hang never
  Last input never, output never, output hang never
  Last input never, output never, output hang never

Best Answer

You are only going to get the specific line of the output for a filter, and that line doesn't include the interface. You would just need to run the command without the filters to include the interface, and that will include all the lines for all the interfaces, which is what you seem to want to eliminate.

You may be able to use the show interfaces counters command. This command will show the statistics per interface since the last time the counters were cleared:

Switch1#show interfaces counters

Port                InOctets   InUcastPkts   InMcastPkts   InBcastPkts
Gi1/0/1           2067013697      20374822        209358          9989
Gi1/0/2                    0             0             0             0
Gi1/0/3                    0             0             0             0
Gi1/0/4           1655040672       5855659           611         77829
Gi1/0/5                    0             0             0             0
Gi1/0/6             17864697         51741         15659            48
Gi1/0/7            605795797       2338136             0          1464
Gi1/0/8             62153075        312522         80188            22