IIS sites monitoring

This support forum board is for support questions relating to Nagios XI, our flagship commercial network monitoring solution.
Naveed
Posts: 285
Joined: Mon May 30, 2016 10:10 am

IIS sites monitoring

Post by Naveed »

Hello,

I have configured IIS web server on windows 2012 R2 server, I have created some sites on it.

All my windows services are monitoring fine with nrpe on it.

Can someone suggest the way to monitor these services?

I have attached screenshots for verification.

Thanks
You do not have the required permissions to view the files attached to this post.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: IIS sites monitoring

Post by mcapra »

I suppose that would depend on what sorts of metrics you want to monitor. We have a few options for generic webpage response times and page sizes with our check_http plugin included with Nagios XI. This plugin is leveraged by our "Website URL" and "Website" wizards.

If you wanted to monitor usage of a given IIS app pool, @willemdh wrote a lovely powershell script for that:
https://github.com/willemdh/check_ms_ii ... ation_pool

At any rate, a good place to start when asking the question of "How do I monitor X" is the Nagios Exchange to see if other users have solutions for your use case.
Former Nagios employee
https://www.mcapra.com/
Naveed
Posts: 285
Joined: Mon May 30, 2016 10:10 am

Re: IIS sites monitoring

Post by Naveed »

Thanks,

I am able to monitor specific URLs now.

But on few URLs, its showing warning alerts with error on it

HTTP WARNING: HTTP/1.1 401 Microsoft_Dynamics_Commerce_Runtime_SessionExpired - 1898 bytes in 0.120 second response time

please explain this.

Thank you!
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: IIS sites monitoring

Post by mcapra »

I don't have much experience with Azure, but if the url/page you are checking has any sort of non-trivial session control in place seeing a 401 is expected behavior. If the page is expecting the user to have session data, you would need to find a way to create/pass session data as a part of the service check. That's not something I can provide much insight on without knowing how the web page/application behaves on the back-end.

Try adding -v to your command and running it from the CLI to get verbose output. That might offer additional insight on what is happening. If you need help with this, please share the check_command definition used for your service.

You can also pass POST data with check_http if you have a way to create a session:

Code: Select all

 -P, --post=STRING
    URL encoded http POST data
Former Nagios employee
https://www.mcapra.com/
Naveed
Posts: 285
Joined: Mon May 30, 2016 10:10 am

Re: IIS sites monitoring

Post by Naveed »

Hi,

Can you please share the syntax or usage of command for the already shared powershell script.

Thank you!
Naveed
Posts: 285
Joined: Mon May 30, 2016 10:10 am

Re: IIS sites monitoring

Post by Naveed »

I have attached the iis application pool monitoring script from nagios xi forum..

[/settings/external scripts/wrapped scripts]
check_iis_apppool_state="C:\Program Files\NSClient++\scripts\check_iis_apppool_state.vbs" $ARG1$

My command and error message is also attached for review.

its giving error on line 87, whereas plugin contains only 72 lines.

please guide.

Thanks
You do not have the required permissions to view the files attached to this post.
Naveed
Posts: 285
Joined: Mon May 30, 2016 10:10 am

Re: IIS sites monitoring

Post by Naveed »

script is attached as well

Code: Select all

===================
'------------------------------------------------------------------------------
' IIS v6 Check state of an application pool
' =========================================
'
' Author: Vincent BESANCON ([email protected])
' Usage:
'	check_iis_apppool_state.vbs <pool_name>
'		<pool_name>	- The name of the application pool.
'
' It returns:
'    - OK if state is running.
'    - CRITICAL if state is stopped.
'    - WARNING if state is stopping or starting.
'    - UNKNOWN for all the others (app pool not found, etc...).
'
' Nagios Agent configuration (NSC.INI):
'	check_iis_apppool_state=cscript.exe //nologo //T:60 scripts\check_iis_apppool_state.vbs $ARG1$
'------------------------------------------------------------------------------
'
' Args
strArgAppPool = Wscript.Arguments.Unnamed.Item(0)

