Version Control Service State Check

TeamFoundationServer2008.VersionControlServiceStateCheck (UnitMonitor)

Check the Status of the Version Control Service

Knowledge Base article:

Resolutions

The Version Control Web Service has indicated it is not in a "running" state. Please check the following. (1) The Version Control Database named "TfsVersionControl" on the Data Tier machine (2) The IIS Application pool for TFS.

Additional

http://msdn.microsoft.com/en-us/library/ms252442.aspx

External

http://msdn.microsoft.com/en-us/library/ms181448.aspx

http://msdn.microsoft.com/en-us/library/ms181455.aspx

Element properties:

TargetTeamFoundationServer2008.TFSVersionControlWebService
Parent MonitorSystem.Health.AvailabilityState
CategoryCustom
EnabledTrue
Alert GenerateTrue
Alert SeverityError
Alert PriorityNormal
Alert Auto ResolveTrue
Monitor TypeMicrosoft.Windows.TimedScript.TwoStateMonitorType
RemotableTrue
AccessibilityInternal
Alert Message
Version Control Service State Check
The Version Control Web Service has indicated it is not in a "running" state. Please check the following. (1) The Version Control Database named "TfsVersionControl" on the Data Tier machine (2) The IIS Application pool for TFS.
RunAsTFSUserProfile

Source Code:

<UnitMonitor ID="TeamFoundationServer2008.VersionControlServiceStateCheck" Accessibility="Internal" Enabled="onEssentialMonitoring" Target="TeamFoundationServer2008.TFSVersionControlWebService" ParentMonitorID="Health!System.Health.AvailabilityState" Remotable="true" Priority="Normal" RunAs="TFSUserProfile" TypeID="Windows!Microsoft.Windows.TimedScript.TwoStateMonitorType" ConfirmDelivery="true">
<Category>Custom</Category>
<AlertSettings AlertMessage="TeamFoundationServer2008.VersionControlServiceStateCheck_AlertMessageResourceID">
<AlertOnState>Error</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Error</AlertSeverity>
</AlertSettings>
<OperationalStates>
<OperationalState ID="UIGeneratedOpStateId7e9289fe28c9425da8696780af22ef7e" MonitorTypeStateID="Success" HealthState="Success"/>
<OperationalState ID="UIGeneratedOpStateId97d648b84df5499bb5d2de113805f3ac" MonitorTypeStateID="Error" HealthState="Error"/>
</OperationalStates>
<Configuration>
<IntervalSeconds>900</IntervalSeconds>
<SyncTime/>
<ScriptName>VersionControlServiceStatus.vbs</ScriptName>
<Arguments/>
<ScriptBody><Script>' Enter a script that outputs a property bag
' Example VBScript:
'
Dim oAPI, oBag
Set oAPI = CreateObject("MOM.ScriptAPI")
Set oBag = oAPI.CreatePropertyBag()


Dim WebServiceURL, WebMethodName, xmlDOC2, soapStr, requestHTTP, serviceName, serviceUrl

WebServiceURL = GetTfsUrl() &amp; "/VersionControl/v1.0/Administration.asmx"
'Call TraceLogMessage("RE-CONSTRUCTED URL = ["&amp; WebServiceURL &amp; "]")


'Call TraceLogMessage("Begin Web Service build up")
'========================================================================
' Set the "environment variables"
'========================================================================
'WebServiceURL = "http://localhost:8080/VersionControl/v1.0/Administration.asmx"

'========================================================================
' Now call the web methods
'========================================================================
WebMethodName = "QueryServerInformation"
'=========================================================================
' main logic of SOAPClient
'=========================================================================
'Get the Properties of the DOM right
Set xmlDOC2 = CreateObject("MSXML.DOMDocument")
xmlDOC2.SetProperty "SelectionLanguage", "XPath"
XmlDOC2.Async = false

'Call TraceLogMessage("Create SOAP Envelope")
' Create the soapEnvelope as a string body

