From c2ad2b65648fff03dff6112270575b7fb579814d Mon Sep 17 00:00:00 2001 From: Lord Hepipud Date: Sat, 8 Aug 2020 14:43:49 +0200 Subject: [PATCH] Fix value digit count for Performance Counters Fixes #97 --- lib/core/perfcounter/New-IcingaPerformanceCounterObject.psm1 | 2 +- lib/core/tools/Format-IcingaPerfDataValue.psm1 | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/lib/core/perfcounter/New-IcingaPerformanceCounterObject.psm1 b/lib/core/perfcounter/New-IcingaPerformanceCounterObject.psm1 index 135ee9e..5f355ac 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', $this.PerfCounter.NextValue()); + $CounterData.Add('value', ([math]::Round($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 b91966a..bd8ec41 100644 --- a/lib/core/tools/Format-IcingaPerfDataValue.psm1 +++ b/lib/core/tools/Format-IcingaPerfDataValue.psm1 @@ -9,6 +9,6 @@ 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 2 digits - return (([string]([math]::round($PerfValue, 2))).Replace(',', '.')); + # In addition, round every output to 6 digits + return (([string]([math]::round($PerfValue, 6))).Replace(',', '.')); }