cancel
Showing results for 
Search instead for 
Did you mean: 
cancel
3338
Views
5
Helpful
3
Replies

Cisco pipe operator FORMAT

pdub206
Level 1
Level 1

I'm trying to find out what the show pipe operator FORMAT does.  There is little to no documentation on this option -- I just can't find any good examples of its use.  I would like to format the output of "show platform cpu packet buffered" into a wireshark .pcap file, and am wondering if this is the appropriate use of the FORMAT operator.

switch#$rm cpu packet buffer | ?
append Append redirected output to URL (URLs supporting append operation
only)
begin Begin with the line that matches
count Count number of lines which match regexp
exclude Exclude lines that match
format Format the output using the specified spec file
include Include lines that match
redirect Redirect output to URL
section Filter a section of output
tee Copy output to URL

What does this operator do, and would I be able to perform something like:

show cpu packet buffered | format bootflash:test.pcap

Without actually formatting my bootflash?

Throwing packets since 2012
3 Replies 3

Dennis Mink
VIP Alumni
VIP Alumni

excellent question,

I think it refers to this:

  http://www.cisco.com/c/en/us/td/docs/net_mgmt/enhanced_device_interface/2-2/developer/guide/edi_pg_2_2/progodm.html

although I have never tried formating CLI output.(looks a bit convoluted)

Please remember to rate useful posts, by clicking on the stars below.

jcameron
Level 1
Level 1

The link is old and appears to be deprecated, but I have same problem and question with this command modifier.

wireman84
Level 1
Level 1

You can ask the router for some examples.  

show format built-in

That will list commands in the built-in "ODM" file.  You can then pick a command and run:

show format cli <cmd>

Example:

#show format cli show inventory
<?xml version="1.0" encoding="UTF-8"?>
<ODMSpec>
<SpecVersion>built-in</SpecVersion>
<Command><Name>show inventory</Name></Command>
<DataModel>
<Container name="ShowInventory">
<Container name="NAME:" alias = "InventoryEntry" dynamic = "true">
<Property name="NAME:" alias = "ChassisName" distance = "1" length = "1" end-delimiter = "," type = "String"/>
<Property name="DESCR:" alias = "Description" distance = "1" length = "-1" type = "String"/>
<Property name="PID:" alias="PID" distance = "1" length = "5" end-delimiter = "," type = "String"/>
<Property name="VID:" alias="VID" distance = "1" length = "1" end-delimiter = "," type = "String"/>
<Property name="SN:" alias="SN" distance = "1" length = "1" end-delimiter = "," type = "String"/>
</Container>
</Container>
</DataModel>
</ODMSpec>

You can use | format flash:/file.odm to specify a file you create.  When adding to a file it must follow this format:

###
the ios command 1
<?xml version="1.0" encoding="UTF-8"?>
<ODMSpec>
...
</ODMSpec>
###
the ios command 2
<?xml version="1.0" encoding="UTF-8"?>
<ODMSpec>
...
</ODMSpec>

The first ### is required!  

Example of two in a file:

###
show inventory
<?xml version="1.0" encoding="UTF-8"?>
<ODMSpec>
<SpecVersion>built-in</SpecVersion>
<Command><Name>show inventory</Name></Command>
<DataModel>
<Container name="ShowInventory">
<Container name="NAME:" alias = "InventoryEntry" dynamic = "true">
<Property name="NAME:" alias = "ChassisName" distance = "1" length = "1" end-delimiter = "," type = "String"/>
<Property name="DESCR:" alias = "Description" distance = "1" length = "-1" type = "String"/>
<Property name="PID:" alias="PID" distance = "1" length = "5" end-delimiter = "," type = "String"/>
<Property name="VID:" alias="VID" distance = "1" length = "1" end-delimiter = "," type = "String"/>
<Property name="SN:" alias="SN" distance = "1" length = "1" end-delimiter = "," type = "String"/>
</Container>
</Container>
</DataModel>
</ODMSpec>
###
show ip interface brief
<?xml version="1.0" encoding="UTF-8"?>
<ODMSpec>
<SpecVersion>built-in</SpecVersion>
<Command><Name>show ip interface brief</Name></Command>
<DataModel>
<Container name="ShowIpInterfaceBrief">
<Table name="IPInterfaces">
<Header name="Interface" type="String" start="0" end="21"/>
<Header name="IP-Address" type="IpAddress" start="23" end="37"/>
<Header name="OK" type="String" start="39" end="41"/>
<Header name="Method" type="String" start="43" end="48"/>
<Header name="Status" type="String" start="50" end="70"/>
<Header name="Protocol" type="String" start="72" end="-1"/>
</Table>
</Container>
</DataModel>
</ODMSpec>

As you can see from these two built in ODM specifications, there is both single parameter parsing and table based parsing.

Hold on because you will do a lot of edit, TFTP, Test, re-edit, TFTP, test, repeat!  No good reference was found. However, imperially you can get some XML output.

Reference:

Cisco IOS Network Management Configuration Guide, Release 12.2SR

 

Review Cisco Networking for a $25 gift card