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