Table of Contents

ASP.NET Performance Counter Pack

Author Neil Franken
Compatibility Xymon 4.2
Requirements IIS, ASP.NET, VBS
Download None
Last Update 2010-06-22

Description

This script will monitor some basic performance counters for the overall ASP.NET Health on a server. The counters monitored are:

Installation

Client side

Place the script on the IIS Server you want to monitor and add a appropriate section to the BBWin.cfg externals section.

Typically it would be configured like this. <load value=“cscript c:\VBSScripts\aspnethealth.vbs” timer=“5m” />

Once this is added to the cfg file it should create a aspnethealth file in the tmp directory of BBwin for upload. If this is the case it is working.

Server side

While the Xymon server does not require any installation you can add the following to the hobbitserver.cfg to create a graph with some of the more important values on.

1) Adding NCV Definition to the hobbitserver.cfg file
NCV_asphealth="RequestsQueued:GAUGE,RequestCurrent:GAUGE,ApplicationRestarts:GAUGE,ApplicationRunning:GAUGE"
2) Adding Graph Definition to the hobbitgraph.cfg file

Show Graph Definition ⇲

Hide Graph Definition ⇱

[aspnethealth]

		TITLE ASP Overall Health
		YAXIS Number
		DEF:RequestsQueued=asphealth.rrd:RequestsQueued:AVERAGE
		DEF:RequestCurrent=asphealth.rrd:RequestCurrent:AVERAGE
		LINE2:RequestsQueued#FF0000:RequestsQueued
		LINE2:RequestCurrent#00FF66:RequestCurrent
		COMMENT:\n
		GPRINT:RequestsQueued:LAST:RequestsQueued\: %5.1lf%s (cur)
		GPRINT:RequestsQueued:MAX: \: %5.1lf%s (max)
		GPRINT:RequestsQueued:MIN: \: %5.1lf%s (min)
		GPRINT:RequestsQueued:AVERAGE: \: %5.1lf%s (avg)\n
		GPRINT:RequestCurrent:LAST:RequestCurrent\: %5.1lf%s (cur)
		GPRINT:RequestCurrent:MAX: \: %5.1lf%s (max)
		GPRINT:RequestCurrent:MIN: \: %5.1lf%s (min)
		GPRINT:RequestCurrent:AVERAGE: \: %5.1lf%s (avg)\n

Source

aspnethealth.vbs

Show Code ⇲

Hide Code ⇱

' ASP.NET Applications Performancer Counters
' Author: Neil Franken
' email: neil_franken@yahoo.com
' Description: 
' This script collects some performance counters related to a overall ASP health i.e. the server. 
'
' You are welcome to use, modify, mangle and do what you please with this script just please
' keep me in the loop about bugs,updates and or improvements.
' 
' IMPORTANT NOTES:
' Before running this script please do the following. Open a command prompt on the SQL server where the script
' runs. Run the following command wmiadap/f.
' Open the services manager screen and restart/start the WMI performance adapter service. This service must be running
' to read the performance counters via the WMI interface.

' KNOWN ISSUE:
' I encountered a problem where the CPU was 64 Bit but the installed OS was 32Bit. This caused the registry read to fail.
' If you have a 32 Bit OS running on a 64 bit system yuo will have to change the script to point to the BBWin\tmp folder 
' as the script will attempt to read the value from a registry key that dont exist. Also comment out the ProcessorCheck function.
'


' Version 0.5 Released: 22/06/2010
'

strAlarmState = "green"
strTestName = "aspnethealth" 'this Is the filename i.e. column name in xymon.
strOutput = ""
Const strComputer = "."
Dim objWMIService, colItems, objItem
Dim ErrorPerSec, ReqExecuting, ReqFailed, ReqNotAuthorized, ReqNotFound, ReqPerSeq,ReqTimedOut
Set ws = WScript.CreateObject("WScript.Shell")

ProcessorCheck
If Proc = "x86" Then
	'            extPath = "c:\"
		extPath = ws.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\BBWin\tmppath") 'Registry key that stores the ext script path on 32bit Architecture
	'	WScript.Echo Proc
Else
	'            extPath = "c:\"  
		extPath = ws.RegRead("HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\BBWin\tmppath") 'Registry key that stores the ext script path on 64bit Architecture
	'	WScript.Echo Proc
End If
extPath = "c:\"

' Usage of the CheckValue,CheckReserveValue Functions:
' CheckValue takes the Performance Counter value,a description which appears on Xymon,the warning value and the Alarm value and does a check for values above the warn and alarm thresholds.
' CheckReverseValue takes the Performance Counter value,a description which appears on Xymon,the warning value and the Alarm value and does a check for values below the warn and alarm thresholds.
'

