Page 1 of 2
Monitor IIS AppPool Using NagiosXI and NCPA Agent
Posted: Thu Apr 19, 2018 2:36 pm
by imadc
Hello Support
On our Systems we have NCPA Agent Version 2.0.4 Running on Web Servers with IIS version 8.5
How can we monitor State/Memory/CPU usage of each IIS AppPool listed on those web servers from NagiosXI version 5.4.13 ?
On this site I have seen examples for NRPE/NSClient++ Agent on
https://outsideit.net/monitoring-iis-application-pools/
Can you recommend how we can do it with NCPA please?
Thanks
Re: Monitor IIS AppPool Using NagiosXI and NCPA Agent
Posted: Thu Apr 19, 2018 4:01 pm
by lmiltchev
I haven't really tested this, but I don't see why not call the "check_ms_iis_application_pool.ps1" script via check_ncpa.py. You could define a similar command (as the one in the NSClient++ example) in the ncpa.cfg, place your PS script in the NCPA plugins directory, and restart the NCPA_Listener. Test your check from command line on the Nagios XI server (or from the GUI -
https://x.x.x.x:5693/gui/api/plugins/ch ... n_pool.ps1).
If it works fine, add a new service to your host.
Hope this helps.
Re: Monitor IIS AppPool Using NagiosXI and NCPA Agent
Posted: Tue Apr 24, 2018 3:31 pm
by imadc
Hello lmiltchev
I tried what you mentioned after placing the script under C:\Program Files (x86)\Nagios\NCPA\plugins then restarted services
When I try to hit the command through the NagiosXI box - I am getting the following
[root@rdnagios libexec]# sudo /usr/local/nagios/libexec/check_ncpa.py -H X.X.X.X -t xXX58UPa -M "agent/plugin/check_ms_iis_application_pool.ps1" -a "-A AppName"
CRITICAL: 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)).
When I try from within the web server - I am getting the following
https://X.X.X.X:5693/gui/api/plugins/ch ... n_pool.ps1
I am getting 404 The page you are looking for was not found.
Even though through powershell I tested the powershell script and it working fine
PS C:\Program Files (x86)\Nagios\NCPA\plugins> .\check_ms_iis_application_pool.ps1 -A AppPool
CRITICAL: Application Pool "AppPool" is Stopped.
Anything else that I need to change to make it work from NagiosXI server?
Thansk
Imad
Re: Monitor IIS AppPool Using NagiosXI and NCPA Agent
Posted: Tue Apr 24, 2018 4:38 pm
by npolovenko
@imadc, In the web browser please type:
*Replace my IP address with yours.
Next, go to the API tab in the top level menu. Under API Endpoint dropdown choose
plugins, and on the next line choose
check_ms_iis_application_pool.ps1.
Next, click on the "View in Alternative Format" button in the buttom left corner of the screen -> As active check using NCPA.py.
Let us know what output you get.
Re: Monitor IIS AppPool Using NagiosXI and NCPA Agent
Posted: Tue Apr 24, 2018 9:21 pm
by imadc
When I try to reload the plugins under API
Nothing will be changed on the screen
Re: Monitor IIS AppPool Using NagiosXI and NCPA Agent
Posted: Tue Apr 24, 2018 9:22 pm
by imadc
Do I have to to change anything in NCPA configuration files after I place the powershell script under plugins folder?
Re: Monitor IIS AppPool Using NagiosXI and NCPA Agent
Posted: Wed Apr 25, 2018 10:15 am
by lmiltchev
Yyou placed your plugin into the "
C:\Program Files (x86)\Nagios\NCPA\plugins\" directory, correct? Can you confirm?
The plugin's path is specified in the ncpa.cfg file.
Example:
Code: Select all
[plugin directives]
#
# Plugin path where all plugins will be ran from.
#
plugin_path = plugins/
Does yours look the same?
I am not able to recreate the issue that you are having. As you can see below, all of the plugins in the "C:\Program Files (x86)\Nagios\NCPA\plugins\" directory are listed under the API:
example01.PNG
Note: I am running NCPA ver. 2.1.3. The version, that you are running (2.0.4) is somewhat old. I am not sure if this is what is causing the issue, however I would recommend that you upgrade to the latest version of NCPA agent, which is 2.1.4 at the moment.
Re: Monitor IIS AppPool Using NagiosXI and NCPA Agent
Posted: Wed Apr 25, 2018 11:28 am
by imadc
Thanks @lmiltchev
As recommended I upgraded the NCPA version 2.1.4
Now I am able to see the plugins loaded with the scripts, now I can test it out form the GUI and from NagiosXI
Re: Monitor IIS AppPool Using NagiosXI and NCPA Agent
Posted: Wed Apr 25, 2018 11:35 am
by lmiltchev
Great! I am glad to hear that!
Do you have any more questions or it is OK to close this topic?
Re: Monitor IIS AppPool Using NagiosXI and NCPA Agent
Posted: Wed Apr 25, 2018 12:32 pm
by imadc
We are almost there
The IIS powershell script need to run under x64 since the commands like Get-WebAppPoolState will fail for example with the following error
{
"returncode": 3,
"stdout": "get-webitemstate : Retrieving the COM class factory for component with CLSID \n{688EEEE5-6A7E-422F-B2E1-6AF00DC944A6} failed due to the following error: \n80040154 Class not registered (Exception from HRESULT: 0x80040154 \n(REGDB_E_CLASSNOTREG)).\nAt C:\\Program Files (x86)\\Nagios\\NCPA\\plugins\\test2.ps1:3 char:1\n+ $AppPool_Status = (Get-WebAppPoolState $args[0]).Value\n+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~\n + CategoryInfo : NotSpecified: (:) [Get-WebItemState], COMExcepti \n on\n + FullyQualifiedErrorId : System.Runtime.InteropServices.COMException,Micr \n osoft.IIs.PowerShell.Provider.GetItemStateCommand\n \nDefaultAppPool Current Status is"
}
------------------------------------------------
I added the following powershell path under ncpa.cfg to see if that forces powershell to run under x64 but it keeps running it under x86
c:\Windows\Sysnative\WindowsPowerShell\v1.0\
# 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
#
# Linux / Mac OS X
.sh = /bin/sh $plugin_name $plugin_args
.py = python $plugin_name $plugin_args
# Windows
#.ps1 = powershell -ExecutionPolicy Bypass -File $plugin_name $plugin_args
.ps1 = C:\Windows\SysWOW64\WindowsPowerShell\v1.0\powershell.exe -ExecutionPolicy Unrestricted -File $plugin_name $plugin_args
.vbs = cscript $plugin_name $plugin_args //NoLogo
.bat = cmd /c $plugin_name $plugin_args
Is this a limitation because NCPA agent runs under x86?
Knowing that we are runnning the NCPA agents under Windows Server 2012 R2 X64 OS