mirror of
https://github.com/Icinga/icinga-powershell-framework.git
synced 2026-02-03 04:09:29 -05:00
Fixes performance counter results sometimes reporting null instead of 0
This commit is contained in:
parent
6b459185a7
commit
c70da2a2a8
3 changed files with 12 additions and 4 deletions
|
|
@ -22,6 +22,7 @@ This beta release has reworked the entire handling on how thresholds and the che
|
|||
* [#735](https://github.com/Icinga/icinga-powershell-framework/pull/735) Fixes an issue with filter for EventLog events, which did not properly handle multiple event id includes, causing empty results
|
||||
* [#743](https://github.com/Icinga/icinga-powershell-framework/pull/743) In the REST API response header `Server`, tell the software version, not the machine name (RFC 9110)
|
||||
* [#745](https://github.com/Icinga/icinga-powershell-framework/pull/745) Fixes an issue for service provider with service names not interpreted correctly in case it contains `[]`
|
||||
* [#746](https://github.com/Icinga/icinga-powershell-framework/issues/746) Fixes an issue with performance counters, sometimes reporting empty values instead of at least 0
|
||||
|
||||
### Enhancements
|
||||
|
||||
|
|
|
|||
|
|
@ -82,6 +82,7 @@ function New-IcingaPerformanceCounterObject()
|
|||
# Initialise the counter
|
||||
try {
|
||||
$this.PerfCounter.NextValue() | Out-Null;
|
||||
$this.PerfCounter.NextSample() | Out-Null;
|
||||
} catch {
|
||||
# Nothing to do here, will be handled later
|
||||
}
|
||||
|
|
@ -110,17 +111,23 @@ function New-IcingaPerformanceCounterObject()
|
|||
$pc_instance | Add-Member -MemberType ScriptMethod -Name 'Value' -Value {
|
||||
[hashtable]$CounterData = @{ };
|
||||
|
||||
$CounterValue = $this.PerfCounter.NextValue();
|
||||
|
||||
if ($null -eq $CounterValue) {
|
||||
$CounterValue = 0;
|
||||
}
|
||||
|
||||
try {
|
||||
[string]$CounterType = $this.PerfCounter.CounterType;
|
||||
$CounterData.Add('value', ([math]::Round([decimal]$this.PerfCounter.NextValue(), 6)));
|
||||
$CounterData.Add('value', ([math]::Round([decimal]$CounterValue, 6)));
|
||||
$CounterData.Add('sample', $this.PerfCounter.NextSample());
|
||||
$CounterData.Add('help', $this.PerfCounter.CounterHelp);
|
||||
$CounterData.Add('type', $CounterType);
|
||||
$CounterData.Add('error', $null);
|
||||
} catch {
|
||||
$CounterData = @{ };
|
||||
$CounterData.Add('value', $null);
|
||||
$CounterData.Add('sample', $null);
|
||||
$CounterData.Add('value', 0); # Set the value to 0 in case of an error
|
||||
$CounterData.Add('sample', 0);
|
||||
$CounterData.Add('help', $null);
|
||||
$CounterData.Add('type', $null);
|
||||
$CounterData.Add('error', $_.Exception.Message);
|
||||
|
|
|
|||
|
|
@ -198,7 +198,7 @@ function New-IcingaCheck()
|
|||
|
||||
[string]$LabelName = (Format-IcingaPerfDataLabel -PerfData $this.Name);
|
||||
[string]$MultiLabelName = (Format-IcingaPerfDataLabel -PerfData $this.Name -MultiOutput);
|
||||
$value = ConvertTo-Integer -Value $this.__ThresholdObject.Value -NullAsEmpty;
|
||||
$value = ConvertTo-Integer -Value $this.__ThresholdObject.Value;
|
||||
$warning = '';
|
||||
$critical = '';
|
||||
|
||||
|
|
|
|||
Loading…
Reference in a new issue