VMware Cloud Community
Mirian5
Contributor
Contributor

calculate the average memory used

Script to calculate the average memory used in a given time. for example: period of 5 days. It's possible?

0 Kudos
5 Replies
LucD
Leadership
Leadership

Yes, but remember that statistics are aggregated


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Mirian5
Contributor
Contributor

Please, could you send an example of the script creation to calculate the memory used in a certain period?

0 Kudos
LucD
Leadership
Leadership

Did you search this community?
There are quite a few examples available, for example Solved: Re: Get VMs CPU and Memory Daily Usage - VMware Technology Network VMTN


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

Mirian5
Contributor
Contributor

Thanks for the tip.

I'm trying to add a field with the information of the average in a certain period, in this script below:

$report += Get-Folder -Name 'nome_da_pasta' | Get-VM |
Select Name,MemoryGB,
@{N='UsedMemoryGB';E={$_.ExtensionData.Summary.Quickstats.GuestMemoryUsage}}

#$_.ExtensionData.Summary.Quickstats.GuestMemoryUsage
}

$report | Export-Csv -Path $log -NoTypeInformation -UseCulture

if ((Get-Content $log) -ne $null)
{
Add-PSSnapin Microsoft.Exchange.Management.Powershell.Admin -erroraction silentlyContinue
$msg = new-object Net.Mail.MailMessage
$smtp = new-object Net.Mail.SmtpClient($smtpServer)
$att = new-object Net.Mail.Attachment($log)
$msg.From = $from
$msg.To.Add($to)
$msg.Subject = "[VCENTER] Relatório de consumo de recursos PRD - $data"
$msg.Attachments.Add($att)
$msg.IsBodyHTML = $true
$body = @"
Relatório de consumos de recursos PRD ON PREMISE por pasta na data de $data.


"@
$msg.body = $body
$smtp = New-Object Net.Mail.SmtpClient($SmtpServer, 587)
$smtp.EnableSsl = $true
$user = "AKIAWJ54FS3T366IGXWY"
$password = "BH1Ko2CLzTE1oNBD5/FoWiTIuP5Jg7Z+ieUScKiuhntq"

$smtp.Credentials = New-Object System.Net.NetworkCredential($user, $password);
$smtp.Send($msg)
}

if (Test-Path $log)
{
Remove-Item $log -Force -ErrorAction: Ignore
}

}

- but i'm not succeeding

0 Kudos
LucD
Leadership
Leadership

How did you try to use the Get-Stat cmdlet?


Blog: lucd.info  Twitter: @LucD22  Co-author PowerCLI Reference

0 Kudos