Blog Series: Monitoring using PowerShell: Part two – Using Powershell to monitor Dell systems

Hi All,

My next couple of blogs will be a series of blogs where I will be explaining on how to use PowerShell for the monitoring of critical infrastructure. I will be releasing a blog every day that will touch on how to monitor specific software components, but also network devices from Ubiquity, third-party API’s and Office365. I will also be showing how you can integrate this monitoring in current RMM packages such as Solarwinds N-Central, Solarwinds RMM MSP and even include the required files to import the  monitoring set directly into your system.


Requirements:

  • Dell OpenManage Managed Node installation
  • PowerShell v2 or higher

Creating the monitoring sets:

This is the second monitoring script is and still pretty straight forward. Instead of using the data retrieved from StorCli we’re going to use the OMReport functionality, which is a part of the Dell OpenManage Managed Node suite to extract the data to a usable array. OMReport has some cavets that aren’t present in the StorCLI files and it does not give very nicely structured data, So we will have to do a bit of string maniplulation to get good results.

If you’re only hear for ready made packages you can scroll down to the downloads, where the packages for PRTG and N-Central can be found.

Getting information from OMReport.exe

Getting information from the OpenManage suite is pretty easy – When you install OpenManage OMReport.exe is added to your path variable, meaning to get the chassis status you can simply open a command prompt on your server and type the command “omreport chassis”.  This reports a visually nice table of information. A very quick and dirty script could be:

$OmReport = omreport chassis | out-string
if($OmReport -Match "Critical"){
$ChassisStatus = $OmReport
} else {
$ChassisStatus = "Healthy"
}

This script does not contain any troubleshooting, error handling, or even a decent way to filter on how the data is displayed. It will simply match the word “Critical” and if its found dump the entire omreport output as a single string, so lets change this up to make sure it’ll give the results like we want it.

To make sure we get cleaner results, we’re going to tell OMReport we don’t want simple data to be returned, but XML data.

For this, we’ll add some commands to the OpenReport CLI tool and tell powershell that the expected output is an XML string. To do that you can do the following:

[xml]$omreport = omreport chassis -fmt xml

After running the command above we can run $omreport to get a list of XML data, pretty useless in its current state, but its actual quite simple to extract usable data out of this. OpenManage OMReport creates an item for each chassis part with its “Computed Object State”, You can query $omreport.oma.Parent for all chassis items. The great thing about this is that you can get advanced metrics by querying the entire object, or just the health statistics by querying the computedobjstatus as follows;

try {
[xml]$OmReport = omreport chassis  -fmt xml | out-string 
}catch{
$ScriptError = "omreport Command has Failed: $($_.Exception.Message)"
exit
}
$intrusionState = $omreport.oma.Parent.intrusion.computedobjstatus.strval
$voltagesState  = $omreport.oma.Parent.voltages.computedobjstatus.strval
$temperaturesState  = $omreport.oma.Parent.temperatures.computedobjstatus.strval
$fansState = $omreport.oma.Parent.fans.computedobjstatus.strval
$currentsState  = $omreport.oma.Parent.currents.computedobjstatus.strval
$powersupplyState = $omreport.oma.Parent.powersupply.computedobjstatus.strval
$powermonitoringState = $omreport.oma.Parent.powermonitoring.computedobjstatus.strval
$processorState  = $omreport.oma.Parent.processor.computedobjstatus.strval
$memoryState = $omreport.oma.Parent.memory.computedobjstatus.strval
$esmlogState = $omreport.oma.Parent.esmlog.computedobjstatus.strval
$batteriesState = $omreport.oma.Parent.batteries.computedobjstatus.strval
$sdcardState = $omreport.oma.Parent.sdcard.computedobjstatus.strval
if(!$ScriptError){ $ScriptError = "Healthy"}

So, after getting this list of information, we can alert on the chassis status simply by calling one of the variables above.

Grabbing the RAID Status via OMReport is slightly trickier. When we use the XML export funtionality we’ve used before we get alot of garbage data and non-descriptive information. To resolve this we’re using another trick out of the monitoring play: converting the data we’ve received to a CSV formatted array.

try {
omconfig preferences cdvformat delimiter=comma
$OmReport = omreport storage vdisk -fmt cdv |  select-string -SimpleMatch "ID,Status," -Context 0,5000
}catch{
$ScriptError = "omreport Command has Failed: $($_.Exception.Message)"
exit
}
$VDarray = convertfrom-csv $OmReport -Delimiter ","
foreach($VirtualDisk in $VDarray){
if($($virtualdisk.State) -eq "Ready" -or $($virtualdisk.Status) -eq "Ok"){
}else{
$RAIDStatus = "$($VirtualDisk.Name) / $($VirtualDisk.'Device Name') Has Status $($VirtualDisk.Status) / $($VirtualDisk.State)"
}
}
if(!$RAIDStatus){ $RAIDStatus = "Healthy"}
if(!$ScriptError){ $ScriptError = "Healthy"}

By running “omconfig preferences cdvformat delimiter=comma” we’re setting the export file to be a comma delimited file, next we set the export format to CDV which Dell believes is a CSV. 😉 By looping this array we get the correct results for the virtual disks. The physical disks work in exactly the same manner;

