Cisco Logo


Data Center and Cloud

Every year I decorate my home’s front door for the holidays, it’s very simple just evergreens, some pine cones, maybe some sticks with berries.  It takes about a day, I get up early the first Sunday of December and drive around the rural areas where I live and clip greens. I look for interesting items maybe red or blue berries, cool pine cones, maybe some tall grasses that have a decorative look to them. I been doing this for about 14 years and have learned how to be more efficient by using the right tools and preparing the day before.

I make sure the wire frames that I hang the greens in are in a good state of repair, I get out my warm gear since I’ll be outside all day, setup my van so I have a place to put the clippings.  I even coat all my fingertips with a product called nu-skin since the greens can be pretty sharp and at the end of the day my hands are beat up.  My preparation and implementation methods have evolved over the years and I think now I have it down to a science, the results of my efforts are shown below with before and after pictures.

What I found was that the right tools really do make a difference, my first time I had clippers that weren’t sharp enough, clothes that weren’t warm enough, and I was so frustrated when I was finished that I swore I would never do it again.  The end result however was so nice and received so many compliments that  the next year I tried it again but did it a little smarter. I used the right tools for the job.

The right tools will always help but you have to know how to use them and then sometimes you have to use them a lot to get comfortable.  When it comes to XML the tool that I found does a great job is xmlstarlet. One of the features of Cisco’s UCS Manager is the ability to send a system inventory email using Callhome.  The inventory email can be sent automatically on a regular basis with the minimal interval of a day.   The UCS inventory email contains all sorts of useful information

This information and more can be retrieved from the Callhome email.  What follows is a detailed breakdown of an xmlstartlet command to mine the UCS inventory information from the Callhome inventory email.

The xmlstarlet utility is free and can be downloaded pre-compiled for Windows or fetched into a Linux install with the various Linux tools built for that purpose. Several versions of Linux come with xmlstarlet already installed. I’m assuming that your environment has xmlstarlet and you are familiar with the capabilities that the utility offers. For the purposes of this article I am running xmlstarlet on a Windows 7 Ultimate 32 bit VM with 4GB. I have implemented the script that calls xmlstarlet as a batch file the xmlstarlet utility is named xml.exe

The UCS Manager Callhome inventory email can be setup to be sent as XML or plain text, the script depends on the inventory email being sent as XML. The XML inventory email is constructed as a SOAP Envelope with attachments.