soapStr = soapStr &amp; "&lt;?xml version=""1.0"" encoding=""utf-8""?&gt;" &amp; vbCrLf
soapStr = soapStr &amp; "&lt;soap:Envelope "
soapStr = soapStr &amp; " xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"""
soapStr = soapStr &amp; " xmlns:xsd=""http://www.w3.org/2001/XMLSchema"""
soapStr = soapStr &amp; " xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/""&gt;"
soapStr = soapStr &amp; vbCrLf
soapStr = soapStr &amp; " &lt;soap:Body&gt;" &amp; vbCrLf
soapStr = soapStr &amp; " &lt;QueryServerInformation xmlns=""http://schemas.microsoft.com/TeamFoundation/2005/06/VersionControl/Admin/03"" /&gt; "
soapStr = soapStr &amp; vbCrLf
soapStr = soapStr &amp; " &lt;/soap:Body&gt;" &amp; vbCrLf
soapStr = soapStr &amp; " &lt;/soap:Envelope&gt;" &amp; vbCrLf
'Call TraceLogMessage("submitted SOAPSTRING:=&gt;" &amp; soapStr)

'Call TraceLogMessage("Set the RequestHTTP object and properties")

Set requestHTTP = CreateObject("Microsoft.XMLHTTP")
requestHTTP.open "POST", WebServiceURL, false
requestHTTP.setrequestheader "Content-Type", "text/xml"
requestHTTP.setrequestheader "SOAPAction", "http://schemas.microsoft.com/TeamFoundation/2005/06/VersionControl/Admin/03/QueryServerInformation"
requestHTTP.Send soapStr

'''''''DO the XML processing''''''''''''''''''
'========================================================================
' Load the respone.xml into DOM for XPATH processing
'========================================================================
bOK = xmlDOC2.load(requestHTTP.responseXML)

' get the SOAP response and save it to disk
Dim responseTextResults, recordSet, recordSet9
responseTextResults = requestHTTP.responseText
recordSet = split(responseTextResults, " ")
'Call TraceLogMessage("R9 = " &amp;recordSet(9))
recordSet9 = recordSet(9)

Call oBag.AddValue("Status", recordSet(9))
Call oAPI.Return(oBag)





'''########## BEGIN FUNCTION : TraceLogMessage ############################################
Function TraceLogMessage(ByVal sMessage)
Dim lsEventInformation
WScript.Echo sMessage

' Retrieve the name of this (running) script
Dim FSO, ScriptFileName
Set FSO = CreateObject("Scripting.FileSystemObject")
ScriptFileName = FSO.GetFile(WScript.ScriptFullName).Name
Set FSO = Nothing

On Error Resume Next
Dim oAPITemp
Set oAPITemp = CreateObject("MOM.ScriptAPI")
lsEventInformation = 3
oAPITemp.LogScriptEvent ScriptFileName, 4000, lsEventInformation, sMessage
On Error Goto 0
End Function
'''########## END FUNCTION : TraceLogMessage ############################################

Function GetTfsInstallFolder()
Dim WSHShell, RegKey, sFolder

Set WSHShell = CreateObject("WScript.Shell")
RegKey = "HKLM\SOFTWARE\Microsoft\VisualStudio\9.0\TeamFoundation\ATInstallPath"
sFolder = WSHShell.RegRead(RegKey)

GetTfsInstallFolder = sFolder
End Function

Function GetTfsUrl()
Dim sTfsWebConfigFile, xmlWebConfig, nodeTfsUrl, bConfigFileLoaded

sTfsWebConfigFile= GetTfsInstallFolder() &amp; "Web Services\Web.Config"

Set xmlWebConfig = CreateObject("MSXML.DOMDocument")
xmlWebConfig.SetProperty "SelectionLanguage", "XPath"
xmlWebConfig.Async = false
bConfigFileLoaded = xmlWebConfig.load(sTfsWebConfigFile)
If bConfigFileLoaded = False Then
Exit Function
End If

Set nodeTfsUrl = xmlWebConfig.selectSingleNode("//add[@key = 'TFSNameUrl']/@value")
If nodeTfsUrl Is Nothing Then
Exit Function
End If
GetTfsUrl = nodeTfsUrl.Value
End Function
</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
<ErrorExpression>
<RegExExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='Status']</XPathQuery>
</ValueExpression>
<Operator>DoesNotContainSubstring</Operator>
<Pattern>Running</Pattern>
</RegExExpression>
</ErrorExpression>
<SuccessExpression>
<RegExExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name='Status']</XPathQuery>
</ValueExpression>
<Operator>ContainsSubstring</Operator>
<Pattern>Running</Pattern>
</RegExExpression>
</SuccessExpression>
</Configuration>
</UnitMonitor>