Wednesday, August 6, 2014

To count or not count cisco style

In this post we will look at the cisco count option. This command can be use with most show commands and does exactly what it  say? Count


Example 1, you want to get a count of how many down interfaces on a switch;

show int status | count notconnect
Number of lines which match regexp = 22

SW1#

Example 2, you need to get a count of how many username are defined in the configuration file;

SW1#show run | count username
Number of lines which match regexp = 4

SW1#

Example 3, how many down states for interface in the current log buffer  ( great btw for when  your in a ServiceProvider  Role and you manager ask how many things just went down )


SW1#show log |  count down|GigabitEthernet.*down
Number of lines which match regexp = 12

SW1#

NOTE: you could get creative and use date modifiers if per-se you are looking for down even at a certain time

SW1#show log | count  05:34.*GigabitEthernet.*down
Number of lines which match regexp = 2

SW1#

note: The above will show all gigabit ethernets interfaces that went down at  hour of 5:34. In a SP arena you would most like just do the following;


Example 4, counting down interfaces that happen during a time

SW1#show log | count  05:34.*down                
Number of lines which match regexp = 2

SW1#

note: This is a great method to get  the total devices down for incident reports or massive tickets and can be very helpful for ticket controls & with correct information


Example 5, you need to know the # of interfaces in a vlan and need to know how many interface are in that vlan.

SW1#show int status |  count  295 | exc Gi
Number of lines which match regexp = 48

SW1# 
 


Example 6, counting the number of port-channel interfaces

SW1#show run | cou interface.*Port-chann

Number of lines which match regexp = 8

SW1#


Counting in cisco IOS  has hundred of examples and options & is simple as 1-2-3, how you would use it, totally  depends on how creative you can get. 

So get out and start counting something  ;)


Ken Felix
Freelance Network/Security Engineer
kfelix  -----a----t---- socpuppets ---dot---com

    ^    ^
=( #  # )=
      @
      /   \

No comments:

Post a Comment