Monitor IIS Application Pool

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Locked
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Monitor IIS Application Pool

Post by jkinning »

I have a Business Unit that just upgraded their application to a newer version. Previously it just used a service check to make sure it was running but not looks like it leverages IIS application pool and I am trying to figure out how I can monitor that status for started or stopped?

Here is the command I was using previously

Code: Select all

check_nrpe -H eas4t -t 55 -c CheckServiceState -a ShowAll EASSLOAD
Using the NSClient++ with Nagios XI 5.2.8.
You do not have the required permissions to view the files attached to this post.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Monitor IIS Application Pool

Post by rkennedy »

There are a few different plugins on our Exchange (https://exchange.nagios.org) that should work for this. I found this one, which has pretty good reviews.

Give it a try, and let us know if you have any questions.
https://exchange.nagios.org/directory/P ... te/details
Former Nagios Employee
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Re: Monitor IIS Application Pool

Post by jkinning »

I haven't ever used any "out-of-the-box" plugins but I followed the instructions in the comments but I am getting this message:

Code: Select all

./check_nrpe -H eas4t -t 30 -c check_iis_apppool_state -a "EasServices"
Unknown command(s): check_iis_apppool_state
Here is what I have done.
1. Add the vbs script to C:\Program Files\NSClient++\scripts
I renamed mine to: check_iis_apppool_state.vbs
Also assumed you have installed the 64bit version.

2. In your NSCLIENT.ini file, add the following:

a. Settings for your external scripts
[/settings/external scripts]
allow arguments = 1
allow nasty characters = 1
timeout = 90

b. A Wrapped scripts section
[/settings/external scripts/wrapped scripts]
check_iis_apppool_state=cscript.exe scripts\\check_iis_apppool_state.vbs $ARG1$

c. the wrappings section
[/settings/external scripts/wrappings]
vbs = cscript.exe //T:30 //NoLogo scripts\\lib\\wrapper.vbs %SCRIPT% %ARGS%
exe = cmd /c %SCRIPT% %ARGS%

* You don't need to create an alias.
The way this works is that nagios will use npre to call check_iis_apppool_state, which in turn will call csript, which since it's an exe will require the exe wrapper. And since your calling a vbs, you need the vbs wrapper.

Saved the nsclient.ini file and restarted the NSclient service.

3. In Nagios, create a new command. For those of you who have not created commands before, This is done in Core Config.

I called my command: check_iis_apppool_state

The important part of the command is that whatever is after the -c , must match what you put in your ini file.

Mine looks like this:
$USER1$/check_nrpe -H $HOSTADDRESS$ -t 30 -c check_iis_apppool_state -a "$ARG1$"

MAKE SURE YOU QUOTE $ARG1$ or else you will spend hours trying to figure out why it is not working. In other words, copy and paste exactly what it looks like.
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Re: Monitor IIS Application Pool

Post by jkinning »

Here is the nsclient.ini file from the Windows 2012r2 server I am trying to run it on.
You do not have the required permissions to view the files attached to this post.
User avatar
WillemDH
Posts: 2320
Joined: Wed Mar 20, 2013 5:49 am
Location: Ghent
Contact:

Re: Monitor IIS Application Pool

Post by WillemDH »

This one works very well for me and also monitors cpu and memory usage of the w3wp.exe process linked to the application pool => https://outsideit.net/check-ms-iis-application-pool/

But you need to install the IIS Management Scripts and Tools feature for the script to work properly.
Nagios XI 5.8.1
https://outsideit.net
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Monitor IIS Application Pool

Post by rkennedy »

It looks like you added it under the wrong part -

Code: Select all

[/settings/external scripts/wrappings]
check_iis_apppool_state = cscript.exe scripts\\check_iis_apppool_state.vbs $ARG1$
NSClient++ is pretty picky in regards to where everything is placed. Try putting it under what the plugin mentions -

Code: Select all

[/settings/external scripts/wrapped scripts]
check_iis_apppool_state=cscript.exe scripts\\check_iis_apppool_state.vbs $ARG1$
Alternatively, a lot of people have had success with what @WillemDH brings to the table. If you're unable to get it working, It's worth taking a look at Willems guide he posted above. (thanks Willem!)
Former Nagios Employee
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Re: Monitor IIS Application Pool

Post by jkinning »

I am trying both now with focus on WillemDH method. Both I am getting the same error.

Code: Select all

Failed to execute check_ms_iis_application_pool: 87: The parameter is incorrect.

Code: Select all

Failed to execute check_iis_apppool_state: 87: The parameter is incorrect.
I also modified the nsclient.ini file as well. IIS Management Scripts and Tools are also installed.
You do not have the required permissions to view the files attached to this post.
rkennedy
Posts: 6579
Joined: Mon Oct 05, 2015 11:45 am

Re: Monitor IIS Application Pool

Post by rkennedy »

Try moving it below this section (add it to your configuration) (you may also need to adjust the path to the powershell script if you didn't save it in the scripts/powershell/ directory) -

Code: Select all

[settings/external scripts/external scripts]
check_ms_iis_application_pool=cmd /c echo scripts/powershell/check_ms_iis_application_pool.ps1 $ARG1$; exit $LastExitCode | powershell.exe /noprofile -command -
Former Nagios Employee
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Re: Monitor IIS Application Pool

Post by jkinning »

Now I am back to the original message

Code: Select all

./check_nrpe -H eas4t -p 5666 -t 30 -c check_ms_iis_application_pool -a '-A EasServices'
Unknown command(s): check_ms_iis_application_pool
jkinning
Posts: 747
Joined: Wed Oct 09, 2013 2:54 pm

Re: Monitor IIS Application Pool

Post by jkinning »

I finally got this working. The nsclient.ini file really is finicky and I discovered I needed to add additional settings for /settings/external scripts.

Thanks for the suggestions for the check_ms_iis_application_pool file check. I like how it gives CPU and Memory usage and the fact it is being actively worked on for additional features and improvements.

Feel free to close at your convenience.
Locked