Monitors the TFS Administration web service for availability on each AT Tier server.
If an error occurs on this monitor it is likely due to an AT Tier server not being available. Check to make sure the AT tier server reporting the error is running.
Target | TeamFoundationServer2012.TFSAdministrationWebService |
Parent Monitor | System.Health.AvailabilityState |
Category | AvailabilityHealth |
Enabled | True |
Alert Generate | False |
Alert Auto Resolve | False |
Monitor Type | Microsoft.Windows.TimedScript.TwoStateMonitorType |
Remotable | False |
Accessibility | Public |
RunAs | TFS2012UserProfile |
<UnitMonitor ID="TeamFoundationServer2012.MonitorForAdministrationWebService" Accessibility="Public" Enabled="true" Target="TeamFoundationServer2012.TFSAdministrationWebService" ParentMonitorID="Health!System.Health.AvailabilityState" Remotable="false" Priority="Normal" RunAs="TFS2012UserProfile" TypeID="Windows!Microsoft.Windows.TimedScript.TwoStateMonitorType" ConfirmDelivery="false">
<Category>AvailabilityHealth</Category>
<OperationalStates>
<OperationalState ID="Success" MonitorTypeStateID="Success" HealthState="Success"/>
<OperationalState ID="Error" MonitorTypeStateID="Error" HealthState="Warning"/>
</OperationalStates>
<Configuration>
<IntervalSeconds>120</IntervalSeconds>
<SyncTime/>
<ScriptName>AdminWebServiceMonitor.vbs</ScriptName>
<Arguments>3 $Target/Property[Type="TeamFoundationServer2012.TFSBaseWebService"]/InstalledPort$ $Target/Property[Type="TeamFoundationServer2012.TFSBaseWebService"]/useSSL$ $Target/Property[Type="TeamFoundationServer2012.TFSBaseWebService"]/VirtualDirectory$</Arguments>
<ScriptBody> Option Explicit
SetLocale("en-us")
''''###### Monitor For Administration Web Service #######
Dim logOutputEnabled
' Change this to log all messages in this script to the event log
logOutputEnabled = False
Dim oArgs
Set oArgs = WScript.Arguments
If oArgs.Count < 4 Then
Call TraceLogMessage("Argument count is less than 3 :: exiting ")
Wscript.Quit -1
End If
Dim ActiveRequestCountLimit
ActiveRequestCountLimit = oArgs(0)
i_InstalledPort = oArgs(1)
Dim useSSL
useSSL = ConvStrBool(oArgs(2))
Dim VirtualDirectory
VirtualDirectory = oArgs(3)
Dim requestHTTP
Set requestHTTP = CreateObject("WinHttp.WinHttpRequest.5.1")
requestHTTP.SetAutoLogonPolicy(0)
requestHTTP.Option(4) = 13056
Dim WebServiceURL, xmlDOC, soapStr, serviceName, serviceUrl, bOK, myError
' Enter a script that outputs a property bag
' Example VBScript:
'
Dim oAPI, oBag
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreateTypedPropertyBag(3)
Dim portInstalled
portInstalled = i_InstalledPort
If useSSL = True Then
WebServiceURL = "https://localhost:" & portInstalled & VirtualDirectory & "TeamFoundation/Administration/v3.0/AdministrationService.asmx"
Else
WebServiceURL = "http://localhost:" & portInstalled & VirtualDirectory & "TeamFoundation/Administration/v3.0/AdministrationService.asmx"
End If
Call TraceLogMessage("RE-CONSTRUCTED URL = ["& WebServiceURL & "]")
soapStr = soapStr & "<?xml version=""1.0"" encoding=""utf-8""?>" & vbCrLf
soapStr = soapStr & "<s:Envelope xmlns:s=""http://schemas.xmlsoap.org/soap/envelope/"">"
soapStr = soapStr & "<s:Body xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:xsd=""http://www.w3.org/2001/XMLSchema"">"
soapStr = soapStr & vbCrLf
soapStr = soapStr & "<QueryActiveRequests xmlns=""http://microsoft.com/webservices/"">"
soapStr = soapStr & vbCrLf
soapStr = soapStr & " <includeDetails>false</includeDetails> "
soapStr = soapStr & vbCrLf
soapStr = soapStr & " </QueryActiveRequests> "
soapStr = soapStr & vbCrLf
soapStr = soapStr & " </s:Body></s:Envelope> "
'Call TraceLogMessage("submitted SOAPSTRING:=>" & soapStr)
'MsgBox soapStr
'Call TraceLogMessage("Set the RequestHTTP object and properties")
requestHTTP.open "POST", WebServiceURL, false
requestHTTP.setrequestheader "Content-Type", "text/xml"
requestHTTP.setrequestheader "SOAPAction", "http://microsoft.com/webservices/QueryActiveRequests"
On Error Resume Next
requestHTTP.Send soapStr
If Err.Number = 0 Then
'''''''DO the XML processing''''''''''''''''''
'========================================================================
' Load the respone.xml into DOM for XPATH processing
'========================================================================
Dim responseText
responseText = requestHTTP.responseText
Call TraceLogMessage("Result of WS Call: " & responseText)
Set xmlDOC = CreateObject("MSXML.DOMDocument")
xmlDOC.SetProperty "SelectionLanguage", "XPath"
xmlDOC.SetProperty "SelectionNamespaces", "xmlns:tns='http://microsoft.com/webservices/'"
xmlDOC.Async = false
bOK = xmlDOC.loadXML(responseText)
If xmlDOC.parseError.errorCode <> 0 Then
myError = xmlDOC.parseError
Call TraceLogMessage("There was a parse error loading XML results")
Call oBag.AddValue("Status","ERROR")
Else
If requestHTTP.status = "200" Then
Dim requestCount
requestCount = xmlDOC.selectNodes("//tns:QueryActiveRequestsResponse/tns:QueryActiveRequestsResult/tns:TeamFoundationServiceHostActivity").Length
If requestCount > ActiveRequestCountLimit Then
Call oBag.AddValue("Status","ERROR")
Call TraceLogMessage("Status: ERROR")
Else
Call oBag.AddValue("Status","OK")
Call TraceLogMessage("Status: OK")
End If
Else
Call oBag.AddValue("Status","ERROR")
Call TraceLogMessage("Status: ERROR")
End If
End If
Else
Call oBag.AddValue("Status","ERROR")
Call TraceLogMessage("Status: ERROR")
End If
Call oAPI.AddItem(oBag)
Call oAPI.Return(oBag)
'########## FUNCTION : TraceLogMessage ############################################
' Since we want to hold this value between Call to the script, initialize it outside the TraceLogMessage function
Dim ScriptFileName, oAPITemp
Function TraceLogMessage(ByVal sMessage)
If logOutputEnabled = true Then
On Error Resume Next
WScript.Echo sMessage
If IsEmpty(ScriptFileName) = True Then
' Retrieve the name of this (running) script
Dim FSO
Set FSO = CreateObject("Scripting.FileSystemObject")
ScriptFileName = FSO.GetFile(WScript.ScriptFullName).Name
Set FSO = Nothing
End If
If IsEmpty(oAPITemp) = True Then
Set oAPITemp = CreateObject("MOM.ScriptAPI")
End If
oAPITemp.LogScriptEvent ScriptFileName, 4002, 4, sMessage
On Error Goto 0
End If
End Function
Public Function ConvStrBool(value)
If UCase(value) = "TRUE" Then
ConvStrBool = True
Else
ConvStrBool = False
End If
End Function
Private i_InstalledPort
</ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
<ErrorExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='Status']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">ERROR</Value>
</ValueExpression>
</SimpleExpression>
</ErrorExpression>
<SuccessExpression>
<SimpleExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='Status']</XPathQuery>
</ValueExpression>
<Operator>Equal</Operator>
<ValueExpression>
<Value Type="String">OK</Value>
</ValueExpression>
</SimpleExpression>
</SuccessExpression>
</Configuration>
</UnitMonitor>