The script

  1. @echo off
  2.  

  3. xml.exe fo -C %1 | ^
  4.  

  5. xml.exe unesc | ^
  6.  

  7. xml.exe sel -t ^
  8.  

  9. -m //topSystem -v "concat('UCS: ', @name, ' Firmware: ', mgmtController/firmwareRunning[@deployment='system']/@version)" -n ^
  10.  

  11. -m //networkElement -s A:T:U @id -n -v "concat('Fabric: ', @id, ' Serial: ', @serial, ' Model: ', @model, ' IP: ', @oobIfIp)" -n -v "concat(' firmware (system/kernel): ', mgmtController/firmwareRunning[@deployment='system']/@version, '/', mgmtController/firmwareRunning[@deployment='kernel']/@version)" -n -n ^
  12.  

  13. -m equipmentSwitchCard -s A:N:U @id -v "concat(' Slot: ', @id, ' Serial: ', @serial, ' Model: ', @model)" -n -b -n ^
  14.  

  15. -m equipmentPsu -s A:T:U @id -v "concat(' PSU: ', @id, ' Serial: ', @serial, ' Model: ', @model)" -n -b -n ^
  16.  

  17. -m equipmentFan -s A:N:U @id -v "concat(' Fan Serial: ', @serial, ' Model: ', @model)" -n -b -b -n ^
  18.  

  19. -m //equipmentChassis -s A:T:U @id -n -v "concat('Chassis: ', @id, ' Serial: ', @serial, ' Model: ', @model)" -n -n ^
  20.  

  21. -m equipmentPsu -s A:T:U @id -v "concat(' PSU: ', @id, ' Serial: ', @serial, ' Model: ', @model)" -n -b -n ^
  22.  

  23. -m equipmentIOCard -s A:T:U @id -v "concat(' IOM: ', @id, ' Serial: ', @serial, ' Model: ', @model, ' firmware: ', mgmtController/firmwareRunning[@deployment='system']/@version, ' Side: ', @side)" -n -b -n ^
  24.  

  25. -m equipmentFanModule -s A:N:U @id -v "concat(' Fan Serial: ', @serial, ' Model: ', @model)" -n -b -n ^
  26.  

  27. -m computeBlade -s A:T:U @serverId -v "concat(' Blade: ', @serverId, ' Serial: ', @serial, ' Model: ', @model)" -n ^
  28.  

  29. -m mgmtController -v "concat(' CIMC Serial: ', @serial, ' Model: ', @model,' firmware: ', firmwareRunning[@deployment='system']/@version)" -b -n -n ^
  30.  

  31. -m adaptorUnit -s A:T:U @id -v "concat(' Adaptor Serial: ', @serial, ' Model: ', @model,' firmware: ', mgmtController/firmwareRunning[@deployment='system']/@version)" -b -n -n ^
  32.  

  33. -m computeBoard -v "concat(' Board Serial: ', @serial, ' Model: ', @model)" -n -n ^
  34.  

  35. -m storageController -v "concat(' Storage Controller: ', @model,' firmware: ', firmwareRunning[@deployment='system']/@version)" -b -n ^
  36.  

  37. -m processorUnit -s A:T:U @id -v "concat(' Socket: ', @socketDesignation, ' Model: ', normalize-space(@model),' speed: ', @speed)" -n -b -n ^
  38.  

  39. -m memoryArray/memoryUnit[@presence='equipped'] -s A:N:U @id -v "concat(' Memory Array: ', @array, ' Id: ', @id,' Model: ', @model, ' Capacity: ', @capacity)" -n -b -n
  40.  

The script is three calls to xmlstarlet pipe-lined from one call to the next, manipulating the XML file that was provided as a parameter, with the output going to the screen. How the XML goes from the email to a file or capturing the output of the script in a file or sending the output as an email or whatever else you may want to do to with it is left to you.

The UCS inventory is represented in the emailed XML as a CDATA section, for the script to work the inventory needs to be just another node in the XML. The first two calls to xml.exe achieve that transformation. The third call to xml.exe does all the extraction and display.