try {
omconfig preferences cdvformat delimiter=comma
$OmReport = omreport storage pdisk controller=0 -fmt cdv | select-string -SimpleMatch "ID,Status" -Context 0,5000
} catch {
$ScriptError = "omreport Command has Failed: $($_.Exception.Message)"
exit
}
$Parray = convertfrom-csv $OmReport -Delimiter ","
foreach($PhysicalDisk in $Parray){
if($($PhysicalDisk.State) -ne "Online" -or $($PhysicalDisk.Status) -ne "Ok") {
$DiskStatus += "$($PhysicalDisk.Name) / $($PhysicalDisk.'Serial No.') Has Status $($PhysicalDisk.Status) / $($PhysicalDisk.State)`n"
}
if($($PhysicalDisk.'Failure Predicted') -eq "Yes"){
$DiskStatus += "$($PhysicalDisk.Name) / $($PhysicalDisk.'Serial No.') Has a predicted failure error `n"
}
}
if(!$DiskStatus){ $DiskStatus = "Healthy"}
if(!$ScriptError){ $ScriptError = "Healthy"}

For ease of use I’ve included N-Able monitoring script for the Chassis, RAID, and physical disk monitoring

Downloads for RMM packages:

N-Central 11.0+ – Chassis Monitoring

N-Central 11.0+ – RAID Monitoring

N-Central 11.0+ – Physical Disk Monitoring

PRTG – Chassis, VD, RAID monitoring. – COMING SOON.

3 thoughts on “Blog Series: Monitoring using PowerShell: Part two – Using Powershell to monitor Dell systems

  1. Nerdshade

    Hey there,

    Great write up! I’m getting some red text on both the RAID and Physical Disk checks, there seems to be an issue converting the cdv formatted omreport command to xml. I’m running the script exactly as shown in your code boxes. I was wondering if you might be able offer some insight into how to get this working.

    ————————————————————————————————————————————–
    Cannot convert value “> ID,Status,Name,State,Power Status,Bus Protocol,Media,Part of Cache Pool,Remaining Rated Write Endurance,Failure Predicted,Revision,Driver
    Version,Model Number,T10 PI Capable,Certified,Encryption Capable,Encrypted,Progress,Mirror Set ID,Capacity,Used RAID Disk Space,Available RAID Disk Space,Hot
    Spare,Vendor ID,Product ID,Serial No.,Part Number,Negotiated Speed,Capable Speed,PCIe Maximum Link Width,PCIe Negotiated Link Width,Sector Size,Device Write
    Cache,Manufacture Day,Manufacture Week,Manufacture Year,SAS Address
    0:0:0,Ok,Physical Disk 0:0:0,Online,Not Applicable,SATA,HDD,Not Applicable,Not Applicable,No,3BKH,Not Applicable,Not Applicable,No,Not Applicable,No,Not
    Applicable,Not Applicable,Not Applicable,697.56 GB (748999933952 bytes),697.56 GB (748999933952 bytes),0.00 GB (0 bytes),No,ATA,ST3750640NS,5QD2LS1G,Not Available,3.00
    Gbps,3.00 Gbps,Not Applicable,Not Applicable,512B,Not Applicable,Not Available,Not Available,Not Available,1221000000000000
    0:0:1,Non-Critical,Physical Disk 0:0:1,Online,Not Applicable,SATA,HDD,Not Applicable,Not Applicable,Yes,3BKH,Not Applicable,Not Applicable,No,Not Applicable,No,Not
    Applicable,Not Applicable,Not Applicable,697.56 GB (748999933952 bytes),697.56 GB (748999933952 bytes),0.00 GB (0 bytes),No,ATA,ST3750640NS,5QD3AVRW,Not Available,3.00
    Gbps,3.00 Gbps,Not Applicable,Not Applicable,512B,Not Applicable,Not Available,Not Available,Not Available,1221000001000000
    ” to type “System.Xml.XmlDocument”. Error: “The specified node cannot be inserted as the valid child of this node, because the specified node is the wrong type.”
    At line:1 char:1
    + $OmReport = omreport storage pdisk controller=0 -fmt cdv | select-str …
    + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo : MetadataError: (:) [], ArgumentTransformationMetadataException
    + FullyQualifiedErrorId : RuntimeException

    Reply
    1. Kelvin Tegelaar Post author

      Hi NerdShare,

      This is most likely due to running the 3 scripts in one script – That’s not possible because the second two scripts use a CSV instead of XML.

      If you do want to use all threee of them in a single script use the following;

      [code]
      try {
      omconfig preferences cdvformat delimiter=comma
      $OmReportCSV = omreport storage vdisk -fmt cdv | select-string -SimpleMatch “ID,Status,” -Context 0,5000
      }catch{
      $ScriptError = “omreport Command has Failed: $($_.Exception.Message)”
      exit
      }

      $VDarray = convertfrom-csv $OmReportCSV -Delimiter “,”

      foreach($VirtualDisk in $VDarray){
      if($($virtualdisk.State) -eq “Ready” -or $($virtualdisk.Status) -eq “Ok”){
      }else{
      $RAIDStatus = “$($VirtualDisk.Name) / $($VirtualDisk.’Device Name’) Has Status $($VirtualDisk.Status) / $($VirtualDisk.State)”
      }
      }

      if(!$RAIDStatus){ $RAIDStatus = “Healthy”}
      if(!$ScriptError){ $ScriptError = “Healthy”}
      [code]

      Reply

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.