Hello everyone
I want to collect the stun times and determine their duration.
The snapshot stun times are logged in each virtual machine's log file (vmware.log)
The log contains this message:
YYYY-MM-DD TIME.544z| vcpu-0 | Checkpoint_Unstun: vm stopped for 403475568 us
How to do it ?
Thank you in advance for your help
You can use the VimDatastore provider.
Unfortunately that PSProvider doesn't have the IContentCmdletProvider interface implemented, so you have to download the file to local storage.
Then it's a matter of reading the file, finding all the 'unstun' messages and extract the info.
Get-VM -Name $vmName -PipelineVariable vm |
ForEach-Object -Process {
$vmxPath = $vm.ExtensionData.Config.Files.VmpathName
$dsObj = Get-Datastore -Name $vmxPath.Split(']')[0].TrimStart('[')
New-PSDrive -Location $dsObj -Name DS -PSProvider VimDatastore -Root "\" | Out-Null
$tempFile = [System.IO.Path]::GetTempFileName()
Copy-DatastoreItem -Item "DS:\$($vm.Name)\vmware.log" -Destination $tempFile
Get-Content -Path $tempFile | where{$_ -match 'Checkpoint_Unstun'} |
ForEach-Object -Process {
$fields = $_.Split('|')
New-Object -TypeName PSObject -Property @{
VM = $vm.Name
Timestamp = [DateTime]$fields[0]
CPU = $fields[1].Trim(' ')
Duration = $fields[2].Split(' ')[6]
}
}
Remove-Item -Path $tempFile -Confirm:$false
Remove-PSDrive -Name DS -Confirm:$false
} | Select-Object VM,Timestamp,Duration
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
How do I get the stun time for a particular date? vmware.log contains multiple stun times and I only care about the times greater than Oct 28 6pm to Oct 29 2am?
Afaik, you will have to read through all the vmware.log files, and use the timestamp on each line.
Blog: lucd.info Twitter: @LucD22 Co-author PowerCLI Reference
Thanks Luc. I will use filters in excel when I export to csv.