mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2025-12-27 18:19:56 -05:00
Improved performance while loading All Perf Counter instances
Improved performance for loading all performance counter instances with '*' by adding the sleep after the initialisation of all counters instead for each single one without having to handle the sleep skip manually
This commit is contained in:
parent
f07a14ec67
commit
8103341388
1 changed files with 7 additions and 1 deletions
|
|
@ -67,12 +67,18 @@
|
|||
$CounterInstances = New-Object System.Diagnostics.PerformanceCounterCategory($UseCounterCategory);
|
||||
foreach ($instance in $CounterInstances.GetInstanceNames()) {
|
||||
[string]$NewCounterName = $Counter.Replace('*', $instance);
|
||||
$NewCounter = New-IcingaPerformanceCounterObject -FullName $NewCounterName -Category $UseCounterCategory -Counter $UseCounterName -Instance $instance -SkipWait $SkipWait;
|
||||
$NewCounter = New-IcingaPerformanceCounterObject -FullName $NewCounterName -Category $UseCounterCategory -Counter $UseCounterName -Instance $instance -SkipWait $TRUE;
|
||||
$AllCountersIntances += $NewCounter;
|
||||
}
|
||||
} catch {
|
||||
return (New-IcingaPerformanceCounterNullObject -FullName $Counter -ErrorMessage ([string]::Format('Failed to deserialize instances for counter "{0}". Exception: "{1}".', $Counter, $_.Exception.Message)));
|
||||
}
|
||||
|
||||
# If we load multiple instances, we should add a global wait here instead of a wait for each single instance
|
||||
# This will speed up CPU loading for example with plenty of cores avaiable
|
||||
if ($SkipWait -eq $FALSE) {
|
||||
Start-Sleep -Milliseconds 500;
|
||||
}
|
||||
|
||||
# Add the parent counter including the array of Performance Counters to our
|
||||
# caching mechanism and return the New-IcingaPerformanceCounterResult object for usage
|
||||
|
|
|
|||
Loading…
Reference in a new issue