From 044ba4bf03d7e6a18a684748f87cc934f4fca80a Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Thu, 20 Aug 2020 10:06:50 +0200 Subject: [PATCH] Fix perfdata value output on variable overflow --- doc/31-Changelog.md | 2 +- lib/core/perfcounter/New-IcingaPerformanceCounterObject.psm1 | 2 +- lib/core/tools/Format-IcingaPerfDataValue.psm1 | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/doc/31-Changelog.md b/doc/31-Changelog.md index 3be0d2d..4fa0d2b 100644 --- a/doc/31-Changelog.md +++ b/doc/31-Changelog.md @@ -50,7 +50,7 @@ Check Command configuration generated by Icinga for Windows 1.2.0 require Icinga * [#91](https://github.com/Icinga/icinga-powershell-framework/issues/91) Fix wrong default values being set for installer arguments by using the Icinga Director Self-Service API * [#92](https://github.com/Icinga/icinga-powershell-framework/issues/92) Fix `Set-IcingaAcl` which fails on older Windows systems with a security id error and not at all/not properly setting required permissions for directories * [#96](https://github.com/Icinga/icinga-powershell-framework/issues/96) Re-Implements caching for Performance Counters and fixes an issue with counters sometimes returning value 0 instead of the correct value -* [#97](https://github.com/Icinga/icinga-powershell-framework/issues/97) Fix value digit count for Performance Counters +* [#97](https://github.com/Icinga/icinga-powershell-framework/issues/97), [#101](https://github.com/Icinga/icinga-powershell-framework/issues/101), [#104](https://github.com/Icinga/icinga-powershell-framework/issues/104) Fix value digit count for Performance Counters ## 1.1.2 (2020-07-01) diff --git a/lib/core/perfcounter/New-IcingaPerformanceCounterObject.psm1 b/lib/core/perfcounter/New-IcingaPerformanceCounterObject.psm1 index 5f355ac..df46e22 100644 --- a/lib/core/perfcounter/New-IcingaPerformanceCounterObject.psm1 +++ b/lib/core/perfcounter/New-IcingaPerformanceCounterObject.psm1 @@ -76,7 +76,7 @@ function New-IcingaPerformanceCounterObject() try { [string]$CounterType = $this.PerfCounter.CounterType; - $CounterData.Add('value', ([math]::Round($this.PerfCounter.NextValue(), 6))); + $CounterData.Add('value', ([math]::Round([decimal]$this.PerfCounter.NextValue(), 6))); $CounterData.Add('sample', $this.PerfCounter.NextSample()); $CounterData.Add('help', $this.PerfCounter.CounterHelp); $CounterData.Add('type', $CounterType); diff --git a/lib/core/tools/Format-IcingaPerfDataValue.psm1 b/lib/core/tools/Format-IcingaPerfDataValue.psm1 index bd8ec41..bfe6de0 100644 --- a/lib/core/tools/Format-IcingaPerfDataValue.psm1 +++ b/lib/core/tools/Format-IcingaPerfDataValue.psm1 @@ -10,5 +10,5 @@ function Format-IcingaPerfDataValue() # Convert our value to a string and replace ',' with a '.' to allow Icinga to parse the output # In addition, round every output to 6 digits - return (([string]([math]::round($PerfValue, 6))).Replace(',', '.')); + return (([string]([math]::round([decimal]$PerfValue, 6))).Replace(',', '.')); }