added function to build a list of intervals from hashtable
This commit is contained in:
parent
e8d0c0cd6c
commit
71eeccdd5a
@ -103,3 +103,36 @@ function ProcessLogToHash {
|
||||
)
|
||||
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
|
||||
}
|
Loading…
Reference in New Issue
Block a user