Scooby Doo can doo-doo, but Jimmy Carter is SMARTer
Ok, that was weak… let’s still try to turn this blog post around to a good one and let me show you how you can be SMARTer by getting relevant SMART information out of your local disk devices within your ESXi host (Which can be really useful for vSAN / hyperconverged environments with local devices).
Thanks to Get-ESXCLI (v2) we are able to access easily the local ESXCLI tool via PowerCLI 6.3 R1++. Since there is a ESXCLI Namespace Method to access the SMART data of local disks we are going to use this in the following script.
# Change Parameter $vCenter = 'vcsa01.lenzker.local' $ClusterName ='CL01' $outputfile = 'c:\temp\smart.csv' #codeblock Connect-VIServer $vCenter $resultList = @() $Cluster = Get-Cluster -Name $ClusterName $ESXs = $Cluster | Get-VMHost | Where {$_.ConnectionState -eq 'Connected'} Foreach ($ESX in $ESXs){ $scsidevs = $ESX | Get-Scsilun | Where {$_.isLocal -eq $True -AND $_.canonicalName -notmatch 'mpx'} $esxcli = $ESX | Get-ESXCLI -v2 $arguments = $esxcli.storage.core.device.smart.get.CreateArgs() foreach ($scsidev in $scsidevs){ write-host "Gathering Smart-Data from $scsidev.canonicalName" $arguments.devicename = $scsidev.canonicalName $smart = $esxcli.storage.core.device.smart.get.Invoke($arguments) $healthstatus = ($smart | Where {$_.Parameter -contains 'Health Status'}).Value $readerror = ($smart | Where {$_.Parameter -like'Read Error Count'}).Value $writeerror = ($smart | Where {$_.Parameter -contains 'Write Error Count'}).Value $temperature = ($smart | Where {$_.Parameter -contains 'Drive Temperature'}).Value $resultList += New-Object -TypeName PSCustomObject -Property @{ esx = $ESX.Name devname = $arguments.devicename healthstatus = $healthstatus readerror = $readerror writeerror = $writeerror temperature = $temperature } | Select esx, devname, healthstatus, readerror, writeerror, temperature } } $resultfile = $resultList | export-csv -Path $outputfile -notype |
et voila…it will discover all local devices and exports the relevant information into a CSV file.
you can find the script here.