Moves PerformanceCounter to private space

This commit is contained in:
Lord Hepipud 2022-01-25 11:25:01 +01:00
parent c600a0fc68
commit f6cf9492e5
6 changed files with 29 additions and 23 deletions

View file

@ -27,6 +27,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
* [#418](https://github.com/Icinga/icinga-powershell-framework/pull/418) Fixes crash on wrong variable usage introduced by [#411](https://github.com/Icinga/icinga-powershell-framework/pull/411) * [#418](https://github.com/Icinga/icinga-powershell-framework/pull/418) Fixes crash on wrong variable usage introduced by [#411](https://github.com/Icinga/icinga-powershell-framework/pull/411)
* [#421](https://github.com/Icinga/icinga-powershell-framework/issues/421) Fixes experimental state of `API Check` feature by removing that term and removing the requirement to install `icinga-powershell-restapi` and `icinga-powershell-apichecks` * [#421](https://github.com/Icinga/icinga-powershell-framework/issues/421) Fixes experimental state of `API Check` feature by removing that term and removing the requirement to install `icinga-powershell-restapi` and `icinga-powershell-apichecks`
* [#436](https://github.com/Icinga/icinga-powershell-framework/pull/436) Fixes a lookup error for existing plugin documentation files, which caused files not being generated properly in case a similar name was already present on the system * [#436](https://github.com/Icinga/icinga-powershell-framework/pull/436) Fixes a lookup error for existing plugin documentation files, which caused files not being generated properly in case a similar name was already present on the system
* [#439](https://github.com/Icinga/icinga-powershell-framework/pull/439) Moves PerformanceCounter to private space from previous public, which caused some problems
### Enhancements ### Enhancements

View file

@ -61,6 +61,7 @@ The following entries are set by default within the `Private` space:
| Timers | All created timers by using `Start-IcingaTimer` are stored under this environment variable | | Timers | All created timers by using `Start-IcingaTimer` are stored under this environment variable |
| Scheduler | Once plugins are executed, performance data, check results and exit codes are stored in this section, in case the PowerShell instance is set to run as daemon | | Scheduler | Once plugins are executed, performance data, check results and exit codes are stored in this section, in case the PowerShell instance is set to run as daemon |
| Daemons | This is a place where all daemon data should be added and stored, separated by a namespace for each module as entry. This data is **not** shared between other daemons | | Daemons | This is a place where all daemon data should be added and stored, separated by a namespace for each module as entry. This data is **not** shared between other daemons |
| PerformanceCounter | A space to share all PerformanceCounter information between threads, which counters are already created for internal usage |
#### Example Data #### Example Data
@ -89,7 +90,6 @@ The following entries are set by default within the `Public` space:
| ThreadPools | A list of all thread pools available to create new thread limits for certain background daemons | | ThreadPools | A list of all thread pools available to create new thread limits for certain background daemons |
| Daemons | A place to store shared information for each single daemon within a namespace, making data accessible to other threads | | Daemons | A place to store shared information for each single daemon within a namespace, making data accessible to other threads |
| Threads | A list of all started and available threads running by Icinga for Windows | | Threads | A list of all started and available threads running by Icinga for Windows |
| PerformanceCounter | A space to share all PerformanceCounter information between threads, which counters are already created for internal usage |
##### Example Data ##### Example Data

View file

@ -33,6 +33,13 @@ function New-IcingaEnvironmentVariable()
'ExitCode' = $null; 'ExitCode' = $null;
} }
); );
$Global:Icinga.Private.Add(
'PerformanceCounter',
@{
'Cache' = @{ };
}
);
} }
# Shared configuration for all threads # Shared configuration for all threads
@ -42,12 +49,6 @@ function New-IcingaEnvironmentVariable()
$Global:Icinga.Public.Add('Daemons', @{ }); $Global:Icinga.Public.Add('Daemons', @{ });
$Global:Icinga.Public.Add('Threads', @{ }); $Global:Icinga.Public.Add('Threads', @{ });
$Global:Icinga.Public.Add('ThreadPools', @{ }); $Global:Icinga.Public.Add('ThreadPools', @{ });
$Global:Icinga.Public.Add(
'PerformanceCounter',
@{
'Cache' = @{ };
}
);
} }
# Session specific configuration which should never be modified by users! # Session specific configuration which should never be modified by users!

View file

@ -27,10 +27,10 @@ function Add-IcingaPerformanceCounterCache()
$Instances $Instances
); );
if ($Global:Icinga.Public.PerformanceCounter.Cache.ContainsKey($Counter)) { if ($Global:Icinga.Private.PerformanceCounter.Cache.ContainsKey($Counter)) {
$Global:Icinga.Public.PerformanceCounter.Cache[$Counter] = $Instances; $Global:Icinga.Private.PerformanceCounter.Cache[$Counter] = $Instances;
} else { } else {
$Global:Icinga.Public.PerformanceCounter.Cache.Add( $Global:Icinga.Private.PerformanceCounter.Cache.Add(
$Counter, $Instances $Counter, $Instances
); );
} }

View file

@ -24,8 +24,12 @@ function Get-IcingaPerformanceCounterCacheItem()
$Counter $Counter
); );
if ($Global:Icinga.Public.PerformanceCounter.Cache.ContainsKey($Counter)) { if ([string]::IsNullOrEmpty($Counter)) {
return $Global:Icinga.Public.PerformanceCounter.Cache[$Counter]; return $null;
}
if ($Global:Icinga.Private.PerformanceCounter.Cache.ContainsKey($Counter)) {
return $Global:Icinga.Private.PerformanceCounter.Cache[$Counter];
} }
return $null; return $null;

View file

@ -56,7 +56,7 @@ function New-IcingaPerformanceCounterArray()
# for each session to speed up the loading. This cold be something like # for each session to speed up the loading. This cold be something like
# this: # this:
# #
# $Global:Icinga.Public.PerformanceCounter.Cache += $CounterResult; # $Global:Icinga.Private.PerformanceCounter.Cache += $CounterResult;
# Above we initialise ever single counter and we only require a sleep once # Above we initialise ever single counter and we only require a sleep once
# in case a new, yet unknown counter was added # in case a new, yet unknown counter was added