Skip to content

Commit e7dc4fe

Browse files
authored
Merge pull request #655 from Icinga:feature/ikwb_and_test_for_intercept_counter
Feature: Adds IWKB and test/manage Cmdlets for SCOM intercept counters Adds IWKB and test/manage Cmdlets for SCOM intercept counters * Test-IcingaInterceptCounter * Disable-IcingaInterceptCounter * Enable-IcingaInterceptCounter
2 parents 5898ee9 + c77349a commit e7dc4fe

File tree

6 files changed

+181
-1
lines changed

6 files changed

+181
-1
lines changed

doc/100-General/10-Changelog.md

+1
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,7 @@ Released closed milestones can be found on [GitHub](https://github.com/Icinga/ic
3838
* [#640](https://github.com/Icinga/icinga-powershell-framework/issues/640) Adds support to set the flag `-NoSSLValidation` for Cmdlets `icinga` and `Install-Icinga`, to ignore errors on self-signed certificates within the environment
3939
* [#643](https://github.com/Icinga/icinga-powershell-framework/pull/643) Adds support for `-RebuildCache` flag on `icinga` cmd to rebuild component cache as well
4040
* [#644](https://github.com/Icinga/icinga-powershell-framework/pull/644) Adds progress bar output to repository interaction (sync, update, new) instead of plain text output
41+
* [#655](https://github.com/Icinga/icinga-powershell-framework/pull/655) Adds [IWKB](https://icinga.com/docs/icinga-for-windows/latest/doc/knowledgebase/IWKB000016/) and test/manage Cmdlets for SCOM intercept counters
4142

4243
### Enhancements
4344

doc/300-Knowledge-Base.md

+2-1
Original file line numberDiff line numberDiff line change
@@ -22,4 +22,5 @@ For this reason you will find a list of Icinga knowledge base entries below. Ent
2222
| [IWKB000012](knowledgebase/IWKB000012.md) | Icinga for Windows cannot be used with Microsoft Defender: `Windows Defender Antivirus has detected malware or other potentially unwanted software` |
2323
| [IWKB000013](knowledgebase/IWKB000013.md) | The local Icinga Agent certificate seems not to be signed by our Icinga CA yet. Using this certificate for the REST-Api as example might not work yet. Please check the state of the certificate and complete the signing process if required |
2424
| [IWKB000014](knowledgebase/IWKB000014.md) | Installing or Updating Icinga for Windows causes error messages regarding `framework_cache.psm1` errors |
25-
| [IWKB000015](knowledgebase/IWKB000015.md) | Got JSON, but not an object, from IfW API on host 'localhost' port '5668': "Exception while calling \\"Fill\\" with 1 arguments: \\"Invalid syntax near \\"`<Argument>:`\\".\\"" |
25+
| [IWKB000015](knowledgebase/IWKB000015.md) | Got JSON, but not an object, from IfW API on host 'localhost' port '5668': "Exception while calling \\"Fill\\" with 1 arguments: \\"Invalid syntax near \\"`<Argument>:`\\".\\"" |
26+
| [IWKB000016](knowledgebase/IWKB000016.md) | Checks using Performance Counter fail with various messages like `Exception of type 'System.OutOfMemoryException' was thrown` or `Icinga Invalid Configuration Error was thrown: PerfCounterCategoryMissing: Category "Memory" not found` |

doc/knowledgebase/IWKB000016.md

+87
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,87 @@
1+
# Icinga Knowledge Base - IWKB000016
2+
3+
## Short Message
4+
5+
Checks using Performance Counter fail with various messages like `Exception of type 'System.OutOfMemoryException' was thrown` or `Icinga Invalid Configuration Error was thrown: PerfCounterCategoryMissing: Category "Memory" not found`
6+
7+
## Example Exception
8+
9+
### Out-Of-Memory Exception
10+
11+
```powershell
12+
[UNKNOWN]: Icinga Unhandled Error was thrown: Unhandled Exception
13+
14+
Unhandled exception occurred: System.Management.Automation.MethodInvocationException: Exception calling "GetInstanceNames" with "0" argument(s): "Exception of type 'System.OutOfMemoryException' was thrown." ---> System.OutOfMemoryException: Exception of type 'System.OutOfMemoryException' was thrown. at Microsoft.Win32.RegistryKey.InternalGetValue(String name, Object defaultValue, Boolean doNotExpand, Boolean checkSecurity) at Microsoft.Win32.RegistryKey.GetValue(String name) at System.Diagnostics.PerformanceMonitor.GetData(String item) at System.Diagnostics.PerformanceCounterLib.GetPerformanceData(String item) at System.Diagnostics.PerformanceCounterLib.get_CategoryTable() at System.Diagnostics.PerformanceCounterLib.GetCategorySample(String category) at System.Diagnostics.PerformanceCounterLib.GetCategorySample(String machine, String category) at System.Diagnostics.PerformanceCounterCategory.GetCounterInstances(String categoryName, String machineName) at CallSite.Target(Closure , CallSite , Object ) --- End of inner exception stack trace --- at System.Management.Automation.ExceptionHandlingOps.CheckActionPreference(FunctionContext funcContext, Exception exception) at System.Management.Automation.Interpreter.ActionCallInstruction`2.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame) at System.Management.Automation.Interpreter.EnterTryCatchFinallyInstruction.Run(InterpretedFrame frame)
15+
```
16+
17+
### Category "..." not found
18+
19+
```powershell
20+
[UNKNOWN]: Icinga Invalid Configuration Error was thrown: PerfCounterCategoryMissing: Category "Memory" not found
21+
22+
The specified Performance Counter category was not found on this system. This could either be a configuration error on your local Windows machine or a wrong usage of the plugin. Please check on different Windows machines if this issue persis. In case it only occurs on certain machines it is likely that the counter is simply not present and the plugin can not be processed.
23+
```
24+
25+
## Reason
26+
27+
This issue seem only to appear while running Icinga for Windows **without** [JEA-Profile](../130-JEA/01-JEA-Profiles.md) and installed SCOM-Agent from Microsoft including the `APM` feature on the same machine.
28+
29+
The reason can be tracked back to the `Intercept Counters` which are installed together with SCOM and `APM` feature.
30+
31+
To check if you are affected by these counters, you can run the command `Test-IcingaInterceptCounter` starting with Icinga for Windows v1.11.0:
32+
33+
```powershell
34+
PS> Test-IcingaInterceptCounter;
35+
36+
[Notice]: Testing for Microsoft SCOM Intercept Counters
37+
[Failed]: Entry "HKLM:\SYSTEM\CurrentControlSet\Services\Intercept CSM Filters\Performance" is present on the system and the intercept counter is NOT disabled
38+
[Passed]: Entry "HKLM:\SYSTEM\CurrentControlSet\Services\Intercept Injector\Performance" is not present on the system
39+
[Passed]: Entry "HKLM:\SYSTEM\CurrentControlSet\Services\Intercept SyncAction Processing\Performance" is not present on the system
40+
[Passed]: Entry "HKLM:\SYSTEM\CurrentControlSet\Services\InterceptCountersManager\Performance" is not present on the system
41+
[Passed]: Entry "HKLM:\SYSTEM\CurrentControlSet\Services\Backup Exec\Performance" is not present on the system
42+
[Failed]: One or more intercept counters exist on this system which are not disabled. Please take a look at https://icinga.com/docs/icinga-for-windows/latest/doc/knowledgebase/IWKB000016/ for further details
43+
```
44+
45+
## Solution
46+
47+
If the command `Test-IcingaInterceptCounter` is reporting a `Failed` state on any of the tests, they are most likely the cause for issues regarding Performance Counter monitoring.
48+
49+
### Requiring APM Feature
50+
51+
Please check beforehand, if you are making use of any of the `Intercept Counters` installed with the SCOM-Agent in your environment. If you are using and requiring the `APM` feature provided by SCOM, the solution would be to reinstall the SCOM-Agent together with the `APM` feature, which should resolve the issue.
52+
53+
If the error persists after the reinstallation, please open a support case for SCOM with Microsoft.
54+
55+
### APM is not required
56+
57+
In case you are not using any of the `APM` features provided the SCOM-Agent, you are save to disable to `Intercept Counters`.
58+
59+
To disable these counters, you can run the command `Disable-IcingaInterceptCounter`:
60+
61+
```powershell
62+
PS> Disable-IcingaInterceptCounter;
63+
64+
[Notice]: Disabling SCOM intercept counter "HKLM:\SYSTEM\CurrentControlSet\Services\Intercept CSM Filters\Performance"
65+
[Notice]: SCOM intercept counter "HKLM:\SYSTEM\CurrentControlSet\Services\Intercept Injector\Performance" not installed on the system
66+
[Notice]: SCOM intercept counter "HKLM:\SYSTEM\CurrentControlSet\Services\Intercept SyncAction Processing\Performance" not installed on the system
67+
[Notice]: SCOM intercept counter "HKLM:\SYSTEM\CurrentControlSet\Services\InterceptCountersManager\Performance" not installed on the system
68+
[Notice]: SCOM intercept counter "HKLM:\SYSTEM\CurrentControlSet\Services\InterceptCountersManager\Performance" not installed on the system
69+
[Notice]: SCOM intercept counter "HKLM:\SYSTEM\CurrentControlSet\Services\Backup Exec\Performance" not installed on the system
70+
```
71+
72+
Afterwards reboot your server and the monitoring with plugins using Performance Counter should be fine.
73+
74+
To enable the `Intercept Counters` again, you can run `Enable-IcingaInterceptCounter`:
75+
76+
```powershell
77+
PS> Enable-IcingaInterceptCounter;
78+
79+
[Notice]: Enabling SCOM intercept counter "HKLM:\SYSTEM\CurrentControlSet\Services\Intercept CSM Filters\Performance"
80+
[Notice]: SCOM intercept counter "HKLM:\SYSTEM\CurrentControlSet\Services\Intercept Injector\Performance" not installed on the system
81+
[Notice]: SCOM intercept counter "HKLM:\SYSTEM\CurrentControlSet\Services\Intercept SyncAction Processing\Performance" not installed on the system
82+
[Notice]: SCOM intercept counter "HKLM:\SYSTEM\CurrentControlSet\Services\InterceptCountersManager\Performance" not installed on the system
83+
[Notice]: SCOM intercept counter "HKLM:\SYSTEM\CurrentControlSet\Services\InterceptCountersManager\Performance" not installed on the system
84+
[Notice]: SCOM intercept counter "HKLM:\SYSTEM\CurrentControlSet\Services\Backup Exec\Performance" not installed on the system
85+
```
86+
87+
Again, reboot your server afterwards to complete the changes.
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
function Disable-IcingaInterceptCounter()
2+
{
3+
[array]$InterceptCounterList = @(
4+
'HKLM:\SYSTEM\CurrentControlSet\Services\Intercept CSM Filters\Performance',
5+
'HKLM:\SYSTEM\CurrentControlSet\Services\Intercept Injector\Performance',
6+
'HKLM:\SYSTEM\CurrentControlSet\Services\Intercept SyncAction Processing\Performance',
7+
'HKLM:\SYSTEM\CurrentControlSet\Services\InterceptCountersManager\Performance',
8+
'HKLM:\SYSTEM\CurrentControlSet\Services\InterceptCountersManager\Performance',
9+
'HKLM:\SYSTEM\CurrentControlSet\Services\Backup Exec\Performance'
10+
);
11+
12+
foreach ($counter in $InterceptCounterList) {
13+
if (Test-Path $counter) {
14+
Write-IcingaConsoleNotice 'Disabling SCOM intercept counter "{0}"' -Objects $counter
15+
16+
$CounterState = Get-ItemProperty -Path $counter -Name 'Disable Performance Counters' -ErrorAction SilentlyContinue;
17+
18+
if ($null -eq $CounterState) {
19+
New-ItemProperty -Path $counter -Name 'Disable Performance Counters' -Value 1;
20+
continue;
21+
}
22+
23+
Set-ItemProperty -Path $counter -Name 'Disable Performance Counters' -Value 1;
24+
} else {
25+
Write-IcingaConsoleNotice 'SCOM intercept counter "{0}" not installed on the system' -Objects $counter
26+
}
27+
}
28+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
function Enable-IcingaInterceptCounter()
2+
{
3+
[array]$InterceptCounterList = @(
4+
'HKLM:\SYSTEM\CurrentControlSet\Services\Intercept CSM Filters\Performance',
5+
'HKLM:\SYSTEM\CurrentControlSet\Services\Intercept Injector\Performance',
6+
'HKLM:\SYSTEM\CurrentControlSet\Services\Intercept SyncAction Processing\Performance',
7+
'HKLM:\SYSTEM\CurrentControlSet\Services\InterceptCountersManager\Performance',
8+
'HKLM:\SYSTEM\CurrentControlSet\Services\InterceptCountersManager\Performance',
9+
'HKLM:\SYSTEM\CurrentControlSet\Services\Backup Exec\Performance'
10+
);
11+
12+
foreach ($counter in $InterceptCounterList) {
13+
if (Test-Path $counter) {
14+
Write-IcingaConsoleNotice 'Enabling SCOM intercept counter "{0}"' -Objects $counter
15+
16+
$CounterState = Get-ItemProperty -Path $counter -Name 'Disable Performance Counters' -ErrorAction SilentlyContinue;
17+
18+
if ($null -eq $CounterState) {
19+
continue;
20+
}
21+
22+
Set-ItemProperty -Path $counter -Name 'Disable Performance Counters' -Value 0;
23+
} else {
24+
Write-IcingaConsoleNotice 'SCOM intercept counter "{0}" not installed on the system' -Objects $counter
25+
}
26+
}
27+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,36 @@
1+
function Test-IcingaInterceptCounter()
2+
{
3+
Write-IcingaConsoleNotice 'Testing for Microsoft SCOM Intercept Counters';
4+
5+
[bool]$TestResult = $TRUE;
6+
[array]$InterceptCounterList = @(
7+
'HKLM:\SYSTEM\CurrentControlSet\Services\Intercept CSM Filters\Performance',
8+
'HKLM:\SYSTEM\CurrentControlSet\Services\Intercept Injector\Performance',
9+
'HKLM:\SYSTEM\CurrentControlSet\Services\Intercept SyncAction Processing\Performance',
10+
'HKLM:\SYSTEM\CurrentControlSet\Services\InterceptCountersManager\Performance',
11+
'HKLM:\SYSTEM\CurrentControlSet\Services\InterceptCountersManager\Performance',
12+
'HKLM:\SYSTEM\CurrentControlSet\Services\Backup Exec\Performance'
13+
);
14+
15+
foreach ($counter in $InterceptCounterList) {
16+
if (Test-Path -Path $counter) {
17+
$CounterState = Get-ItemProperty -Path $counter -Name 'Disable Performance Counters' -ErrorAction SilentlyContinue;
18+
19+
if ($null -eq $CounterState -Or $CounterState.'Disable Performance Counters' -eq 0) {
20+
Write-IcingaTestOutput -Severity 'Failed' -Message ([string]::Format('Entry "{0}" is present on the system and the intercept counter is NOT disabled', $counter));
21+
$TestResult = $FALSE;
22+
continue;
23+
}
24+
25+
Write-IcingaTestOutput -Severity 'Passed' -Message ([string]::Format('Entry "{0}" is present on the system and the intercept counter is disabled', $counter));
26+
} else {
27+
Write-IcingaTestOutput -Severity 'Passed' -Message ([string]::Format('Entry "{0}" is not present on the system', $counter));
28+
}
29+
}
30+
31+
if ($TestResult -eq $FALSE) {
32+
Write-IcingaTestOutput -Severity 'Failed' -Message 'One or more intercept counters exist on this system which are not disabled. Please take a look at https://icinga.com/docs/icinga-for-windows/latest/doc/knowledgebase/IWKB000016/ for further details';
33+
} else {
34+
Write-IcingaTestOutput -Severity 'Passed' -Message 'There are either no intercept counters installed on your system or they are disabled. Monitoring of Performance Counters should work fine';
35+
}
36+
}

0 commit comments

Comments
 (0)