Page 1 of 5
IIS App Pool monitoring
Posted: Thu Dec 26, 2019 7:01 pm
by rferebee
Ok team, I give up. I've been working at this for a week and I cannot figure it out.
I'm attempting to monitor IIS Application Pools on a Windows Server 2008 box running IIS 7. This scenario is well documented all over the Support Forum, but despite my best efforts I can't get it to work. Can you please assist?
I'm using this custom command and the accompanying PS1 script:
https://outsideit.net/monitoring-iis-application-pools/
Here is the command running directly from my Nagios host:
Code: Select all
bash-4.2$ /usr/local/nagios/libexec/check_nrpe -H 10.xxx.xxx.xxx -p 5666 -t 60 -c check_ms_iis_application_pool -a '-A <Prepaid>'
Failed to execute check_ms_iis_application_pool: 57: The parameter is incorrect.
I made a few changes (outlined here:
https://support.nagios.com/forum/viewto ... =7&t=50294) to the nsclient.ini file stored on the host I'm attempting to build this check for and started getting the error shown above. Before the ini changes I was getting an error saying, "The specified application pool does not exist" (even though it does).
Not sure what else to look at. Let me know who I can PM my files to. Thank you!
Re: IIS App Pool monitoring
Posted: Fri Dec 27, 2019 10:19 am
by mbellerue
I would say revert your nsclient.ini changes. I like "The specified application pool does not exist" message better than the other one.
Next, assuming PrePaid is an application pool on your IIS server, take away the less-than/greater-than signs from the sides. Those exist in the documentation as formatting. I suspect you received the "application pool does not exist" message because it was searching for literally <PrePaid>, when the pool is named PrePaid. I could be wrong, but it's worth a shot.
Re: IIS App Pool monitoring
Posted: Fri Dec 27, 2019 10:51 am
by rferebee
Ok, I'm back to:
Code: Select all
CRITICAL: Application Pool "" does not exist.
I reverted my nsclient.ini changes and I'm running the command this way now:
Code: Select all
/usr/local/nagios/libexec/check_nrpe -H 10.xxx.xxx.xxx -p 5666 -t 60 -c check_ms_iis_application_pool -a '-A Prepaid'
I confirmed my list of application pools by running:
C:\Windows\system32\inetsrv\appcmd list apppool from a PS window. Unfortunately, my service check isn't working for any of the application pools on the list.
Re: IIS App Pool monitoring
Posted: Fri Dec 27, 2019 11:12 am
by mbellerue
Okay, go ahead and PM me your nsclient.ini file, and the script you are calling. I will take a look at it and see if I can find out what's going on.
Re: IIS App Pool monitoring
Posted: Fri Dec 27, 2019 11:21 am
by rferebee
PM sent, thank you very much for your help.
Re: IIS App Pool monitoring
Posted: Fri Dec 27, 2019 11:40 am
by mbellerue
You are always welcome!
Okay, so the issue of the pool name not getting passed to the script is in your nsclient.ini file. Line 227, where you have check_ms_iis_application_pool defined.
Existing
Code: Select all
check_ms_iis_application_pool=check_ms_iis_application_pool.ps1
Change to this,
Code: Select all
check_ms_iis_application_pool=powershell check_ms_iis_application_pool.ps1 $ARG1$
That definition will likely also need to be under settings/external scripts/scripts in nsclient.ini. I think wrapped scripts is for scripts that act as wrappers for other scripts.
Give that a shot, don't forget to restart the NSClient service, and let m know how it goes.
Re: IIS App Pool monitoring
Posted: Fri Dec 27, 2019 11:46 am
by rferebee
Ok, I made those changes and the error reverted back to:
Code: Select all
Failed to execute check_ms_iis_application_pool: 57: The parameter is incorrect.
I also tried it be defining powershell.exe instead of just powershell, but that didn't make a difference.
Re: IIS App Pool monitoring
Posted: Fri Dec 27, 2019 11:59 am
by rferebee
When I attempt to run the script directly from a PS window I get the following error message:
Code: Select all
PS C:\Program Files\NSClient++\scripts\powershell> .\check_ms_iis_application_pool.ps1 -A Prepaid
Get-WmiObject : Invalid namespace
At C:\Program Files\NSClient++\scripts\powershell\check_ms_iis_application_pool.ps1:317 char:53
+ $IISStruct.ProcessId = Get-WmiObject <<<< -NameSpace 'root\WebAdministration' -class 'WorkerProcess'
| Where-Object {$_.AppPoolName -match $IISStruct.ApplicationPool} | Select-Object -Expand ProcessId
+ CategoryInfo : InvalidOperation: (:) [Get-WmiObject], ManagementException
+ FullyQualifiedErrorId : GetWMIManagementException,Microsoft.PowerShell.Commands.GetWmiObjectCommand
OK: Application Pool Started but no process is assigned yet "Prepaid" with 0 Applications. {CPU: 0%}{Memory: 0MB} | 'po
ol_cpu'=0%;;;0;100 'pool_memory'=0MB;;;0; 'app_count'=0
Re: IIS App Pool monitoring
Posted: Fri Dec 27, 2019 12:39 pm
by ssax
If you open a powershell prompt as admin, what does this output (attach in a text file):
Code: Select all
Get-WmiObject -Class "__Namespace" -Namespace "root"
Get-WmiObject -List -Class "*WorkerProcess*"
Re: IIS App Pool monitoring
Posted: Fri Dec 27, 2019 12:51 pm
by rferebee
Please see attached. Thank you.