Filtering CLI commands within CLIIt is possible to use
search or
grep commands in the CLI to filter output of any
show command.
searchThe
search command provides a simple method to search for single terms within show command output.
search [-exclude] [-case-sensitive] <single_search_term> <show_command>Example search for an IP address in the running config:
CBS# search 192.168 "show running-config" ip 192.168.4.10/24 192.168.4.255 ip 192.168.4.15/24 192.168.4.255 ip route 192.168.129.0/24 10.10.3.254 vap-group fw circuit outsidegrepThe
grep command provides full grep functionality and can be used to search for a complex search term.
grep [-options <opt1> … <optx>] <search_term> [<show_command>]Searching for an IP address in show flow active output:
CBS# grep 192.168 "show flow active verbose"
fw_2 Source Addr 192.168.4.10, Destination Addr 192.168.129.1
np1 Source Addr 192.168.129.1, Destination Addr 192.168.4.10
Filter configuration to display IP addresses and related circuits and virtual routers:
CBS# grep -options -E "^circuit| ip |virtual" "show running-config"
circuit mgmt circuit-id 1025
ip 192.168.100.11/24 192.168.100.255 increment-per-vap 192.168.100.12
circuit sync circuit-id 1026
ip 192.168.101.11/24 192.168.101.255 increment-per-vap 192.168.101.12
circuit inside circuit-id 1027
ip 192.168.10.11/24 192.168.10.255 increment-per-vap 192.168.10.12
circuit outside circuit-id 1028
ip 10.121.94.11/24 10.121.94.255 increment-per-vap 10.121.94.12
virtual-router vrrp-id 1 circuit inside
virtual-ip 192.168.10.10/24 192.168.10.255
virtual-router vrrp-id 2 circuit outside
virtual-ip 10.121.94.10/24 10.121.94.255
Filtering CLI commands in Linux shellAdditionally, it is possible to filter output of CLI commands in the Linux shell. The following examples are run from the Linux prompt on the CPM.
Display flows being reported as drops in the AFT (including 2 lines after filtered data):
/crossbeam/bin/cli -i 'show flow act' |grep -i -A2 drop Same command but exporting to a file:
/crossbeam/bin/cli -i 'show flow act' |grep -i -A2 drop > flowdrop.txtShowing
traplog messages for a certain date (including 3 lines after and 4 lines before filtered data) :
/crossbeam/bin/cli -i 'show traplog' |grep -A3 -B4 2009-11-25Same command but exporting to a file:
/crossbeam/bin/cli -i 'show traplog' |grep -A3 -B4 2009-11-25 > nov11trap.txtSearching for an IP address in running configuration:
/crossbeam/bin/cli -i 'show running-config" |grep 192.168.100.5Search Audit trail for last time the reload command was run:
/crossbeam/bin/cli -i 'show audit-trail' |grep -i reload The watch command can also be used to monitor the output of commands.
watch runs command repeatedly, displaying its output (the first screenfull).
This allows you to watch the program output change over time:
watch --i=2 "/crossbeam/bin/cli -i \"show ap-vap-mapping\""
watch --i=2 "/crossbeam/bin/cli -i \"show interface gig 1/1\""
watch --i=2 "/crossbeam/bin/cli -i \"show heartbeat np1\""Workaround
N/A