' Establish the connection to the WMI provider
Set oWMIService = GetObject("winmgmts:root\microsoftiisv2")

' Search the AppPool passed as argument in the list of application pools
Set strQueryAppPools = oWMIService.ExecQuery("Select * from IIsApplicationPoolSetting where Name='W3SVC/AppPools/" & strArgAppPool & "'")

' Enumerate the pools
noError = False

For Each oAppPool in strQueryAppPools
	noError = True
	
	' Create nice messages for pool states
	Select Case oAppPool.AppPoolState
		Case 1
			poolState = "Starting"
			outputStatus = "WARNING: "
			outputCode = 1
		Case 2
			poolState = "Running"
			outputStatus = "OK: "
			outputCode = 0
		Case 3
			poolState = "Stopping"
			outputStatus = "WARNING: "
			outputCode = 1
		Case 4
			poolState = "Stopped"
			outputStatus = "CRITICAL: "
			outputCode = 2
		Case else
			poolState = "unknown"
			outputStatus = "UNKNOWN: "
			outputCode = 3
	End Select
	
	' Create a clear name for the pool (remove the leading info)
	poolName = Replace(oAppPool.Name, "W3SVC/AppPools/", "")
	
	' Output
	Wscript.Echo outputStatus & poolName & ", State: " & poolState
Next

' Error handling
If Not noError Then
	' Error message
	Wscript.echo "UNKNOWN: Error during the WMI query for app pool " & strArgAppPool & " !"
	' Exit & return code
	WScript.Quit(3)
Else
	' Clean exit
	WScript.Quit(outputCode)
End If
Last edited by dwhitfield on Wed Dec 07, 2016 4:34 pm, edited 1 time in total.
Reason: code blocks FTW
User avatar
ruffsense
Posts: 140
Joined: Thu Apr 11, 2013 12:40 am

Re: IIS sites monitoring

Post by ruffsense »

why not use the powershell script. @Naveed
mcapra wrote:I suppose that would depend on what sorts of metrics you want to monitor. We have a few options for generic webpage response times and page sizes with our check_http plugin included with Nagios XI. This plugin is leveraged by our "Website URL" and "Website" wizards.

If you wanted to monitor usage of a given IIS app pool, @willemdh wrote a lovely powershell script for that:
https://github.com/willemdh/check_ms_ii ... ation_pool

At any rate, a good place to start when asking the question of "How do I monitor X" is the Nagios Exchange to see if other users have solutions for your use case.
I don't insult, I diagnose.
User avatar
mcapra
Posts: 3739
Joined: Thu May 05, 2016 3:54 pm

Re: IIS sites monitoring

Post by mcapra »

Naveed wrote: its giving error on line 87, whereas plugin contains only 72 lines.
The plugin i've shared has 295 lines total.
https://github.com/willemdh/check_ms_ii ... n_pool.ps1

I would highly recommend using the plugin created by @WillemDH as I was never able to get the one you're currently trying to use to work correctly.
Former Nagios employee
https://www.mcapra.com/
Naveed
Posts: 285
Joined: Mon May 30, 2016 10:10 am

Re: IIS sites monitoring

Post by Naveed »

Thank you

I have placed your powershell script in "C:\Program Files\NSClient++\scripts\\check_iis.ps1" and made below changes in nsclient.ini file.


; A list of scripts available to run from the CheckExternalScripts module. Syntax is: <command>=<script> <arguments>
[/settings/external scripts/scripts]

check_iis_apppool_state=wscript.exe //nologo //T:60 "C:\Program Files\NSClient++\scripts\\check_iis.ps1" $ARG1$

ps1 = cmd /c echo scripts%SCRIPT%\%ARGS%; exit($lastexitcode) | powershell.exe -ExecutionPolicy Bypass -command -

Command in nagios is attached,

Service results are as CHECK_NRPE: Socket timeout after 30 seconds.

Please check and guide If I am doing anything wrong here.

Thanks
You do not have the required permissions to view the files attached to this post.
Locked