Compare commits

...

5 Commits

Author SHA1 Message Date
Karl-Wilfried Zimmer
8d8b549f0f PrintAffected to GetAffected, will now only print to screen in switch verbose is given 2024-02-09 00:06:54 +01:00
Karl-Wilfried Zimmer
49a6f65a76 PrintAffected to GetAffected, will now only print to screen in switch verbose is given 2024-02-09 00:06:14 +01:00
Karl-Wilfried Zimmer
545d790a8b added function to print all vm names that intersect with point 2024-02-09 00:01:51 +01:00
Karl-Wilfried Zimmer
84e409c096 suppressed printdebug output 2024-02-08 23:56:56 +01:00
Karl-Wilfried Zimmer
71eeccdd5a added function to build a list of intervals from hashtable 2024-02-08 23:54:24 +01:00
2 changed files with 64 additions and 1 deletions

View File

@ -102,4 +102,57 @@ 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
}
function GetAffected {
param (
$listOfIntervals,
[datetime]$point,
[switch] $verbose
)
$array = @()
foreach ($elem in $listOfIntervals){
if ($point -le $elem.ending -and $point -ge $elem.begining){
if ($verbose) {
Write-Host "$point : $($elem.vm) $($elem.state)"
}
if(!$array.Contains($elem.vm)){
$array += @($elem.vm)
}
}
}
return $array
}

View File

@ -12,4 +12,14 @@ snrdaoeisnrdaoie:2024-02-06 20:00:00 some harddrive operation
snrdaoeisnrdaoie:2024-02-06 20:00:00 some other Harddrive operation
snrdaoeisnrdaoie: VMware-Maschine 'test2'
snrdaoeisnrdaoie:aoei aoei VMware-Maschine 'test2'
snrdaoeisnrdaoie:2024-02-06 21:00:00 VMware-Maschine 'test2'
snrdaoeisnrdaoie:2024-02-06 21:00:00 VMware-Maschine 'test2'
snrdaoeisnrdaoie:2024-02-06 20:00:00 gestartet VMware-Maschine 'test'
snrdaoeisnrdaoie:2024-02-06 20:00:00 gestartet VMware-Maschine 'test'
snrdaoeisnrdaoie:2024-02-06 20:00:00 some harddrive operation
nsriadoeisnrdaoei
snrdaoeisnrdaoie:2024-02-06 20:00:00 some other Harddrive operation
snrdaoeisnrdaoie:2024-02-06 20:01:00 VMware-Maschine 'test' Erfolgreiche
snrdaoeisnrdaoie:2024-02-06 20:01:00 VMware-Maschine 'test' Erfolgreiche
snrdaoeisnrdaoie:2024-02-06 20:01:00 VMware-Maschine 'test'
snrdaoeisnrdaoie:2024-02-06 20:00:00 gestartet VMware-Maschine 'test2'