Windows batch files use the Caret as the line continuation chatacter, when I’m referencing a line beyond line 4 it will be from the “-m” that begins the line up to the caret that ends the line, even if the line overflows to the next line due to screen width.

  1. Stops the display of the commands on the screen.
  2.  

  3. The first call to xml.exe uses the fo option to format the input XML the -C flag turns CDATA sections of the XML into text nodes.
  4.  

  5. The output has CDATA sections formatted as text nodes however the embedded < and > were escaped, use the unecs option to turn them back to < and >.
  6.  

  7. This third call to xml.exe uses the sel option followed by multiple -m, -s, -v, -b and -n flags to extract the UCS inventory and format the output.
  8. A brief explanation of the flags

    • -m is the match flag and uses XPATH syntax to match XML elements and attributes.
    • -s X:Y:Z op xpath is the sort flag where direction (X), data type(Y), case order(Z) and the sort entity is identified.
    • X is A - for order="ascending"
    • X is D - for order="descending"
    • Y is N - for data-type="numeric"
    • Y is T - for data-type="text"
    • Z is U - for case-order="upper-first"
    • Z is L - for case-order="lower-first"
    •  

    • -v is the value-of flag to specify the display of a value of an XPATH expression.  Line formatting can be achieved when used in conjunction with the “concat” and “normalize-space” functions, as well as over a hundred other XSLT functions.
    • -b is the break flag, use this to break from a nested -m call
    • -n is the new-line flag to insert a new-line in the output
  9. Match (-m) for all the topSystem elements (there is only one) and output a line (-v with the concat function, element attributes are referenced by placing a @ in front of the attribute name) with the UCS name and the firmware version of UCS Manager followed by a newline. The firmware version is contained in the firmwareRunning element that is the grandchild element of topSystem. The XPATH statement  mgmtController/firmwareRunning[@deployment='system']/@version retrieves the attribute “version” from the firmwareRunning element where the atttribute “deployment” has the value “system”.  This is needed because there are two firmwareRunning elements, but I only want to display the value of version attribute where deployment has a value of system. The output is finished with a new-line.
  10.  

  11. Match for all the networkElement elements these elements are the UCS Fabric Interconnects, sort (-s) them in Ascending order, with a test data type, uppercase values first. Sort on the value id attribute. Output the Fabric Interconnect id, serial number, model and IP address, followed by a new-line and then the system and kernel firmware firmware versions, followed by two new-lines.
  12.  

  13. Match for all the equipmentSwitchCard elements under the current networkElement node, sort and output, followed by new-line a break and a new-line.  The break allows the next match to match again just below the current networkElement.
  14.  

  15. Match for all equipmentPsu elements under the current networkElement node, sort and output, followed by a new-line a break and a new-line.
  16.  

  17. Match for all equipmentFan elements under the current networkElement node, sort and output, followed by a new-line two breaks and a new-line. Two breaks are needed to allow for the processing of the next networkElement node, if there is one.
  18.  

  19. Match for all equipmentChassis elements sort and output, followed by two new-lines.
  20.  

  21. Match for all equipmentPsu elements under the current equipmentChassis node, sort and output, followed by a new-line a break and a new-line.
  22.  

  23. Match for all equipmentIOCard elements under the current equipmentChassis node, sort and output, followed by a new-line a break and a new-line.
  24.  

  25. Match for all equipmentFanModule elements under the current equipmentChassis node, sort and output, followed by a new-line a break and a new-line.
  26.  

  27. Match for all computeBlade elements under the current equipmentChassis node, sort and output, followed by a new-line.
  28.  

  29. Match for all mgmtController elements under the current computeBlade node, output, followed by a break and two new-lines.
  30.  

  31. Match for all adaptorUnit elements under the current computeBlade node, sort and output, followed by a break and two new-lines.
  32.  

  33. Match for all computeBoard elements under the current computeBlade node, output, followed two new-lines.
  34.  

  35. Match for all storageController elements under the current computeBlade node, output, followed by a break and a new-line.
  36.  

  37. Match for all processorUnit elements under the current computeBlade node, sort and output, followed by a new-line a break and a new-line. The normalize-space function was used to eliminated extra spaces in the “model” attribute.
  38.  

  39. Match for all memoryArray/memoryUnit elements under the current computeBlade node, sort and output, followed by a new-line a break and a new-line. Only the populated memoryUnit elements will be displayed based on the memoryUnit presence attribute having a value of equipped.

