I want to use awk to strip certain fields from the output of the Dell OMSA storage hardware diag tool. Typically the format of the output is:

ID                        : 0:0:11
Status                    : Ok
Name                      : Physical Disk 0:0:11
State                     : Online
Power Status              : Spun Up
Bus Protocol              : SAS
Media                     : HDD
Revision                  : ES64
Failure Predicted         : No
Certified                 : Yes
Encryption Capable        : No
Encrypted                 : Not Applicable
Progress                  : Not Applicable
Mirror Set ID             : 0
Capacity                  : 558.38 GB (599550590976 bytes)
Used RAID Disk Space      : 558.38 GB (599550590976 bytes)
Available RAID Disk Space : 0.00 GB (0 bytes)
Hot Spare                 : No
Vendor ID                 : DELL(tm)
Product ID                : ST3600057SS
Serial No.                : 3SL17DCH
Part Number               : SG0W347K1253108C026YA00
Negotiated Speed          : 6.00 Gbps
Capable Speed             : 6.00 Gbps
Manufacture Day           : 07
Manufacture Week          : 32
Manufacture Year          : 2010
SAS Address               : 5000C500240A0BE9

I want to run the command, pipe the output through awk and get the following:

ID                        : 0:0:11
Status                    : Ok
Name                      : Physical Disk 0:0:11
State                     : Online
Capacity                  : 558.38 GB (599550590976 bytes)

but only if the Status is Non-Critical or Failed.

My experience with awk is limited, and I am reading up on awk programming, but I would appreciate any help so I can get this running as a tool for discovering issues before they become critical.

Thank you for the help

hi,

awk -F' : ' 'BEGIN{b[1]="ID"; b[2]="Status"; b[3]="Name"; b[4]="State"; b[5]="Capacity"} {a[$1]=$0}END{ if(a["Status"] ~ "(Non-critical|Failed)$")for(i in b)print a[b[i]]}'
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.