Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Powershell-framework 1.10 - Register-IcingaServiceCheck results in powershell errors #582

Closed
chr1sos opened this issue Sep 21, 2022 · 9 comments · Fixed by #590
Closed
Assignees
Labels
Bug There is an issue present
Milestone

Comments

@chr1sos
Copy link

chr1sos commented Sep 21, 2022

Expected Behavior

Register Background Daemon and Service Checks to collect metrics over time should work.

Register-IcingaBackgroundDaemon -Command 'Start-IcingaServiceCheckDaemon';

Register-IcingaServiceCheck -CheckCommand 'Invoke-IcingaCheckCPU' -Interval 30 -TimeIndexes 1, 3, 5, 15;

Show-IcingaRegisteredServiceChecks;

Current Behavior

Register-IcingaServiceCheck fails and print several powershell errors:

Add-Member : Cannot bind argument to parameter 'InputObject' because it is null.
At C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-framework\cache\framework_cache.psm1:411 char:21
... figObject | Add-Member -MemberType NoteProperty -Name $ConfigKey -Val ...
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
CategoryInfo : InvalidData: (:) [Add-Member], ParameterBindingValidationException
FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddMemberCommand

Possible Solution

Steps to Reproduce (for bugs)

  1. follow guide to install IcingaForWindows (first installation on a new system)
  2. run Register-IcingaBackgroundDaemon -Command 'Start-IcingaServiceCheckDaemon';
  3. run Register-IcingaServiceCheck -CheckCommand 'Invoke-IcingaCheckCPU' -Interval 30 -TimeIndexes 1, 3, 5, 15;
  4. multiple errors occured

Context

collect metrics over time not usable with framework 1.10

Your Environment

  • PowerShell Version used ($PSVersionTable.PSVersion):
    Major Minor Build Revision
    5_______1_____17763__592
  • Operating System and version (Get-IcingaWindowsInformation Win32_OperatingSystem | Select-Object Version, BuildNumber, Caption):
    Version_____BuildNumber__Caption
    10.0.17763__17763______Microsoft Windows Server 2019 Standard Evaluation
    (fresh installed to exclude possible side effects)
@BTMichel
Copy link

BTMichel commented Sep 21, 2022

I am facing the same issue, background check registration seems to be broken with 1.10.0

Further informations regarding the error
This is a part of the exceptions thrown after executing 'Register-IcingaServiceCheck ...':

Add-Member : Cannot bind argument to parameter 'InputObject' because it is null.
At C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-framework\cache\framework_cache.psm1:411 char:21
+ ... figObject | Add-Member -MemberType NoteProperty -Name $ConfigKey -Val ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Add-Member], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddMemberCo
   mmand

Add-Member : Cannot bind argument to parameter 'InputObject' because it is null.
At C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-framework\cache\framework_cache.psm1:411 char:21
+ ... figObject | Add-Member -MemberType NoteProperty -Name $ConfigKey -Val ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Add-Member], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddMemberCo
   mmand

The property 'CheckCommand' cannot be found on this object. Verify that the property exists and can be set.
At C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-framework\cache\framework_cache.psm1:542 char:13
+             $ConfigObject.$entry = $Value;
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

According to the error messages, it seems like the framework cache is causing the problems.

@BTMichel
Copy link

BTMichel commented Sep 21, 2022

Some more context, because i have been analyzing the problem:
When i add the config for the registeredservice manually in the config.json of the powershell-framework module, the exceptions do not occur.
It seems, that the error is a logic issue, where some check is missing, to see if the config is already present in the config.json or if it has to be written first.

@BTMichel
Copy link

BTMichel commented Sep 22, 2022

One more thing to note:
Even whith the fix applied (adding the config manually to the config.json and then registering the background service), the cpu check seems to not be working correctly.
There is no output specifying, that the value is actually an average, even though the performance data makes it seem that way:

image
=> Here you can see, that just a normal percentage value is displayed. In previous versions of ifw, there was additional information displayed, e.g.: "15m avg." which made it obvious, that is was a interval value.


image
=> In the performance data you can also see, that the thresholds seem to still be applied to the "normal" value, not the interval values.

And yes: The interval value is given to the check call as argument. It is set to "15m".

@BTMichel
Copy link

Update
I could unfortunately still not really solve this issue.
Any help would be appreciated, since this issue is causing our business to miss out on all the new features and bug fixes of the newest version.

@tbauriedel
Copy link
Member

ref/NC/766230

@LordHepipud
Copy link
Collaborator

I did some digging into this issue and I can't seem to be able to reproduce with with v1.10.0.

Please note that there was one change with the command, which now specifies the intervals based on the time unit. If you add a service check with 1,3,5,15 this will result in checks being stored in seconds instead of minutes before. If want the previous minute handling, you will require to do set the values to

