• hi@yahyazahedi.com
  • Germany

Estimation of VM change rate in different time intervals (minutes, hours, daily)

A question on one of the projects came up recently about how to see the disk change of virtual machines for a specified period of time. We were planning for replication between sites and the customer wants to know how much bandwidth does it need for replication of virtual machines. Actually, he would like to know what the bandwidth between two sites should be for a 15 minute RPO, and which RPO is the current bandwidth suitable for? They do not have monitoring tools and do not decide to install the monitoring system. I couldn’t find a way to see all the disk writes for virtual machines in a datacenter in VMware, but I did find a real-time change to a VM’s virtual disk that works great and makes it easy to find out how many writes are being sent to storage. I also briefly searched for a free monitoring tool but no luck! (Of course, I did not search well, if you know, I would appreciate it if you could give me some information)

As you can see in the figure above, we use vCenter’s Advanced Performance feature to determine the write rate in real-time. That’s a good solution, but it’s not enough because I need the disk writes for all the virtual machines in the data center. So I need to find a way to sum this value for each virtual machine and then I can determine how many writes are sent to storage and how much data changes in a given period of time.

So I started to write a script! I think the script itself is good and complete and can easily get all the writes of the virtual machines in a data center at different time intervals. I want to share the script with you so that firstly my mistake is recognized and secondly it may be useful for you too.

#######
# Connect to vCenter Server
#######

Connect-VIServer -Server "vCenter IP Address" -User "Your Username" -Password "Your Password"

#######
# Create a new table to store the write rate along with the timestamp
#######

$table = @()

#######
# Retrieve all powered virtual machines in the data center, filtering according to your own requirements, e.g. all virtual machines in a specific host or datastore
#######

$vms = @((Get-VM | where {$_.PowerState -eq "PoweredOn"}) | Sort Name)

#######
# Specify how long you want the script to run. If you want it to run for 15 minutes, please enter "-Minutes 15"
#######

$timeout = new-timespan -Hours 8

#######
# Calculation of hard disk write rate of each virtual machine and sum per time unit
#######

$sw = [diagnostics.stopwatch]::StartNew()
while ($sw.elapsed -lt $timeout){
$writedata = 0 ;
foreach ($VM in $VMs){
	Get-Stat -Entity $vm -Stat "disk.write.average" -maxsamples 1 -Realtime -Instance "" | %{
		$Details = "" | select Time, Writedata
        $Details.Time = $_.Timestamp
        $writedata += $_.Value
        $Details.Writedata = $writedata		
	}
}

#######
# Specify the interval at which the script should be executed
#######

start-sleep -seconds 60
$table += $Details
}

#######
# Specify output location 
#######

$table | Export-Csv C:\dailychange.csv -NoTypeInformation

As you can see in the following figure, I get the virtual machine write rate in KB (KiloByte) for each minute, In other words, it shows minute-by-minute changes in my environment, and since my environment is just a test, the value of the numbers are low!

Let’s import the data into a program like Excel and calculate the date change for 8 hours with an interval of 1 minute. In these 8 hours, 475 records were set and about 100 MB were written in this environment.

I hI hope you find this informative and I’m eager to receive your feedback.

Share Post on:

5 thoughts on “Estimation of VM change rate in different time intervals (minutes, hours, daily)

Leave a Reply

Your email address will not be published. Required fields are marked *