From 71eeccdd5a5dadf352c675a410d4fe180e1be8f0 Mon Sep 17 00:00:00 2001 From: Karl-Wilfried Zimmer Date: Thu, 8 Feb 2024 23:54:24 +0100 Subject: [PATCH] added function to build a list of intervals from hashtable --- Extractor.ps1 | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) 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