Differences

This shows you the differences between two versions of the page.

Link to this comparison view

monitors:aspapplicationperfmon [2010/06/22 08:37] (current)
Line 1: Line 1:
 +====== ASP.NET Application Specific Performance Counters ======
  
 +^ Neil Franken| [[ neil_franken@yahoo.com | Neil Franken]] |
 +^ Compatibility | Xymon 4.2 |
 +^ Requirements | IIS, VBS|
 +^ Download | None |
 +^ Last Update | 2010-06-21 |
 +
 +===== Description =====
 +This script will monitor ASP.Net Application Specific Performance Counters. You will need to modify the script to point to a specific ASP application. For example you have a mission critical asp.net application called Warehouse you will need to change the script to monitor the application called Warehouse. You can also use the Total instance to get a specific overview. See the code for instructions on where to change the script to point to a specific application.
 +===== Installation =====
 +=== Client side ===
 +Edit the script to monitor the ASP Application of your choice. See Script for more instructions.
 +
 +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\aspapplicationperfmon.vbs” timer=“5m” />
 +
 +Once this is added to the cfg file it should create a sql 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 ==
 +
 +
 +    * Add aspapplications=ncv to the TEST2RRD section of the hobbitserver.cfg file. Please note that the aspapplications name must reflect the name of the test. You will change this to monitor a specific application.
 +    * Add the following definition to the hobbitserver.cfg. Once again remember to change the value aspapplications to reflect the name of the test.
 +<​code>​NCV_aspapplications="​ErrorsPerSecond:​GAUGE
 +,​RequestExecuting:​GAUGE
 +,​RequestFailed:​GAUGE
 +,​RequestNotAuthorized:​GAUGE
 +,​RequestNotFound:​GAUGE
 +,​RequestPerSecond:​GAUGE
 +,​RequestTimedOut:​GAUGE"​
 +</​code>​
 +
 +
 +    * Restart Xymon
 +== 2) Adding Graph Definition to the hobbitgraph.cfg file ==
 +  * Add the following to the file.Remember to chance the aspapplications name to reflect your test name
 +<hidden onHidden="​Show Graph Definition ⇲" onVisible="​Hide Graph Definition ⇱">​
 +<​code>​
 +[aspapplications]
 + TITLE YOUR ASP.NET Application Health
 + YAXIS Number
 + DEF:​ErrorsPerSecond=genisyshealth.rrd:​ErrorsPerSecond:​AVERAGE
 + VDEF:​ErrorsPerSecondmax=ErrorsPerSecond,​MAXIMUM
 + VDEF:​ErrorsPerSecondavg=ErrorsPerSecond,​AVERAGE
 +    VDEF:​ErrorsPerSecondmin=ErrorsPerSecond,​MINIMUM
 +    VDEF:​ErrorsPerSecondlast=ErrorsPerSecond,​LAST
 +
 + DEF:​RequestExecuting=genisyshealth.rrd:​RequestExecuting:​AVERAGE
 + VDEF:​RequestExecutingmax=RequestExecuting,​MAXIMUM
 + VDEF:​RequestExecutingavg=RequestExecuting,​AVERAGE
 +    VDEF:​RequestExecutingmin=RequestExecuting,​MINIMUM
 +   ​ VDEF:​RequestExecutinglast=RequestExecuting,​LAST
 +
 + DEF:​RequestFailed=genisyshealth.rrd:​RequestFailed:​AVERAGE
 + VDEF:​RequestFailedmax=RequestFailed,​MAXIMUM
 + VDEF:​RequestFailedavg=RequestFailed,​AVERAGE
 +    VDEF:​RequestFailedmin=RequestFailed,​MINIMUM
 +   ​ VDEF:​RequestFailedlast=RequestFailed,​LAST
 +
 + DEF:​RequestNotAuthorize=genisyshealth.rrd:​RequestNotAuthorize:​AVERAGE
 + VDEF:​RequestNotAuthorizemax=RequestNotAuthorize,​MAXIMUM
 + VDEF:​RequestNotAuthorizeavg=RequestNotAuthorize,​AVERAGE
 +    VDEF:​RequestNotAuthorizemin=RequestNotAuthorize,​MINIMUM
 +   ​ VDEF:​RequestNotAuthorizelast=RequestNotAuthorize,​LAST
 +
 + DEF:​RequestNotFound=genisyshealth.rrd:​RequestNotFound:​AVERAGE
 + VDEF:​RequestNotFoundmax=RequestNotFound,​MAXIMUM
 + VDEF:​RequestNotFoundavg=RequestNotFound,​AVERAGE
 +    VDEF:​RequestNotFoundmin=RequestNotFound,​MINIMUM
 +   ​ VDEF:​RequestNotFoundlast=RequestNotFound,​LAST
 +
 + DEF:​RequestPerSecond=genisyshealth.rrd:​RequestPerSecond:​AVERAGE
 + VDEF:​RequestPerSecondmax=RequestPerSecond,​MAXIMUM
 + VDEF:​RequestPerSecondavg=RequestPerSecond,​AVERAGE
 +    VDEF:​RequestPerSecondmin=RequestPerSecond,​MINIMUM
 +   ​ VDEF:​RequestPerSecondlast=RequestPerSecond,​LAST
 +
 + DEF:​RequestTimedOut=genisyshealth.rrd:​RequestTimedOut:​AVERAGE
 + VDEF:​RequestTimedOutmax=RequestTimedOut,​MAXIMUM
 + VDEF:​RequestTimedOutavg=RequestTimedOut,​AVERAGE
 +    VDEF:​RequestTimedOutmin=RequestTimedOut,​MINIMUM
 +   ​ VDEF:​RequestTimedOutlast=RequestTimedOut,​LAST
 +
 +
 + COMMENT: ​          
 + COMMENT:​\t\t Maximum ​  
 +    COMMENT:​\tAverage ​  
 + COMMENT:​\tMinimum ​  
 + COMMENT:​\tCurrent \l
 +
 + LINE2:​ErrorsPerSecond#​FF0000:​Errors/​Second ​      
 + GPRINT:​ErrorsPerSecondmax:​%8.0lf %S
 +    GPRINT:​ErrorsPerSecondavg:​\t%8.0lf %S
 +    GPRINT:​ErrorsPerSecondmin:​\t%8.0lf %S
 +    GPRINT:​ErrorsPerSecondlast:​\t%8.0lf %S\l
 +
 + LINE2:​RequestExecuting#​00FF66:​Executing ​          
 + GPRINT:​RequestExecutingmax:​%8.0lf %S
 +    GPRINT:​RequestExecutingavg:​\t%8.0lf %S
 +    GPRINT:​RequestExecutingmin:​\t%8.0lf %S
 +    GPRINT:​RequestExecutinglast:​\t%8.0lf %S\l
 +
 +
 + LINE2:​RequestPerSecond#​1ebdf8:​Request/​Second ​     ​
 + GPRINT:​RequestPerSecondmax:​%8.0lf %S
 +    GPRINT:​RequestPerSecondavg:​\t%8.0lf %S
 +    GPRINT:​RequestPerSecondmin:​\t%8.0lf %S
 +    GPRINT:​RequestPerSecondlast:​\t%8.0lf %S\l
 + COMMENT:​Data Not On Graph\l
 +
 + #​LINE2:​RequestFailed#​ff6c00:​Failed ​                
 + COMMENT:​Request Failed ​       ​
 + GPRINT:​RequestFailedmax:​%8.0lf %S
 +    GPRINT:​RequestFailedavg:​\t%8.0lf %S
 +    GPRINT:​RequestFailedmin:​\t%8.0lf %S
 +    GPRINT:​RequestFailedlast:​\t%8.0lf %S\l
 +
 + #​LINE2:​RequestNotAuthorize#​000000:​Not Authorized ​        
 + COMMENT:​Not Authorized ​       ​
 + GPRINT:​RequestNotAuthorizemax:​%8.0lf %S
 +    GPRINT:​RequestNotAuthorizeavg:​\t%8.0lf %S
 +    GPRINT:​RequestNotAuthorizemin:​\t%8.0lf %S
 +    GPRINT:​RequestNotAuthorizelast:​\t%8.0lf %S\l
 +
 + #​LINE2:​RequestNotFound#​b527d4:​Not Found              ​
 + COMMENT:​Not Found             
 + GPRINT:​RequestNotFoundmax:​%8.0lf %S
 +    GPRINT:​RequestNotFoundavg:​\t%8.0lf %S
 +    GPRINT:​RequestNotFoundmin:​\t%8.0lf %S
 +    GPRINT:​RequestNotFoundlast:​\t%8.0lf %S\l
 +
 +
 + #​LINE2:​RequestTimedOut#​d4ce27:​Timed Out              ​
 + COMMENT:​Timed Out             
 + GPRINT:​RequestTimedOutmax:​%8.0lf %S
 +    GPRINT:​RequestTimedOutavg:​\t%8.0lf %S
 +    GPRINT:​RequestTimedOutmin:​\t%8.0lf %S
 +    GPRINT:​RequestTimedOutlast:​\t%8.0lf %S\l
 +
 +</​code>​
 +</​hidden>​
 +
 +===== Source =====
 +==== aspapplicationperfmon.vbs====
 +
 +<hidden onHidden="​Show Code ⇲" onVisible="​Hide Code ⇱">​
 +<​code>​
 +' ASP.NET Applications Performancer Counters
 +' Author: Neil Franken
 +' email: neil_franken@yahoo.com
 +' Description: ​
 +' This script collects some performance counters related to a specific ASP Application. ​
 +'
 +' 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.
 +' BEFORE RUNNING THIS SCRIPT:
 +' 1) Change the following token <<​ASPNETAPPLICATION>>​ to the name of the ASP.NET Application you wish to profile.
 +' 2) Change the str Name to something like applicationname_asp i.e. google_asp, sharepoint_asp etc.
 +' 3) If you use the graph definition please change the name from aspapplications to the name you give the file.
 +' 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: 18/06/2010
 +'
 +
 +strAlarmState = "​green"​
 +strTestName = "​aspapplication"​ '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
 +
 +
 +' 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 Application Check Starts Here
 +strOutput = strOutput & vbCrLf & "​ASP.NET Application Information:"​ & vbCrLf
 +Set objWMIService = GetObject("​winmgmts:​\\"​ & strComputer & "​\root\cimv2"​)
 +'​------------------------------------------------------------------------------------
 +'​ YOU NEED TO MODIFY THIS SECTION TO MAKE IT WORK |
 +'​------------------------------------------------------------------------------------
 +' Change the token <<​ASPNETAPPLICATION>>​ to the application name you want to monitor ​
 +' To Check what name your application runs under you can use the peformance monitor
 +' to add a ASP.NET application performance counter. The applications running on the 
 +' server will be listed under instance names. ​
 +'​------------------------------------------------------------------------------------
 +
 +Set colItems = objWMIService.ExecQuery("​Select * from Win32_PerfFormattedData_ASPNET_ASPNETApplications Where name ='<<​ASPNETAPPLICATION>>'",,​48)
 +'​------------------------------------------------------------------------------------
 +'​ END OF SECTION YOU NEED TO MODIFY |
 +'​------------------------------------------------------------------------------------
 +For Each objItem In colItems
 + ErrorPerSec=objItem.ErrorsTotalPerSec
 + ReqExecuting= objItem.RequestsExecuting
 + ReqFailed=objItem.RequestsFailed
 + ReqNotAuthorized=objItem.RequestsNotAuthorized
 + ReqNotFound=objItem.RequestsNotFound
 + ReqPerSeq=objItem.RequestsPerSec
 + ReqTimedOut=objItem.RequestsTimedOut
 + Exit For
 +Next
 +strOutput = strOutput & CheckValue(ErrorPerSec,"​ErrorsPerSecond",​100,​ 300)
 +strOutput = strOutput & CheckValue(ReqExecuting,"​RequestExecuting",​100,​ 300)
 +strOutput = strOutput & CheckValue(ReqFailed,"​RequestFailed",​100,​ 300)
 +strOutput = strOutput & CheckValue(ReqNotAuthorized,"​RequestNotAuthorized",​100,​ 300)
 +strOutput = strOutput & CheckValue(ReqNotFound,"​RequestNotFound",​25,​ 75)
 +strOutput = strOutput & CheckValue(ReqPerSeq,"​RequestPerSecond",​300,​ 600)
 +strOutput = strOutput & CheckValue(ReqTimedOut,"​RequestTimedOut",​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
 +</​code>​
 +</​hidden>​
 +
 +===== Known  Bugs and Issues =====
 +    * Running a 32 Bit Windows on a 64 Bit CPU(It happens apparently). This causes the script to look for the HKEY_LOCAL_MACHINE\SOFTWARE\Wow6432Node\BBWin\tmppath registry key. This does not exist in a 32 windows version and the script will bomb. To fix comment out the Processor check and hard code(yuck) the bath to the BBwin\tmp folder.
 +
 +    * When running the script it throws a null exception which looks something like C:\Program Files (x86)\BBWin\ext\aspapplicationperfmon.vbs(103,​ 2) (null). To fix this problem open a command prompt and execute the following command wmiadap/f. Open the administrative tools under control panel and run the windows services manager. Right at the bottom of the list there is a WMI Performance Adapter service. Restart the service if started, if the service is not running please start it.
 +
 +===== To Do =====
 +It would be nice to have this script retrieve a list of all ASP.NET applications and list all of the applications and their respective performance counters. The main problem then would be to generate a graph with all these values. I could create a script to read the result set and then create the appropriate graph definition. However this is sufficient for now. 
 +===== Credits =====
 +  * Neil Franken
 +  * Chris Walker, Liberty Enterprises for his original IISHealth script.
 +===== Changelog =====
 +
 +  * **2010-06-21**
 +    * Initial release
 +  * **2010-06-22**
 +    * Initial release had debug functionallity included which was removed. Thanks to Carlos Arroba for reporting the issue. Copy and Paste is a blessing and curse.
  • monitors/aspapplicationperfmon.txt
  • Last modified: 2010/06/22 08:37
  • (external edit)