I would like to keep a list of the firmware installed in a database, and I can the data I want in the output of hpacucli, but I can't find a reliable way to parse that file;

# hpacucli ctrl slot=2 enclosure 4I:1 show  

Smart Array P800 in Slot 2

   DL320s           at Port 4I, Box 1, OK
      Fan Status: OK
      Temperature Status: OK
      Power Supply Status: Redundant
      Vendor ID: HP      
      Serial Number: 
      **Firmware Version: 1.20**
      Drive Bays: 12
      Port: 4I
      Box: 1
      Location: Internal

   Expander 249
      Device Number: 249
      Firmware Version: 1.20
      WWID: 500508B300DCED50
      Port: 4I
      Box: 1
      Vendor ID: HP      

   Expander 250
      Device Number: 250
      Firmware Version: 1.02
      WWID: 50014380036D183F
      Vendor ID: HP      

   Enclosure SEP (Vendor ID HP, Model DL320s) 247
      Device Number: 247
      Firmware Version: 1.20
      WWID: 500508B300DCED63
      Port: 4I
      Box: 1
      Vendor ID: HP      
      Model: DL320s          

   SEP (Vendor ID HP, Model P800) 248
      Device Number: 248
      Firmware Version: 1.02
      WWID: 50014380036D183E
      Vendor ID: HP      
      Model: P800            

how do I parse that value out of there?

Some of the enclosures, internal ones, don't have a firmware value at all


I have tried to parse the output of hpacucli like that in the past, and here's what I ended up having to do:

Run the ACU command and dump the output to a file. The script you write will parse the file one line at a time. While reading through the file, ignore every line until we see one that starts with "Smart Array". After finding that line, you will start looking for blank lines. When you see a blank line, you know a section is about to start. Store the line following the blank line as title. Keep reading in lines, looking for a line that says "Firmware Version". If you find such a line, parse the number out of it (it's easiest to split the line at the colon) and store it as version. Write title and version to an output file. When you find another blank line, erase the old values of title and version and repeat the process.

I can't find my script at the moment or I'd post it as sample code. From what I recall, I did it in Ruby and it wasn't more than a dozen or so lines long.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.