mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2026-02-03 12:19:29 -05:00
* Set maximum cache duration for service daemons to the right value This commit sets the maximum duration for cached data for service daemons to the proper amount. Previously it was multiplied by 60, probably a typo from a time when the assigned value was in minutes and not in seconds directly. Therefore the value was 60 times to high which leads to a massive amount of cached data which drags down the performance significantly. * Updates changelog --------- Co-authored-by: Lord Hepipud <contact@lordhepipud.de>
61 lines
2.2 KiB
PowerShell
61 lines
2.2 KiB
PowerShell
function New-IcingaServiceCheckDaemonEnvironment()
|
|
{
|
|
param (
|
|
$CheckCommand,
|
|
$Arguments,
|
|
$TimeIndexes
|
|
);
|
|
|
|
if ($Global:Icinga.Public.Daemons.ServiceCheck.PerformanceDataCache.ContainsKey($CheckCommand) -eq $FALSE) {
|
|
$Global:Icinga.Public.Daemons.ServiceCheck.PerformanceDataCache.Add(
|
|
$CheckCommand, @{ }
|
|
);
|
|
}
|
|
|
|
$Global:Icinga.Private.Daemons.Add(
|
|
'ServiceCheck',
|
|
@{
|
|
'PassedTime' = 0;
|
|
'SortedResult' = $null;
|
|
'PerformanceCache' = @{ };
|
|
'AverageCalculation' = @{ };
|
|
'MaxTime' = 0;
|
|
'MaxTimeInSeconds' = 0;
|
|
}
|
|
);
|
|
|
|
foreach ($index in $TimeIndexes) {
|
|
# Only allow numeric index values
|
|
if ((Test-Numeric (ConvertTo-Seconds $index)) -eq $FALSE) {
|
|
Write-IcingaEventMessage -EventId 1450 -Namespace 'Framework' -Objects $CheckCommand, ($Arguments | Out-String), ($TimeIndexes | Out-String), $index;
|
|
continue;
|
|
}
|
|
if ($Global:Icinga.Private.Daemons.ServiceCheck.AverageCalculation.ContainsKey([string]$index) -eq $FALSE) {
|
|
$Global:Icinga.Private.Daemons.ServiceCheck.AverageCalculation.Add(
|
|
[string]$index,
|
|
@{
|
|
'Interval' = ([int]($index -Replace '[^0-9]', ''));
|
|
'RawInterval' = $index;
|
|
'Time' = (ConvertTo-Seconds $index);
|
|
'Sum' = 0;
|
|
'Count' = 0;
|
|
}
|
|
);
|
|
}
|
|
if ($Global:Icinga.Private.Daemons.ServiceCheck.MaxTime -le (ConvertTo-Seconds $index)) {
|
|
$Global:Icinga.Private.Daemons.ServiceCheck.MaxTime = (ConvertTo-Seconds $index);
|
|
}
|
|
}
|
|
|
|
$Global:Icinga.Private.Daemons.ServiceCheck.MaxTimeInSeconds = $Global:Icinga.Private.Daemons.ServiceCheck.MaxTime;
|
|
|
|
if ($Global:Icinga.Private.Scheduler.CheckData.ContainsKey($CheckCommand) -eq $FALSE) {
|
|
$Global:Icinga.Private.Scheduler.CheckData.Add(
|
|
$CheckCommand,
|
|
@{
|
|
'results' = @{ };
|
|
'average' = (New-Object -TypeName PSObject);
|
|
}
|
|
);
|
|
}
|
|
}
|