diff --git a/Extractor.ps1 b/Extractor.ps1 index a6fd344..a1307ee 100644 --- a/Extractor.ps1 +++ b/Extractor.ps1 @@ -102,4 +102,37 @@ function ProcessLogToHash { $Path ) ProduceHashMap -Elements $(getElems -Path $Path) +} + +function buildIntervals { + param ( + $hash + ) + $array = @() + foreach ($key in $hash.Keys){ + Write-Host $key + $list = $hash.$key + Write-Host $list + $lastState = $null + $lastTS = $null + foreach ($elem in $list){ + Write-Host $elem + if (($elem.state -eq 'Started') -and ($null -eq $lastState)) { + $lastState=$elem.state + $lastTS=$elem.ts + } + if (($elem.state -ne 'Started') -and ($lastState -eq 'Started')) { + $array += @(New-Object psobject -Property @{ + begining=$lastTS + ending=$elem.ts + state=$elem.state + vm=$key + }) + $lastState=$null + $lastTS=$null + } + Write-Host "$array" + } + } + return $array } \ No newline at end of file