NCPA Plugin Error Received

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
FrontlineIT
Posts: 94
Joined: Tue Jul 26, 2016 8:46 am

NCPA Plugin Error Received

Post by FrontlineIT »

Hello,

I'm getting an error message in Nagios XI when executing a custom plugin I wrote within NCPA. The plugin/powershell script works fine when run locally on the server. The intent of the script is to scan for any IIS App Pools that are in a stopped state. Any assistance would be greatly appreciated. Below is the script/plugin:

Import-Module WebAdministration

$ok = 0
$warning = 1
$critical = 2

$ErrorThreshold = 1
$AppPoolStatus = Get-ChildItem IIS:\AppPools | where {$_.state -eq "Stopped"}
$StoppedAppPools = $AppPoolStatus.count

if ($StoppedAppPools -ge $ErrorThreshold){
Write-Host Critical: $StoppedAppPools Application Pools in a stopped state
exit $critical
}
Else {
Write-Host OK: All Application Pools are running
exit $ok
}


Below is the error message:

Get-ChildItem : Cannot retrieve the dynamic parameters for the cmdlet.
Retrieving the COM class factory for component with CLSID
{688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error:
80040154 Class not registered (Exception from HRESULT: 0x80040154
(REGDB_E_CLASSNOTREG)).
At C:\\Program Files (x86)\\Nagios\\NCPA\\plugins\\check_iis_app_pools.ps1:8 char:18
+ $AppPoolStatus = Get-ChildItem IIS:\\AppPools
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: NCPA Plugin Error Received

Post by lmiltchev »

We may need to try to lab this in-house, and try recreating the issue. It is possible that your script runs fine only in 64-bit powershell. If this is the case, you can try modifying the ncpa.cfg file.

See instructions in the file:
# Since windows NCPA is 32-bit, if you need to use 64-bit powershell, try the following for
# the powershell plugin definition:
# .ps1 = c:\windows\sysnative\windowspowershell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -File $plugin_name $plugin_args
#
P.S.
Don't forget to restart the NCPA services after saving the file, so that changes can take effect.
Be sure to check out our Knowledgebase for helpful articles and solutions!
FrontlineIT
Posts: 94
Joined: Tue Jul 26, 2016 8:46 am

Re: NCPA Plugin Error Received

Post by FrontlineIT »

Excuse my ignorance as I'm still getting accustomed to the ncpa.cfg. What changes would I be making within the config? Is this implying that I uncomment the line? Any examples?
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: NCPA Plugin Error Received

Post by lmiltchev »

You need to comment out this line:

Code: Select all

.ps1 = powershell -ExecutionPolicy Bypass -File $plugin_name $plugin_args
so it looks like this:

Code: Select all

# .ps1 = powershell -ExecutionPolicy Bypass -File $plugin_name $plugin_args
Also, you need to uncomment this line:

Code: Select all

# .ps1 = c:\windows\sysnative\windowspowershell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -File $plugin_name $plugin_args
so, it looks like this:

Code: Select all

.ps1 = c:\windows\sysnative\windowspowershell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -File $plugin_name $plugin_args
Save, and exit ncpa.cfg file. Restart NCPA Listener, and NCPA Passive services.
Be sure to check out our Knowledgebase for helpful articles and solutions!
FrontlineIT
Posts: 94
Joined: Tue Jul 26, 2016 8:46 am

Re: NCPA Plugin Error Received

Post by FrontlineIT »

Gotcha. I made the changes within the ncpa.cfg and restarted the NCPA services but am now getting this:

/usr/local/nagios/libexec/check_ncpa.py -H ********* -t '**********' -P 5693 -M 'plugins/check_iis_app_pools.ps1'
The plugin (check_iis_app_pools.ps1) requested does not exist.
FrontlineIT
Posts: 94
Joined: Tue Jul 26, 2016 8:46 am

Re: NCPA Plugin Error Received

Post by FrontlineIT »

Please disregard. Missed a change within the nagios.cfg and all is well now!!! Thank you so much for helping. This post can be marked as resolved.
User avatar
lmiltchev
Bugs find me
Posts: 13589
Joined: Mon May 23, 2011 12:15 pm

Re: NCPA Plugin Error Received

Post by lmiltchev »

I am glad I could help! :)
Be sure to check out our Knowledgebase for helpful articles and solutions!
Locked