Register-IcingaServiceCheck -CheckCommand 'Invoke-IcingaCheckMemory' -Interval 30 -TimeIndexes 1m, 3m, 5m, 15m

I can't however not get the above mentioned error. Once I register the service check, it just works. I will try on a newly installed machine in addition to test further.

For existing config: The migration is done by default to the new minute handling. Therefor you do not need to worry about that.

I just realised this slipped through the upgrading docs statement and will update this including the examples to ensure we are all on track regading this change.

@t3easy
Copy link
Contributor

t3easy commented Oct 18, 2022

I get the same errors:

Register-IcingaServiceCheck -CheckCommand 'Invoke-IcingaCheckCPU' -Interval 30 -TimeIndexes 1m, 5m, 15m
Add-Member : Das Argument kann nicht an den Parameter "InputObject" gebunden werden, da es NULL ist.
In C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-framework\cache\framework_cache.psm1:411 Zeichen:21
+ ... figObject | Add-Member -MemberType NoteProperty -Name $ConfigKey -Val ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Add-Member], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddMemberCommand

Add-Member : Das Argument kann nicht an den Parameter "InputObject" gebunden werden, da es NULL ist.
In C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-framework\cache\framework_cache.psm1:411 Zeichen:21
+ ... figObject | Add-Member -MemberType NoteProperty -Name $ConfigKey -Val ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Add-Member], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddMemberCommand

Die Eigenschaft "CheckCommand" wurde für dieses Objekt nicht gefunden. Vergewissern Sie sich, dass die Eigenschaft vorhanden ist und festgelegt werden kann.
In C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-framework\cache\framework_cache.psm1:542 Zeichen:13
+             $ConfigObject.$entry = $Value;
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

Add-Member : Das Argument kann nicht an den Parameter "InputObject" gebunden werden, da es NULL ist.
In C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-framework\cache\framework_cache.psm1:411 Zeichen:21
+ ... figObject | Add-Member -MemberType NoteProperty -Name $ConfigKey -Val ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Add-Member], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddMemberCommand

Add-Member : Das Argument kann nicht an den Parameter "InputObject" gebunden werden, da es NULL ist.
In C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-framework\cache\framework_cache.psm1:411 Zeichen:21
+ ... figObject | Add-Member -MemberType NoteProperty -Name $ConfigKey -Val ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Add-Member], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddMemberCommand

Die Eigenschaft "Arguments" wurde für dieses Objekt nicht gefunden. Vergewissern Sie sich, dass die Eigenschaft vorhanden ist und festgelegt werden kann.
In C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-framework\cache\framework_cache.psm1:542 Zeichen:13
+             $ConfigObject.$entry = $Value;
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

Add-Member : Das Argument kann nicht an den Parameter "InputObject" gebunden werden, da es NULL ist.
In C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-framework\cache\framework_cache.psm1:411 Zeichen:21
+ ... figObject | Add-Member -MemberType NoteProperty -Name $ConfigKey -Val ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Add-Member], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddMemberCommand

Add-Member : Das Argument kann nicht an den Parameter "InputObject" gebunden werden, da es NULL ist.
In C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-framework\cache\framework_cache.psm1:411 Zeichen:21
+ ... figObject | Add-Member -MemberType NoteProperty -Name $ConfigKey -Val ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Add-Member], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddMemberCommand

Die Eigenschaft "Interval" wurde für dieses Objekt nicht gefunden. Vergewissern Sie sich, dass die Eigenschaft vorhanden ist und festgelegt werden kann.
In C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-framework\cache\framework_cache.psm1:542 Zeichen:13
+             $ConfigObject.$entry = $Value;
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

Add-Member : Das Argument kann nicht an den Parameter "InputObject" gebunden werden, da es NULL ist.
In C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-framework\cache\framework_cache.psm1:411 Zeichen:21
+ ... figObject | Add-Member -MemberType NoteProperty -Name $ConfigKey -Val ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Add-Member], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddMemberCommand

Add-Member : Das Argument kann nicht an den Parameter "InputObject" gebunden werden, da es NULL ist.
In C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-framework\cache\framework_cache.psm1:411 Zeichen:21
+ ... figObject | Add-Member -MemberType NoteProperty -Name $ConfigKey -Val ...
+                 ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidData: (:) [Add-Member], ParameterBindingValidationException
    + FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.AddMemberCommand

Die Eigenschaft "TimeIndexes" wurde für dieses Objekt nicht gefunden. Vergewissern Sie sich, dass die Eigenschaft vorhanden ist und festgelegt werden kann.
In C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-framework\cache\framework_cache.psm1:542 Zeichen:13
+             $ConfigObject.$entry = $Value;
+             ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
    + CategoryInfo          : InvalidOperation: (:) [], RuntimeException
    + FullyQualifiedErrorId : PropertyNotFound

