Skip to content

Commit bfd0237

Browse files
committed
Fixes thershold interval time conversion
1 parent 6e9f256 commit bfd0237

File tree

2 files changed

+3
-2
lines changed

2 files changed

+3
-2
lines changed

doc/100-General/10-Changelog.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
1919
* [#381](https://github.com/Icinga/icinga-powershell-framework/issues/381) Fixes Repository Hash generator for new repositories, which always returned the same hash regardless of the files inside
2020
* [#386](https://github.com/Icinga/icinga-powershell-framework/pull/386) Fixes check command config generator for Icinga Director baskets/Icinga 2 conf files, in case we are using a check command with an alias as reference to a new name of a check command
2121
* [#387](https://github.com/Icinga/icinga-powershell-framework/pull/387) Fixes config generator to use alias names for command arguments/parameters in case available instead of the real name
22+
* [#390](https://github.com/Icinga/icinga-powershell-framework/pull/390) Fixes threshold interval time conversion by using `-ThresholdInterval` with values that cause the used `TimeSpan` object to move from minutes to hours, like `60m` and `1h`
2223

2324
### Enhancements
2425

lib/icinga/plugin/Compare-IcingaPluginThresholds.psm1

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -61,7 +61,7 @@ function Compare-IcingaPluginThresholds()
6161

6262
if ([string]::IsNullOrEmpty($TimeInterval) -eq $FALSE -And $null -ne $ThresholdCache) {
6363
$TimeSeconds = ConvertTo-Seconds $TimeInterval;
64-
$MinuteInterval = ([TimeSpan]::FromSeconds($TimeSeconds)).Minutes;
64+
$MinuteInterval = [math]::round(([TimeSpan]::FromSeconds($TimeSeconds)).TotalMinutes, 0);
6565
$CheckPerfDataLabel = [string]::Format('{0}_{1}', (Format-IcingaPerfDataLabel $CheckName), $MinuteInterval);
6666

6767
if ($null -ne $ThresholdCache.$CheckPerfDataLabel) {
@@ -96,7 +96,7 @@ function Compare-IcingaPluginThresholds()
9696
$Threshold = $TmpValue.Substring(0, $LastIndex);
9797
$TimeIndex = $TmpValue.Substring($LastIndex + 1, $TmpValue.Length - $LastIndex - 1);
9898
$TimeSeconds = ConvertTo-Seconds $TimeIndex;
99-
$MinuteInterval = ([TimeSpan]::FromSeconds($TimeSeconds)).Minutes;
99+
$MinuteInterval = [math]::round(([TimeSpan]::FromSeconds($TimeSeconds)).TotalMinutes, 0);
100100
101101
$CheckPerfDataLabel = [string]::Format('{0}_{1}', (Format-IcingaPerfDataLabel $CheckName), $MinuteInterval);
102102

0 commit comments

Comments
 (0)