mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2026-02-03 04:09:29 -05:00
This adds new and improved handling for Metrics over Time. The overall execution time for the background tasks has been reduced, while also the memory management is way more efficient. In addition to the improved core handling of the feature, performance metrics for metrics over time will NO LONGER BE WRITTEN. This will increase the performance of the graphing solutions like InfluxDB a lot, while the monitoring by using the "-ThresholdInterval" argument is still possible. ```powershell PS> Invoke-IcingaCheckCPU -Warning '5%' -ThresholdInterval '10m'; [WARNING] CPU Load [WARNING] Overall Load, Socket #0 \_ [WARNING] Overall Load: Value 6.546175% is greater than threshold 5% (10m Avg.) \_ [WARNING] Socket #0 \_ [WARNING] Core 0: Value 18.391566% is greater than threshold 5% (10m Avg.) \_ [WARNING] Core 1: Value 14.100505% is greater than threshold 5% (10m Avg.) \_ [WARNING] Core Total: Value 6.546175% is greater than threshold 5% (10m Avg.) | totalload::ifw_cpu::load=5.804053;5;;0;100 0_0::ifw_cpu::load=18.03764;5;;0;100 0_1::ifw_cpu::load=9.36611;5;;0;100 0_2::ifw_cpu::load=5.830669;5;;0;100 0_3::ifw_cpu::load=0.646737;5;;0;100 0_4::ifw_cpu::load=0.926955;5;;0;100 0_5::ifw_cpu::load=0.016205;5;;0;100 0_total::ifw_cpu::load=5.804053;5;;0;100 ```
38 lines
1.6 KiB
PowerShell
38 lines
1.6 KiB
PowerShell
function Get-IcingaMetricsOverTimePerfData()
|
|
{
|
|
param (
|
|
[switch]$AddWhiteSpace = $FALSE
|
|
);
|
|
|
|
[string]$MetricsOverTime = '';
|
|
[bool]$IsDaemonWorker = $FALSE;
|
|
|
|
if ([string]::IsNullOrEmpty($Global:Icinga.Private.Scheduler.PerfDataWriter.MetricsOverTime) -eq $FALSE) {
|
|
if ($AddWhiteSpace) {
|
|
return (' ' + $Global:Icinga.Private.Scheduler.PerfDataWriter.MetricsOverTime);
|
|
}
|
|
|
|
return $Global:Icinga.Private.Scheduler.PerfDataWriter.MetricsOverTime;
|
|
}
|
|
|
|
if ($Global:Icinga.Public.Daemons.ContainsKey('ServiceCheck') -And $Global:Icinga.Public.Daemons.ServiceCheck.ContainsKey('PerformanceDataCache') -And $Global:Icinga.Public.Daemons.ServiceCheck.PerformanceDataCache.ContainsKey($Global:Icinga.Private.Scheduler.CheckCommand)) {
|
|
$IsDaemonWorker = $TRUE;
|
|
}
|
|
|
|
if ($IsDaemonWorker) {
|
|
$MetricsOverTime = $Global:Icinga.Public.Daemons.ServiceCheck.PerformanceDataCache[$Global:Icinga.Private.Scheduler.CheckCommand];
|
|
} else {
|
|
$PerformanceLabelFile = Join-Path -Path (Join-Path -Path (Join-Path -Path (Get-IcingaCacheDir) -ChildPath 'service_check_cache') -ChildPath 'performance_labels') -ChildPath ([string]::Format('{0}.db', $Global:Icinga.Private.Scheduler.CheckCommand));
|
|
if (Test-Path -Path $PerformanceLabelFile) {
|
|
$MetricsOverTime = Get-Content -Path $PerformanceLabelFile -Raw;
|
|
}
|
|
}
|
|
|
|
$Global:Icinga.Private.Scheduler.PerfDataWriter.MetricsOverTime = $MetricsOverTime;
|
|
|
|
if ([string]::IsNullOrEmpty($MetricsOverTime) -eq $FALSE -And $AddWhiteSpace) {
|
|
$MetricsOverTime = ' ' + $MetricsOverTime;
|
|
}
|
|
|
|
return $MetricsOverTime;
|
|
}
|