The XML that starts with topSystem and contains the UCS inventory elements is represented by the outline below.  In the script a match can be run while inside a node this allows for the retrieval of child nodes specific to the cirrent node. For example the element firmwareRunning is a grandchild or great grandchild of several of the elements. The nested match requests in the script allow for the retrieval of the firmwareRunning element that is a child of the element that is currently being processed. Each break flag in the script causes the script to back out of the current node in order to process the next matching sibling node.
topSystem
-mgmtController
--firmwareRunning
-networkElement
--mgmtController
---firmwareRunning
--equipmentSwitchCard
--equipmentSwitchCard
--equipmentPsu
--equipmentPsu
--equipmentFan
--equipmentFan
-networkElement
--(children elements similar to the previous networkElement)
-equipmentChassis
--equipmentPsu
--equipmentPsu
--equipmentPsu
--equipmentPsu
--equipmentIOCard
---mgmtController
----firmwareRunning
--equipmentIOCard
---mgmtController
----firmwareRunning
--equipmentFanModule
--equipmentFanModule
--equipmentFanModule
--equipmentFanModule
--equipmentFanModule
--equipmentFanModule
--equipmentFanModule
--equipmentFanModule
--computeBlade
---mgmtController
----firmwareRunning
---adaptorUnit
----mgmtController
----firmwareRuning
---storageController
---processorUnit
---processorUnit
---memoryArray
----memoryUnit
--computeBlade
--(children elements similar to the previous computeBlade
-equipmentChassis
--(children elements similar to the previous equipmentChassis)
-equipmentChassis
--(children elements similar to the previous equipmentChassis)

Here is a sample of the output from the script above;


UCS: ucsprod Firmware: 1.4(3s)

Fabric: A Serial: SSI151117G3 Model: N10-S6100 IP: 10.23.4.168
firmware (system/kernel): 4.2(1)N1(1.43s)/4.2(1)N1(1.43s)

Slot: 1 Serial: JAF7514BKMT Model: N10-S6100-SUP
Slot: 2 Serial: JAF7418ECMJ Model: N10-E0440

PSU: 1 Serial: DTM147900LB Model: N10-PAC1-550W
PSU: 2 Serial: DTM157900K0 Model: N10-PAC1-550W

Fan Serial: N/A Model: N10-FAN1
Fan Serial: N/A Model: N10-FAN1

Fabric: B Serial: SSI151007DN Model: N10-S6100 IP: 10.23.4.169
firmware (system/kernel): 4.2(1)N1(1.43s)/4.2(1)N1(1.43s)

Slot: 1 Serial: JAF1515ARFC Model: N10-S6100-SUP
Slot: 2 Serial: JAF1418ECMK Model: N10-E0440

PSU: 1 Serial: DTM157900K2 Model: N10-PAC1-550W
PSU: 2 Serial: DTM1570008A Model: N10-PAC1-550W

Fan Serial: N/A Model: N10-FAN1
Fan Serial: N/A Model: N10-FAN1

Chassis: 1 Serial: FOX1505H453 Model: N20-C6508

PSU: 1 Serial: DTM157905CA Model: N20-PAC5-2500W
PSU: 2 Serial: DTM157200YN Model: N20-PAC5-2500W
PSU: 3 Serial: DTM157902A2 Model: N20-PAC5-2500W
PSU: 4 Serial: DTM157905D2 Model: N20-PAC5-2500W

IOM: 1 Serial: QCI1571A2G6 Model: N20-I6584 firmware: 1.4(3s) Side: left
IOM: 2 Serial: QCI1571A21L Model: N20-I6584 firmware: 1.4(3s) Side: right

Fan Serial: NWG150709PZ Model: N20-FAN5
Fan Serial: NWG1507096G Model: N20-FAN5
Fan Serial: NWG15070819 Model: N20-FAN5
Fan Serial: NWG1507082M Model: N20-FAN5
Fan Serial: NWG1507083C Model: N20-FAN5
Fan Serial: NWG15070836 Model: N20-FAN5
Fan Serial: NWG15070887 Model: N20-FAN5
Fan Serial: NWG15070872 Model: N20-FAN5

Blade: 1/1 Serial: QCI1507A49H Model: N20-B6625-1
CIMC Serial: QCI1507A49H Model: N20-B6625-1 firmware: 1.4(3s)

Adaptor Serial: EXM135176PJ Model: N20-AE0002 firmware: 1.4(3s)

Board Serial: QCI1503749H Model: N20-B6625-1

Storage Controller: SAS1064E PCI-Express Fusion-MPT SAS firmware: 01.28.03.00
Socket: CPU1 Model: Intel(R) Xeon(R) CPU E5620 @ 2.40GHz speed: 2.400000
Socket: CPU2 Model: Intel(R) Xeon(R) CPU E5620 @ 2.40GHz speed: 2.400000

Memory Array: 1 Id: 1 Model: M393B5170FH0-YH9 Capacity: 4096
Memory Array: 1 Id: 3 Model: M393B5170FH0-YH9 Capacity: 4096
Memory Array: 1 Id: 5 Model: M393B5170FH0-YH9 Capacity: 4096
Memory Array: 1 Id: 7 Model: M393B5170FH0-YH9 Capacity: 4096
Memory Array: 1 Id: 9 Model: M393B5170FH0-YH9 Capacity: 4096
Memory Array: 1 Id: 11 Model: M393B5170FH0-YH9 Capacity: 4096

Blade: 1/2 Serial: QCI150771FM Model: N20-B6625-1
CIMC Serial: QCI150771FM Model: N20-B6625-1 firmware: 1.4(3s)

Adaptor Serial: EXM135176JA Model: N20-AE0002 firmware: 1.4(3s)

Board Serial: QCI150771FM Model: N20-B6625-1

Storage Controller: SAS1064E PCI-Express Fusion-MPT SAS firmware: 01.28.03.00
Socket: CPU1 Model: Intel(R) Xeon(R) CPU E5620 @ 2.40GHz speed: 2.400000
Socket: CPU2 Model: Intel(R) Xeon(R) CPU E5620 @ 2.40GHz speed: 2.400000

Memory Array: 1 Id: 1 Model: M393B5170FH0-YH9 Capacity: 4096
Memory Array: 1 Id: 3 Model: M393B5170FH0-YH9 Capacity: 4096
Memory Array: 1 Id: 5 Model: M393B5170FH0-YH9 Capacity: 4096
Memory Array: 1 Id: 7 Model: M393B5170FH0-YH9 Capacity: 4096
Memory Array: 1 Id: 9 Model: M393B5170FH0-YH9 Capacity: 4096
Memory Array: 1 Id: 11 Model: M393B5170FH0-YH9 Capacity: 4096
The right tools make all the difference xmlstartlet is a great tool that should be in your XML toolbox. The options used in this script are just a small sample of what xmlstarlet can do.

In an effort to keep conversations fresh, Cisco Blogs closes comments after 90 days. Please visit the Cisco Blogs hub page for the latest content.

5 Comments.


  1. Excellent explanation John. I was wondering is call home config on UCS the same as other IOS devices? In other words, does the CiscoTAC-1 profile exist? I believe this default profile is setup with xml for the backend system. Could one create a separate profile with the same info contained in CiscoTAC-1 and just specify short/long text; thereby bypassing xml in email?

       0 likes

  2. Rob,

    Glad you liked it and yes Callhome is setup similar to other IOS devices and utilizes the CiscoTAC-1 profile. As recent as the 2.0 release of the UCS firmware the Callhome inventory email is sent only to the recipients in the CiscoTAC-1 profile. See UCS documentation, http://www.cisco.com/en/US/docs/unified_computing/ucs/sw/cli/config/guide/2.0/b_UCSM_CLI_Configuration_Guide_2_0_chapter_0101010.html#task_1BFB29AED2C7427CA7ACEEB329F188B5

    Creating another profile with the same information of CiscoTAC-1 except the delivery format will not work for what you are asking.

    Regards,
    John

       0 likes

  3. Thanks John. I think specifics like this are good to know as Cisco adds more and more device/platform support to the Smart Call Home offering. I have had a few customers run into this very same xml email issue; which makes the emails generated unreadable to most humans without a solution like this. Looking at the output above the reading and good portion of the link you provided also point to the fact that the UCS implementation of only xml and shortext might be the way of the future for the tool. Thanks again for the clarification.

       0 likes

  4. Great Post John!
    Was looking for something to help me extract inventory from UCSM! Love this script…
    I made a small contribution, adding local hard drive information:
    18.5 -m storageController/storageLocalDisk[@presence='equipped'] -s A:N:U @id -v “concat(‘ Disk ID: ‘, @id, ‘ Vendor: ‘, @vendor,’ Model: ‘, @model, ‘ Serial: ‘, @serial,’ Capacity: ‘, @size)” -n -b -n ^

    m

       0 likes

    • Thanks for the contribution, there’s so much information that can be extracted from the CallHome email, glad you found the script useful.

         0 likes

  1. Return to Countries/Regions
  2. Return to Home
  1. All Data Center and Cloud
  2. Return to Home