Page 1 of 2

IIS 6 Application Pool State Monitoring

Posted: Tue Aug 01, 2017 10:56 am
by Sampath.Basireddy
How do I monitor IIS 6 Application Pool State Monitoring on a Windows Server with NCPA?

I did find few plugins on exchange.nagios.org, but most of them are for NSClient++. Is there a way I can use the same plugin to work with NCPA. If yes, please help.

Here is the plugin I am trying to configure, but the steps are for NSClient. Would be really great help if someone can guide me how to use it with NCPA.

https://exchange.nagios.org/directory/P ... 1501271895


Thanks.

Re: IIS 6 Application Pool State Monitoring

Posted: Tue Aug 01, 2017 12:58 pm
by mcapra
The official NCPA documentation should get you started:
https://www.nagios.org/ncpa/help.php
https://www.nagios.org/ncpa/help/2.0/ap ... es-plugins
https://www.nagios.org/ncpa/help/2.0/ap ... ing-plugin

Essentially, you place the plugin in the NCPA plugins path (as defined in the [plugin directives] section of your NCPA configuration file) then call it via the NCPA API.

Re: IIS 6 Application Pool State Monitoring

Posted: Wed Aug 02, 2017 9:37 am
by tmcdonald
Thanks for the assist, @mcapra! OP, let us know if you need further assistance.

Re: IIS 6 Application Pool State Monitoring

Posted: Wed Aug 02, 2017 10:46 am
by Sampath.Basireddy
Thank you @mcapra.

I followed the instructions and created a service check, but it is throwing some error. Here are the details.

Below is the output when I run the check command from Nagios XI:

Code: Select all

[nagios@<SRV Name> ~]$ /usr/local/nagios/libexec/check_ncpa.py -H <Host Name> -t '<Token>' -P 5693 -M 'plugins/check_ms_iis_application_pool.ps1' -a OEPool
CRITICAL: Argument: OEPool Value:  Error: Illegal arguments detected: OEPool
Below is the output when I run from Nagios Server CLI:

Code: Select all

UID@<SRV Name>:[~]: /usr/local/nagios/libexec/check_ncpa.py -H <Host Name> -t '<Token>' -P 5693 -M 'plugins/check_ms_iis_application_pool.ps1' -a OEPool
CRITICAL: Argument: OEPool Value: Error: Illegal arguments detected: OEPool

Please note that, when I run the script manually on the IIS Server itself, it works fine. Here is the output when I run it locally.
This output is when the IIS Application Pool was stopped:

Code: Select all

PS C:\Program Files (x86)\Nagios\NCPA\plugins> .\check_ms_iis_application_pool.ps1 -A OEPool
CRITICAL: Application Pool "OEPool" is Stopped.
PS C:\Program Files (x86)\Nagios\NCPA\plugins> 
This output is when the the IIS Application Pool is started:

Code: Select all

PS C:\Program Files (x86)\Nagios\NCPA\plugins> ./check_ms_iis_application_pool.ps1 -A OEPool
OK: Application Pool "OEPool" with 2 Applications. {CPU:  %}{Memory: 0 MB} | 'pool_cpu'=%, 'pool_memory'=0MB, 'app_count'=2
PS C:\Program Files (x86)\Nagios\NCPA\plugins>

Any help is greatly appreciated.

And I have attached the error output when I try to access the scripts from NCPA Console via APIs

Re: IIS 6 Application Pool State Monitoring

Posted: Wed Aug 02, 2017 4:55 pm
by tgriep
Can you post the ncpa.cfg file from the Windows Host?
You can find it in this folder.

Code: Select all

C:\Program Files (x86)\Nagios\NCPA\etc
From the Error, it looks like the -A option is not defined in the command.

Re: IIS 6 Application Pool State Monitoring

Posted: Thu Aug 03, 2017 9:54 am
by Sampath.Basireddy
Here is the ncpa.cfg.

Code: Select all

[listener]
uid = nagios
certificate = adhoc
loglevel = info
ip = 0.0.0.0
gid = nagcmd
logfile = var/ncpa_listener.log
port = 5693
pidfile = var/ncpa_listener.pid
# Available versions: PROTOCOL SSLv2, SSLv3, TLSv1
ssl_version = TLSv1

[passive]
uid = nagios
handlers = nrds,nrdp
loglevel = info
gid = nagcmd
sleep = 300
logfile = var/ncpa_passive.log
pidfile = var/ncpa_passive.pid

[nrdp]
token =
hostname =
parent =

[nrds]
URL =
CONFIG_VERSION =0
TOKEN =
CONFIG_NAME =
CONFIG_OS = None
PLUGIN_DIR=plugins/
UPDATE_CONFIG=1
UPDATE_PLUGINS=1

[api]
community_string =<Token>

[plugin directives]
plugin_path = plugins/
.sh = /bin/sh $plugin_name $plugin_args
.ps1 = powershell -ExecutionPolicy Bypass -File $plugin_name $plugin_args
.vbs = cscript $plugin_name $plugin_args //NoLogo

[passive checks]
%HOSTNAME%|cpu usage = /cpu/percent --warning 20 --critical 30
%HOSTNAME%|swap usage = /memory/swap/percent --warning 40 --critical 80
%HOSTNAME%|memory usage = /memory/virtual/percent --warning 60 --critical 80
And I did update the script to accept -a, but still no luck.

Re: IIS 6 Application Pool State Monitoring

Posted: Thu Aug 03, 2017 12:54 pm
by tgriep
Try running the command like the example below adding the -A to the arguments option and see if this works.
/usr/local/nagios/libexec/check_ncpa.py -H <Host Name> -t '<Token>' -P 5693 -M 'plugins/check_ms_iis_application_pool.ps1' -a '-A OEPool'

Re: IIS 6 Application Pool State Monitoring

Posted: Thu Aug 03, 2017 1:29 pm
by Sampath.Basireddy
Tried that as well, but no luck.

Here is the output:

Code: Select all

UID@SRV:[~]: /usr/local/nagios/libexec/check_ncpa.py -H <SRV Name> -t '<Token>' -M 'plugins/check_ms_iis_application_pool.ps1' -a '-A OEPool' -v
Connecting to: https://<SRV Name>:5693/api/plugins/check_ms_iis_application_pool.ps1/-A/OEPool?token=<Token>&check=1
File returned contained:
{
    "returncode": 2,
    "stdout": "CRITICAL: Argument: -A Value: OEPool Error: Illegal arguments detected: -A"
}
CRITICAL: Argument: -A Value: OEPool Error: Illegal arguments detected: -A
UID@SRV:[~]:

Re: IIS 6 Application Pool State Monitoring

Posted: Thu Aug 03, 2017 4:32 pm
by tgriep
Can you post your check_ms_iis_application_pool.ps1 script so we can view it?
It looks like the plugin passed the arguments correctly to that script.

Re: IIS 6 Application Pool State Monitoring

Posted: Thu Aug 03, 2017 4:33 pm
by bolson
Try this:

Code: Select all

/usr/local/nagios/libexec/check_ncpa.py -H <Host Name> -t '<Token>' -P 5693 -M 'plugins/check_ms_iis_application_pool.ps1 OEPool'
It likely won't work but it should give us a different error message.

I think the issue is that the argument '-a OEPool' is being interpreted as an argument for check_ncpa.py rather than for check_ms_iis_application_pool.ps1.