Showing posts with label xml-pi. Show all posts
Showing posts with label xml-pi. Show all posts

19 February, 2014

Cisco IOS empty XML output issue

Noticed a weird issue with using the | format command. The switch had been idle for about 16 hours since last connection.

Issued command:
DLS2#sh cdp neighbors detail | format

Got reply:
<?xml version="1.0" encoding="UTF-8"?>
  <show_cdp_neighbors_detail xmlns="ODM://flash:/finalspan.odm//show_cdp_neighbors_detail">
    <SpecVersion>built-in</SpecVersion>
  </show_cdp_neighbors_detail>

No output of CDP whatsoever. I issued the same command again, 5 seconds later without any config alteration:
DLS2#sh cdp neighbors detail | format

Got reply:
<?xml version="1.0" encoding="UTF-8"?>
  <show_cdp_neighbors_detail xmlns="ODM://flash:/finalspan.odm//show_cdp_neighbors_detail">
    <SpecVersion>built-in</SpecVersion>
    <beginner>
      <remote_hostname>DLS1</remote_hostname>
      <remote_ip_addr>10.1.1.11</remote_ip_addr>
      <local_int>FastEthernet0/12,</local_int>
      <remote_int>FastEthernet1/0/12</remote_int>
    </beginner>
    <beginner>
      <remote_hostname>DLS1</remote_hostname>
      <remote_ip_addr>10.1.1.11</remote_ip_addr>
      <local_int>FastEthernet0/11,</local_int>
      <remote_int>FastEthernet1/0/11</remote_int>
    </beginner>
    <beginner>
      <remote_hostname>ALS2</remote_hostname>
      <remote_ip_addr>10.1.1.14</remote_ip_addr>
      <local_int>FastEthernet0/8,</local_int>
      <remote_int>FastEthernet0/8</remote_int>
    </beginner>
    <beginner>
      <remote_hostname>ALS2</remote_hostname>
      <remote_ip_addr>10.1.1.14</remote_ip_addr>
      <local_int>FastEthernet0/7,</local_int>
      <remote_int>FastEthernet0/7</remote_int>
    </beginner>
    <beginner>
      <remote_hostname>ALS1</remote_hostname>
      <remote_ip_addr>10.1.1.13</remote_ip_addr>
      <local_int>FastEthernet0/10,</local_int>
      <remote_int>FastEthernet0/10</remote_int>
    </beginner>
    <beginner>
      <remote_hostname>ALS1</remote_hostname>
      <remote_ip_addr>10.1.1.13</remote_ip_addr>
      <local_int>FastEthernet0/9,</local_int>
      <remote_int>FastEthernet0/9</remote_int>
    </beginner>
  </show_cdp_neighbors_detail>

Exact same anomaly occured on my other switch.
Affected hardware is running on:
c3560-ipservicesk9-mz.122-55.SE7.bin
c3750-ipservicesk9-mz.122-55.SE8.bin

14 February, 2014

Spanning-tree output formatting to XML

Formatting spanning-tree output into (almost) structured XML.
Can be used to query entire list of VLANs or just the desired ones.
The content of temp4.odm:

###
show spanning-tree
show spanning-tree vlan *
<?xml version="1.0" encoding="UTF-8"?>
<ODMSpec>
<SpecVersion>built-in</SpecVersion>
<Command><Name>show spanning-tree</Name></Command>
<DataModel>
<Container name="ShowSpanningtree">
<Container name="VLAN" alias = "VLANNER" dynamic = "true">
<Property name="VLAN" alias = "VLAN" distance = "0" length = "1" type = "String"/>
<Container name="Priority" alias = "Root_ID" dynamic = "false">
<Property name="Priority" alias = "Root_Priority" distance = "1" length = "1" type = "String"/>
<Property name="Address" alias = "Root_Address" distance = "1" length = "1" end-delimiter = "," type = "String"/>
<Property name="This" alias = "am_root" distance = "4" length = "1" type = "String"/>
</Container>
<Container name="Priority" alias = "Bridge_ID" dynamic = "false">
<Property name="Priority" alias = "Bridge_Priority" distance = "1" length = "1" type = "String"/>
<Property name="Address" alias = "Bridge_Address" distance = "1" length = "1" end-delimiter = "," type = "String"/>
</Container>
<Table name="Interfaces">
<Header name="Interface" type="String" start="0" end="18"/>
<Header name="Role" type="String" start="20" end="23"/>
<Header name="Sts" type="String" start="25" end="27"/>
<Header name="Cost" type="String" start="29" end="37"/>
<Header name="Prio.Nbr" type="String" start="39" end="46"/>
<Header name="Type" type="String" start="48" end="69"/>
</Table>
</Container>
</Container>
</DataModel>
</ODMSpec>

13 February, 2014

XML-PI property variables.

<Property name="Priority" alias = "Priority" distance = "2" length = "-1" type = "String"/>

Trying to figure out how exactly the distance and length values influence the XML output and format.


-update-

The <property> tag matches a row.
The "distance" parameter dictates where the matching of data (inside the row) should begin.
The "length" parameter dictates where the matching of data (inside the row) should end.
The value of "distance" can be any positive integer.
The value of "length" can range from -1 to any other positive integer (-1 covers entire row to the end).
Delimiter for counting numbers is the space key.

For example row:
              1           2          3          4         5

Priority    32769  (priority 32768 sys-id-ext 1)

and
<Property name="Priority" alias = "Priority" distance = "3" length = "-1" type = "String"/>

results in a match of
<Priority>32768 sys-id-ext 1</Priority>