c3750-ASW2A#sh int counter | i \ 0\ +0\ +0\ +0
Fa1/0/2 0 0 0 0
Fa1/0/5 0 0 0 0
Fa1/0/6 0 0 0 0
Fa1/0/7 0 0 0 0
Fa1/0/2 0 0 0 0
Fa1/0/5 0 0 0 0
Fa1/0/6 0 0 0 0
Fa1/0/7 0 0 0 0
There's a space after each one of the backslashes. What we're really looking for is ports that show zero packets for all of their interface counters: hence, the regex shows lines that have four zeros preceded and followed by one or more spaces, followed by a zero.
Note: you don't actually need the backslashes in IOS; apparently spaces don't need to be escaped in the IOS regex parser. Using them is a habit formed by working with regexes in other OSes. For example:
c3750-ASW2A#sh int counter | i 0 +0 +0 +0
Fa1/0/2 0 0 0 0
Fa1/0/5 0 0 0 0
Initially, I used a $ at the end of the regex to match the zero at the end of the line, but this doesn't seem to work in all IOS versions; I suspect some of them must have whitespace after the zero. In later images, you can use the "count" filter to count the number of never-used ports. Note that because there are separate sections for input and output packets in "show interface counter", you'll need to divide the result by 2:
c3750-ASW2A#sh int counter | count \ 0\ +0\ +0\ +0
Number of lines which match regexp = 60 <-- divide this by 2
If you're running the command via SSH from a Unix-y shell, you can get just the interface names like this:
$ssh 10.1.1.5 'sh int counter | i 0 +0 +0 +0' | sort | uniq | cut -d ' ' -f 1
Fa1/0/10
Fa1/0/13
Fa1/0/14
Fa1/0/13
Fa1/0/14
No comments:
Post a Comment