<?xml version="1.0" encoding="UTF-8"?>
<rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:rdf="http://www.w3.org/1999/02/22-rdf-syntax-ns#" xmlns:taxo="http://purl.org/rss/1.0/modules/taxonomy/" version="2.0">
  <channel>
    <title>topic Re: Script that looks at disk device usage (%USD in ESXtop) in VMware PowerCLI Discussions</title>
    <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-that-looks-at-disk-device-usage-USD-in-ESXtop/m-p/2925811#M108028</link>
    <description>&lt;P&gt;The Get-EsxTop cmdlet is a bit of hard nut to crack.&lt;BR /&gt;I did some attempts, see &lt;A href="https://www.lucd.info/?s=get-esxtop" target="_blank" rel="noopener"&gt;here&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Using the definition in&amp;nbsp;&lt;SPAN&gt;&lt;A href="https://communities.vmware.com/t5/Storage-Performance/Interpreting-esxtop-Statistics/ta-p/2776936" target="_blank" rel="noopener"&gt;Interpreting esxtop Statistics&lt;/A&gt; (section 4.2.1) for %USD, I came up with something like this.&lt;BR /&gt;Note that the loop sleeps for 5 seconds, because that is the esxtop interval.&lt;BR /&gt;&lt;BR /&gt;Can you check if this indeed returns 100% for %USD for the disk involved?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;$device = 'mpx.vmhba32:C0:T0:L0'

