Hey guys,
Im trying to figure out how i can monitor the disk usage through PowerCLI but im getting stuck.
Currently a company im working for have installed SD-Cards as their boot device. They also have a scratch location on it. These SD-cards have started to degrade after years of usage, to the point the ESXi node stops working. We are working on replacing them.
The company has asked me to find ways to monitor whether an SD-Cards starts acting out, so we could preemptively put the host in maintenance and start swapping the SD-card out with another one.
Currently i have a script that is going through the VMKernel log and filters on "*failed H:0x7*" Which should indicate that an iscsi device has failed working (we got those errors on host on which the SD-card was failing).
I wanted to add a script that looks at the usage of the SD card (called mpx.vmhba32:C0:T0:L0) because if the SD card was degraded, its usage would be 100% onder ESXITOP command (%USD would be 100).
But i sadly cant figure it out. I tried the get-esxtop command but i cant figure out if i can filter it on getting the disk device % usage like ESXTOP command (with the switch "u") does.
For those wondering, this is my current PowerCLI script (it still is a work in progress thing):
Connect-VIServer %vCentername%
$VMhosts = Get-VMHost -PipelineVariable esxihost
$value = ForEach ($VMhost in $VMhosts) {
$esxcli = get-vmhost $VMhost | Get-EsxCli
$esxcli.VMHost.Name
(Get-Log -VMHost (Get-VMHost $esxcli.VMHost.Name) vmkernel).Entries | Where {$_ -like “*failed H:0x7*“}
}
$attachment = "c:\temp\logs.txt"
$value | Out-File $attachment
if ($value -like "*failed H:0x7*")
{
Send-MailMessage -To “<recipient’s email address>” -From “<sender’s email address>” -Subject “xxx” -Body “xxx” -Attachments $attachment -Credential (Get-Credential) -SmtpServer “<smtp server>” -Port 587
}
else
{
Write-Host "its all good"
}