[Notice]: Icinga background service check has been added
Environment configuration:

PowerShell Root                 => C:\Program Files\WindowsPowerShell\Modules\
Icinga for Windows Service Path => C:\Program Files\icinga-framework-service\
Icinga for Windows Service User => .\icinga
Icinga for Windows Service Pid  => 8436
Icinga for Windows JEA Pid      => 1100
Icinga Agent Path               => C:\Program Files\ICINGA2\
Icinga Agent User               => .\icinga
Defined Default User            => SERVER\icinga
Icinga Managed User             => True
PowerShell Version              => 5.1.17763.2931
Operating System                => Microsoft Windows Server 2019 Datacenter
Operating System Version        => 10.0.17763
JEA Context                     => IcingaForWindows
JEA Session File                => C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-framework\RoleCapabilities\IcingaForWindows.psrc
Api Check Forwarder             => True
Debug Mode                      => False

Icinga for Windows Certificate:

Issuer  => CN=Icinga CA
Subject => CN=server.domain.tld

List of configured background daemons on this system:

Start-IcingaServiceCheckDaemon
-----------
No arguments defined

Start-IcingaWindowsRESTApi
-----------
No arguments defined

List of configured background service checks on this system:
=> https://icinga.com/docs/icinga-for-windows/latest/doc/110-Installation/06-Collect-Metrics-over-Time/

No background service checks configured

List of configured repositories on this system. The list order matches the apply order:

Icinga Stable
-----------
CloneSource  =>
Enabled      => True
LocalPath    =>
Order        => 0
RemotePath   => https://packages.icinga.com/IcingaForWindows/stable/ifw.repo.json
UseSCP       => False

Installed components on this system:

Component    Version   Available
---          ---       ---
agent        2.13.5    2.13.5
framework    1.10.0    1.10.0
plugins      1.10.0    1.10.0
service      1.2.0     1.2.0

Available versions flagged with "*" mean that this component is locked to this version

@LordHepipud LordHepipud self-assigned this Oct 18, 2022
@LordHepipud LordHepipud added the Bug There is an issue present label Oct 18, 2022
@LordHepipud LordHepipud added this to the v1.10.1 milestone Oct 18, 2022
@LordHepipud
Copy link
Collaborator

LordHepipud commented Oct 18, 2022

In case you are running into this problem, can you please run this command on PowerShell and try again?

if ($null -eq (Get-IcingaPowerShellConfig -Path 'BackgroundDaemon.RegisteredServices')) {
    Remove-IcingaPowerShellConfig -Path 'BackgroundDaemon.RegisteredServices';
}

This should resolve the issue. I will provide an automated fix for this with v1.10.1, which will run this command during the migration tasks. v1.10.1 will also fix the previous migration task which broke the config for the registration. This error only occured if no service check definitions were defined before.

@t3easy
Copy link
Contributor

t3easy commented Oct 18, 2022

In case you are running into this problem, can you please run this command on PowerShell and try again?

if ($null -eq (Get-IcingaPowerShellConfig -Path 'BackgroundDaemon.RegisteredServices')) {
    Remove-IcingaPowerShellConfig -Path 'BackgroundDaemon.RegisteredServices';
}

This should resolve the issue. I will provide an automated fix for this with v1.10.1, which will run this command during the migration tasks. v1.10.1 will also fix the previous migration task which broke the config for the registration. This error only occured if no service check definitions were defined before.

Thanks @LordHepipud, that worked!

PS C:\> if ($null -eq (Get-IcingaPowerShellConfig -Path 'BackgroundDaemon.RegisteredServices')) {
>>     Remove-IcingaPowerShellConfig -Path 'BackgroundDaemon.RegisteredServices';
>> }
PS C:\> Register-IcingaServiceCheck -CheckCommand 'Invoke-IcingaCheckCPU' -Interval 30 -TimeIndexes 1m, 5m, 15m
[Notice]: Icinga background service check has been added
PS C:\> Show-IcingaRegisteredServiceChecks;
List of configured background service checks on this system:
=> https://icinga.com/docs/icinga-for-windows/latest/doc/110-Installation/06-Collect-Metrics-over-Time/

Invoke-IcingaCheckCPU
-----------
Arguments    =>
CheckCommand => Invoke-IcingaCheckCPU
Id           => 1234
Interval     => 30
TimeIndexes  => 1m, 5m, 15m

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug There is an issue present
Projects
None yet
Development

Successfully merging a pull request may close this issue.

5 participants