Memory usage reports on hosts and VM's.

WE are using Vsphere 4 and want to show some memory usage reports on our ESX hosts in specific clusters and for some VM's.  I think our memory is beginning to be heavily utilised and want to show in reports  so that i can present to management and get a case fro more hosts or memory.


We have a cluster A and have 4 hosts and there memory % is now over 80 %.  I see this in the VI client int the hosts tab of the cluster.  Is there a report I can run which shows some memory counters and their values for 5 days Mon - Fri for the times 9am - 6pm, and show the average values.  As for the memory counters would it be memory usage % or any other memory counters ?


I want to show the memory usage of the VM's which have 4GB or more memory as I dont think they need 4GB memory.  I have these VM's listed but need to show some memory counters which shows the memory usage for Mon - Fri for times 9am -6pm.   Would like to show the Average, and max values.  As for the memory counters would that active memory ot memory utlisation %.

I know you can use the get-stat command to show reports, but can you advise on the best method.


0 Kudos
1 Reply

For a sample of a script that reports on specific time ranges for specific days of the week, have a look at my PowerCLI & vSphere statistics – Part 2 – Come together post. In the section Business hours/working days you will find a script that does this.

For the metrics I would always include the mem.usage.average (or if prefer MB values instead of percentages).

A sample script for the hosts report

$clusterName = "MyCluster" 
$esxImpl =  Get-Cluster -Name $clusterName | Get-VMHost $todayMidnight = (Get-Date -Hour 0 -Minute 0 -Second 0).AddMinutes(-1) $workingDays = "Monday","Tuesday","Wednesday","Thursday","Friday"
$dayStart = New-Object DateTime(1,1,1,9,0,0)     # 09:00 AM
$dayEnd = New-Object DateTime(1,1,1,18,0,0)      # 06:00 PM
$start = $todayMidnight.AddDays(-8) $finish = $todayMidnight.AddDays(-1) $stats = Get-Stat -Entity $esxImpl -Stat cpu.usage.average -Start $$start -Finish $finish
$report = $stats | Where-Object {     $workingDays -contains $_.Timestamp.DayOfWeek -and
    $_.Timestamp.TimeOfDay -gt $dayStart.TimeOfDay -and
$_.Timestamp.TimeOfDay -lt $dayEnd.TimeOfDay } | Select @{N="Host";E={$_.Entity.Name}},Timestamp,Value $report | Export-Csv "C:\BusinessHours-cpu.csv" -NoTypeInformation -UseCulture

The report for the VMs can be done in a similar way, just change the value you pass on the Entity parameter.

Blog:  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos