I have installed that versions:
Icinga2-v2.12.4-x86_64.msi
icinga-powershell-framework-1.5.2.zip
icinga-powershell-plugins-1.5.1.zip
icinga-service-v1.1.0.zip
After I have updated framework, agent and plugins I have a problem in all my checks with that command:
return New-IcingaCheckresult -Check $Check -noPerfdata $True -Compile
This is the error:
Exception calling "Compile" with "0" argument(s): "Cannot index into a null array."
At C:\Program
Files\WindowsPowerShell\Modules\icinga-powershell-framework\lib\icinga\plugin\New-IcingaCheckResult.psm1:34 char:16
+ return $IcingaCheckResult.Compile();
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ScriptMethodRuntimeException
this issue is interesting and shouldnât happen. There were only bugfixes with 1.5.1 and 1.5.2 which shouldnât cause problems in addition, but resolve them.
The issue is resolved once you replace New-IcingaCheckBaseObject from 1.5.2 with 1.5.0?
Could you please try to test your plugin with the Master of 1.6.0?
Wohld it be possible to Share your code snippet for the Check causing the Error, allowing us to reproduce the issue?
I have installed that versions:
Icinga2-v2.13.0-x86_64.msi
icinga-powershell-framework-1.5.2.zip
icinga-powershell-plugins-1.5.1.zip
icinga-service-v1.1.0.zip
There is something.
if the Check is not named Invoke-Icinga* for example Invoke-MyIcingaCheckAppPool the check fails, after running a check with the name Invoke-Icinga* and the same check again the error is gone
PS C:\Users\Nicolas> Use-Icinga
PS C:\Users\Nicolas> Invoke-MyIcingaCheckAppPool
\APP_POOL_WAS(_Total)\Current Application Pool State
\APP_POOL_WAS(DefaultAppPool)\Current Application Pool State
[OK] Performance Counter
Ausnahme beim Aufrufen von "Compile" mit 0 Argument(en): "Es ist nicht möglich, einen Index auf ein NULL-Array
anzuwenden."
In C:\Program Files\WindowsPowerShell\Modules\icinga-powershell-framework\cache\framework_cache.psm1:20871 Zeichen:16
+ return $IcingaCheckResult.Compile();
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [], MethodInvocationException
+ FullyQualifiedErrorId : ScriptMethodRuntimeException
Check
-----
@{Name=Performance Counter; Verbose=0; __CheckPerfData=System.Collections.Hashtable; __Hidden=False; __Parent=; __In...
PS C:\Users\Nicolas> Invoke-MyIcingaCheckAppPool
\APP_POOL_WAS(_Total)\Current Application Pool State
\APP_POOL_WAS(DefaultAppPool)\Current Application Pool State
[OK] Performance Counter
| 'app_pool_wasdefaultapppoolcurrent_application_pool_state'=3;;3
0
This allows us to ensure we are inside a plugin context and can automate certain tasks behind, without the developer to worry about.
If we remove this ârestrictionâ, writing custom plugins will require much more effort in the future. For that reason I would love to stick to that rule.