Quantcast
Channel: VMware Communities : Discussion List - All Communities
Viewing all articles
Browse latest Browse all 193198

PowerCLI script for NFS Datastores

$
0
0

Hi

I have the following powershell script and this is new to me. What do I need to add to it in order to retrive a weeks worth of IO stats and also have it exported to a csv file.

Thanks.

$metrics = "virtualdisk.numberwriteaveraged.average","virtualdisk.numberreadaveraged.average"
$start = (Get-Date).AddMinutes(-5)
$report = @()

$vms = Get-VM | where {$_.PowerState -eq "PoweredOn"}
# vCenter Login Variables
$sVCentre = ""    # holds the fqdn or ip of the vcenter server.
$sVCUser = ""# holds the login name used to login to vcenter, local or domain
$sVCPwd = ""    # the password for vcenter login in clear txt.
$strVMWildCard = "*"    # use * for all machine, or use wildcard to limit, eg : "Sol*" for machines begining Sol
$strOutputLocation = "C:\" # The default output location for for results, the file name is generated - just provide the path.

# add VMware PS snapin
if (-not (Get-PSSnapin VMware.VimAutomation.Core -ErrorAction SilentlyContinue)) {
    Add-PSSnapin VMware.VimAutomation.Core
}

## Begin Script

#Connect to VC
Connect-VIServer $sVCentre -User $sVCUser -Password $sVCPwd -ea silentlycontinue

$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
        Datastore = $hdTab[$_.Values[0] + "/"+ $_.Values[1]]
    }
}

$report


Viewing all articles
Browse latest Browse all 193198

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>