Pulling Average VM Network Usage En Masse

One of my customers is considering moving some of their infrastructure around and wanted to get an idea about how their WAN connection might be impacted by the move.  They didn't have vROPS and we didn't want to enable greater vCenter logging due to space constraints on the SQL server (that tells you that we're working with some older systems, doesn't it!).  So, I decided that our best course of action would be to write a script that could run on an interval, collecting and summarizing the real-time statistics that we actually needed.  Hence the creation of summarize-VMNetUsage.ps1!

This is a pretty straightforward script.  If you run it without any parameters, it will find the highest 20 second Average Network Usage stats from all VMs in an environment, then return a summary of its findings: VM Count, sum, average, maximum, minimum, and a date-stamp.  Then, the script enters a holding pattern until 1 hour has passed and it starts the process again.  It does this for 24 hours, then spits out a table of those summarizations, so that you can see the sum total network traffic for each of those network averages (which is a worst-case scenario, since it shows the peak network activity during the interval, including east-west traffic which would not traverse the WAN), as well as those other potentially useful numbers.  Based on that, you can use your favorite statistical tricks (like standard deviation) to ballpark the network impact of moving those VMs.

How's it do it?  At its core, it just runs get-stat -stat "net.usage.average" -realtime on every VM and then aggregates and summarizes that data.  It will return the data as a table, so when you execute the script, I'd recommend either capturing it in a variable or writing it directly into a CSV like this: summarize-VMNetUsage.ps1 | write-csv C:\temp\netSummary.csv.  By default the script polls vCenter every 60 minutes and runs for 24 hours, but those numbers can be changed via the intervalMinutes and durationHours parameters.  You can probably guess what each of those options does, so I'll just move on to the code itself ;)

Comments

Popular posts from this blog

PowerShell Sorting by Multiple Columns

Clone a Standard vSwitch from one ESXi Host to Another

Deleting Orphaned (AKA Zombie) VMDK Files