' ASP.NET Check Starts Here
strOutput = strOutput & vbCrLf & "ASP.NET Application Information:" & vbCrLf
Set objWMIService = GetObject("winmgmts:\\" & strComputer & "\root\cimv2")
Set colItems = objWMIService.ExecQuery("Select * from Win32_PerfFormattedData_ASPNET_ASPNET",,48)
For Each objItem in colItems
	AppRestarts 	=objItem.ApplicationRestarts
	AppRunning  	=objItem.ApplicationsRunning
	ReqCurrent		=objItem.RequestsCurrent
	ReqQueued 		=objItem.RequestsQueued
	Exit For
Next
strOutput = strOutput & CheckValue(AppRestarts,"ApplicationRestarts",1, 5)
strOutput = strOutput & CheckValue(AppRunning,"ApplicationRunning",3, 5)
strOutput = strOutput & CheckValue(ReqQueued,"RequestFailed",50, 150)
strOutput = strOutput & CheckValue(ReqCurrent,"RequestCurrent",100, 300)


' Write the file for BB
WriteFile extPath, strTestName, strAlarmState, strOutput

'===========================================================
' FUNCTIONS and SUBS start here



Sub ProcessorCheck ()
	Dim  WshShell, WshSysEnv
	
	Set WshShell = WScript.CreateObject("WScript.Shell")
	Set WshSysEnv = WshShell.Environment("SYSTEM")
	Proc = WshSysEnv("PROCESSOR_ARCHITECTURE")
End Sub



' This is used to check the actual value against the warning and alarm.
Function CheckValue(iObjectValue,strObjectDesc,iWarnValue,iAlarmValue)
	If iWarnValue > iAlarmValue Then
		CheckValue = "&red" & " " & strObjectDesc & ":" & vbTab & "Object is Misconfigured"
		If strAlarmState <> "red" Then
			strAlarmState = "red"
		End If
	Else
		If CDbl(iObjectValue) > CDbl(iWarnValue) Then
			If  CDbl(iObjectValue) >  CDbl(iAlarmValue) Then
				CheckValue = "&red" & " " & strObjectDesc & ":" & vbTab & iObjectValue & vbCrLf
				SetAlarmStatus "red"
			Else
				CheckValue = "&yellow" & " " & strObjectDesc & ":" & vbTab & iObjectValue & vbCrLf
				'CheckValue = "&yellow" &  strObjectDesc &  vbTab & iObjectValue & vbCrLf
				SetAlarmStatus "yellow"
			End If
		Else
			CheckValue = "&green" & " " & strObjectDesc & ":" & vbTab & iObjectValue & vbCrLf
			'CheckValue = "&green"  & strObjectDesc & vbTab & iObjectValue & vbCrLf
		End If
	End If
End Function


' This is used to check the actual value against the warning and alarm.
' This one the alarm will be a lower value than the warning. (Values Decrease rather than increase)
Function CheckReverseValue(iObjectValue,strObjectDesc,iWarnValue,iAlarmValue)
	If  CDbl(iWarnValue) <  CDbl(iAlarmValue) Then
		CheckReverseValue = "&red" & " " & strObjectDesc & ":" & vbTab & "Object is Misconfigured"
		If strAlarmState <> "red" Then
			strAlarmState = "red"
		End If
	Else
		If  CDbl(iObjectValue) <  CDbl(iWarnValue) Then
			If  CDbl(iObjectValue) <  CDbl(iAlarmValue) Then
				CheckReverseValue = "&red" & " " & strObjectDesc & ":" & vbTab & iObjectValue & vbCrLf
				SetAlarmStatus "red"
			Else
				CheckReverseValue = "&yellow" & " " & strObjectDesc & ":" & vbTab & iObjectValue & vbCrLf
				SetAlarmStatus "yellow"
			End If
		Else
			CheckReverseValue = "&green" & " " & strObjectDesc & ":" & vbTab & iObjectValue & vbCrLf
		End If
	End If
End Function


' This is called to set the overall alarm status.
Sub SetAlarmStatus(strnewAlarmState)
	If strnewAlarmState = "red" Then
		strAlarmState = strnewAlarmState
	ElseIf strnewAlarmState = "yellow" Then
		If strAlarmState <> "red" Then
			strAlarmState = strnewAlarmState
		End If
	End If
End Sub


' This SUB is used for outputting the file to the external's directory in bb
Sub WriteFile(strExtPath, strTestName, strAlarmState, strOutput)
	Set fso = CreateObject("Scripting.FileSystemObject")
	strOutput = strAlarmState & " " & Date & " " & Time & vbCrLf & vbCrLf & strOutput & vbCrLf
	Set f = fso.OpenTextFile(strExtPath & "\" & strTestName , 8 , True)
	f.Write strOutput
	f.Close
	Set fso = Nothing
End Sub

Known Bugs and Issues

To Do

Credits

Changelog