Automation

 View Only
  • 1.  Check vm iops on a certain datastore

    Posted Mar 20, 2014 02:17 PM

    Hello, I foun numerious script but I don't think they give me the correct result.

    I'am looking for a powerhell script to connect to my vcenter that can give me the iops of all the vm's running on that nfs datastore.

    I would like to retrieve the same info as If I was looking with esxtop on a esx machine.

    Does anyone has a script like this.



  • 2.  RE: Check vm iops on a certain datastore

    Posted Mar 20, 2014 03:12 PM

    Hello,

    mainly based in the "nfs datastore version" script from LucD vmware communities user, i guess this script should do the trick! :smileywink:

    $datastoreName = "NameOfTheDatastore"

    $metrics = "virtualdisk.numberwriteaveraged.average","virtualdisk.numberreadaveraged.average"

    $start = (Get-Date).AddMinutes(-5)

    $report = @()

    $vms = Get-VM | where {$_.PowerState -eq "PoweredOn"}

    $stats = Get-Stat -Realtime -Stat $metrics -Entity $vms -Start $start

    $interval = $stats[0].IntervalSecs

    $hdTab = @{}

    foreach($hd in (Get-Harddisk -VM $vms)){

        $controllerKey = $hd.Extensiondata.ControllerKey

        $controller = $hd.Parent.Extensiondata.Config.Hardware.Device | where{$_.Key -eq $controllerKey}

        $hdTab[$hd.Parent.Name + "/scsi" + $controller.BusNumber + ":" + $hd.Extensiondata.UnitNumber] = $hd.FileName.Split(']')[0].TrimStart('[')

    }

    $report = $stats | Group-Object -Property {$_.Entity.Name},Instance | %{

        New-Object PSObject -Property @{

            VM = $_.Values[0]

            Disk = $_.Values[1]

            IOPSMax = ($_.Group | `

                Group-Object -Property Timestamp | `

                %{$_.Group[0].Value + $_.Group[1].Value} | `

                Measure-Object -Maximum).Maximum / $interval

        IOPSAvg = ($_.Group | `

                Group-Object -Property Timestamp | `

                %{$_.Group[0].Value + $_.Group[1].Value} | `

                Measure-Object -Average).Average / $interval

            Datastore = $hdTab[$_.Values[0] + "/"+ $_.Values[1]]

        }

    }

    $report | Where-object { ($_.Datastore -match $datastoreName) }

    Set the variable of $datastoreName to the name of your datastore.

    I would like to comment that this script shows the maximum and average IOPS values over the last 5 minutes

    Hope this helps you :smileyhappy:

    Best regards,

    Pablo



  • 3.  RE: Check vm iops on a certain datastore

    Posted Mar 20, 2014 03:34 PM

    Thanks, for the script, but where is the differents between your script and when i look with esxtop on the esx server to that vm.

    The info is totally different?

    IOPSMax   : 63,9

    Disk      : scsi0:0

    Datastore
    : NFS_DEV02_NS-DCO04_HYBRID

    VM        : crslv005

    IOPSMax   : 0,65

    Disk      : scsi0:1

    Datastore
    : NFS_DEV02_NS-DCO04_HYBRID

    VM        : crslv005

    esxtop :

    crslv005          read/s 266.08   write/s 262.26    



  • 4.  RE: Check vm iops on a certain datastore

    Posted Mar 20, 2014 05:14 PM

    Hello,

    when using powercli you're not really getting realtime statics like when using esxtop.

    With "realtime" PowerCLI and vSphere statics, Vsphere is getting/storing the values every 20 seconds.

    Then, the "virtualdisk.numberwriteaveraged.average" and "virtualdisk.numberreadaveraged.average" are counters that are the average of the values collected over the last 20 seconds.

    You can notice what i commented above, checking the output.csv file that generates the below script:

    $metrics = "virtualdisk.numberwriteaveraged.average","virtualdisk.numberreadaveraged.average"

    $start = (Get-Date).AddMinutes(-5)

    $report = @()

    $vms = Get-VM | where {$_.PowerState -eq "PoweredOn"}

    $stats = Get-Stat -Realtime -Stat $metrics -Entity $vms -Start $start

    $stats | export-csv output.csv

    I would like to comment, that the values stored in the csv file are from the last 5 minutes time period.

    If you want to use esxtop to monitor disk throughput/usage, maybe it will be a good idea to capture and analyze the data.

    Best regards,

    Pablo



  • 5.  RE: Check vm iops on a certain datastore

    Posted Mar 21, 2014 03:27 PM

    Ok thnx



  • 6.  RE: Check vm iops on a certain datastore
    Best Answer

    Posted Mar 21, 2014 05:57 PM

    You welcome :smileyhappy:

    Please, remember to award if any answer was correct/helpful.

    Best regards,

    Pablo