while($true){
  $result = Get-EsxTop -CounterName SCSIDevice | where{$_.DeviceName -eq $device}
  $actv = $result | Select-Object -ExpandProperty NumOfActiveCommands
  $qlen = $result | Select-Object -ExpandProperty QueueDepth
  $usd = $actv/$qlen
  Write-Host "$(Get-Date -Format hh:mm:ss.ffff ) %USD = $usd"
  Start-Sleep -Seconds 5
}
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
    <pubDate>Thu, 25 Aug 2022 12:52:21 GMT</pubDate>
    <dc:creator>LucD</dc:creator>
    <dc:date>2022-08-25T12:52:21Z</dc:date>
    <item>
      <title>Script that looks at disk device usage (%USD in ESXtop)</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-that-looks-at-disk-device-usage-USD-in-ESXtop/m-p/2925799#M108026</link>
      <description>&lt;P&gt;Hey guys,&lt;/P&gt;&lt;P&gt;Im trying to figure out how i can monitor the disk usage through PowerCLI but im getting stuck.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;Currently i have a script that is going through the VMKernel log and filters on "*failed H:0x7*"&amp;nbsp; Which should indicate that an iscsi device has failed working (we got those errors on host on which the SD-card was failing).&lt;/P&gt;&lt;P&gt;I wanted to add a script that looks at the usage of the SD card (called&amp;nbsp;mpx.vmhba32:C0:T0:L0) because if the SD card was degraded, its usage would be 100% onder ESXITOP command (%USD would be 100).&lt;/P&gt;&lt;P&gt;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.&lt;/P&gt;&lt;P&gt;For those wondering, this is my current PowerCLI script (it still is a work in progress thing):&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Connect-VIServer %vCentername%&lt;/P&gt;&lt;P&gt;$VMhosts = Get-VMHost -PipelineVariable esxihost&lt;/P&gt;&lt;P&gt;$value = ForEach ($VMhost in $VMhosts) {&lt;/P&gt;&lt;P&gt;$esxcli = get-vmhost $VMhost | Get-EsxCli&lt;/P&gt;&lt;P&gt;$esxcli.VMHost.Name&lt;BR /&gt;(Get-Log -VMHost (Get-VMHost $esxcli.VMHost.Name) vmkernel).Entries | Where {$_ -like “*failed H:0x7*“}&lt;BR /&gt;}&lt;BR /&gt;$attachment = "c:\temp\logs.txt"&lt;/P&gt;&lt;P&gt;$value | Out-File $attachment&lt;/P&gt;&lt;P&gt;if ($value -like "*failed H:0x7*")&lt;BR /&gt;{&lt;BR /&gt;Send-MailMessage -To “&amp;lt;recipient’s email address&amp;gt;” -From “&amp;lt;sender’s email address&amp;gt;” -Subject “xxx” -Body “xxx” -Attachments $attachment -Credential (Get-Credential) -SmtpServer “&amp;lt;smtp server&amp;gt;” -Port 587&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;else&lt;BR /&gt;{&lt;BR /&gt;Write-Host "its all good"&lt;BR /&gt;}&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 11:58:54 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-that-looks-at-disk-device-usage-USD-in-ESXtop/m-p/2925799#M108026</guid>
      <dc:creator>San-Infinity</dc:creator>
      <dc:date>2022-08-25T11:58:54Z</dc:date>
    </item>
    <item>
      <title>Re: Script that looks at disk device usage (%USD in ESXtop)</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-that-looks-at-disk-device-usage-USD-in-ESXtop/m-p/2925811#M108028</link>
      <description>&lt;P&gt;The Get-EsxTop cmdlet is a bit of hard nut to crack.&lt;BR /&gt;I did some attempts, see &lt;A href="https://www.lucd.info/?s=get-esxtop" target="_blank" rel="noopener"&gt;here&lt;/A&gt;&amp;nbsp;&lt;BR /&gt;&lt;BR /&gt;Using the definition in&amp;nbsp;&lt;SPAN&gt;&lt;A href="https://communities.vmware.com/t5/Storage-Performance/Interpreting-esxtop-Statistics/ta-p/2776936" target="_blank" rel="noopener"&gt;Interpreting esxtop Statistics&lt;/A&gt; (section 4.2.1) for %USD, I came up with something like this.&lt;BR /&gt;Note that the loop sleeps for 5 seconds, because that is the esxtop interval.&lt;BR /&gt;&lt;BR /&gt;Can you check if this indeed returns 100% for %USD for the disk involved?&lt;BR /&gt;&lt;/SPAN&gt;&lt;/P&gt;
&lt;LI-CODE lang="csharp"&gt;$device = 'mpx.vmhba32:C0:T0:L0'

while($true){
  $result = Get-EsxTop -CounterName SCSIDevice | where{$_.DeviceName -eq $device}
  $actv = $result | Select-Object -ExpandProperty NumOfActiveCommands
  $qlen = $result | Select-Object -ExpandProperty QueueDepth
  $usd = $actv/$qlen
  Write-Host "$(Get-Date -Format hh:mm:ss.ffff ) %USD = $usd"
  Start-Sleep -Seconds 5
}
&lt;/LI-CODE&gt;
&lt;P&gt;&lt;SPAN&gt;&amp;nbsp;&lt;/SPAN&gt;&lt;/P&gt;</description>
      <pubDate>Thu, 25 Aug 2022 12:52:21 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-that-looks-at-disk-device-usage-USD-in-ESXtop/m-p/2925811#M108028</guid>
      <dc:creator>LucD</dc:creator>
      <dc:date>2022-08-25T12:52:21Z</dc:date>
    </item>
    <item>
      <title>Re: Script that looks at disk device usage (%USD in ESXtop)</title>
      <link>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-that-looks-at-disk-device-usage-USD-in-ESXtop/m-p/2925937#M108039</link>
      <description>&lt;P&gt;Thanks man! To be honest, i didnt expected a reply that fast. I really appreciate this&amp;nbsp;&lt;img class="lia-deferred-image lia-image-emoji" src="https://communities.vmware.com/html/@331907B6FCE46F0C5C3BDC0924ECA432/emoticons/1f64f.png" alt=":folded_hands:" title=":folded_hands:" /&gt;. VMware really has an awesome community.&lt;/P&gt;&lt;P&gt;&amp;nbsp;&lt;/P&gt;&lt;P&gt;Im going to test the script today&amp;nbsp; and see if it fits my case and ill update this post with the new script (for others to use if they want, i know ive used a bunch of scripts ive found on this forum!).&amp;nbsp;&lt;/P&gt;&lt;P&gt;EDIT:&lt;/P&gt;&lt;P&gt;Hands down! I bow to thee sir. The script does exactly what i wanted/asked for. I still need to delve into the "why" but i have found your blog on it and definitely am going to take a read. You just got yourself a new fan!&lt;/P&gt;</description>
      <pubDate>Fri, 26 Aug 2022 08:57:43 GMT</pubDate>
      <guid>https://communities.vmware.com/t5/VMware-PowerCLI-Discussions/Script-that-looks-at-disk-device-usage-USD-in-ESXtop/m-p/2925937#M108039</guid>
      <dc:creator>San-Infinity</dc:creator>
      <dc:date>2022-08-26T08:57:43Z</dc:date>
    </item>
  </channel>
</rss>

