Monitor for Build WebService
Monitor for Build WebService
Target | TeamFoundationServer2008.TFSBuildWebService | ||
Parent Monitor | System.Health.AvailabilityState | ||
Category | AvailabilityHealth | ||
Enabled | True | ||
Alert Generate | True | ||
Alert Severity | Error | ||
Alert Priority | Normal | ||
Alert Auto Resolve | True | ||
Monitor Type | Microsoft.Windows.TimedScript.TwoStateMonitorType | ||
Remotable | True | ||
Accessibility | Internal | ||
Alert Message |
| ||
RunAs | TFSUserProfile |
<UnitMonitor ID="TeamFoundationServer2008.MonitorforBuildWebService" Accessibility="Internal" Enabled="onEssentialMonitoring" Target="TeamFoundationServer2008.TFSBuildWebService" ParentMonitorID="Health!System.Health.AvailabilityState" Remotable="true" Priority="Normal" RunAs="TFSUserProfile" TypeID="Windows!Microsoft.Windows.TimedScript.TwoStateMonitorType" ConfirmDelivery="false">
<Category>AvailabilityHealth</Category>
<AlertSettings AlertMessage="TeamFoundationServer2008.MonitorforBuildWebService_AlertMessageResourceID">
<AlertOnState>Warning</AlertOnState>
<AutoResolve>true</AutoResolve>
<AlertPriority>Normal</AlertPriority>
<AlertSeverity>Error</AlertSeverity>
</AlertSettings>
<OperationalStates>
<OperationalState ID="Success" MonitorTypeStateID="Success" HealthState="Success"/>
<OperationalState ID="Error" MonitorTypeStateID="Error" HealthState="Warning"/>
</OperationalStates>
<Configuration>
<IntervalSeconds>900</IntervalSeconds>
<SyncTime/>
<ScriptName>BuildService.vbs</ScriptName>
<Arguments/>
<ScriptBody> '
Dim oAPI, oBag
Dim WebServiceURL, WebMethodName, xmlDOC2, soapStr, requestHTTP, serviceName, serviceUrl
WebServiceURL = GetTfsUrl() & "/Build/V1.0/BuildStore.asmx"
Call TraceLogMessage("RE-CONSTRUCTED URL = ["& WebServiceURL & "]")
'========================================================================
' Now call the web methods
'========================================================================
' 1. Test the GetRegistrationEntries method
WebMethodName = "GetBuildQualities"
'=========================================================================
' main logic of SOAPClient
'=========================================================================
'Get the Properties of the DOM right
Set xmlDOC2 = CreateObject("MSXML.DOMDocument")
xmlDOC2.SetProperty "SelectionLanguage", "XPath"
XmlDOC2.Async = false
' Do a simple polling check on GetBuildQualities Web Service and check its return status.
'Call TraceLogMessage("Create SOAP Envelope")
' Create the soapEnvelope as a string body
soapStr = soapStr & "<?xml version=""1.0"" encoding=""utf-8""?>" & vbCrLf
soapStr = soapStr & "<soap:Envelope "
soapStr = soapStr & " xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"""
soapStr = soapStr & " xmlns:xsd=""http://www.w3.org/2001/XMLSchema"""
soapStr = soapStr & " xmlns:soap=""http://schemas.xmlsoap.org/soap/envelope/"">"
soapStr = soapStr & vbCrLf
soapStr = soapStr & " <soap:Body>" & vbCrLf
soapStr = soapStr & " <GetBuildQualities xmlns=""http://schemas.microsoft.com/TeamFoundation/2005/06/Build/BuildInfo/03""/> "
soapStr = soapStr & vbCrLf
soapStr = soapStr & " </soap:Body>" & vbCrLf
soapStr = soapStr & " </soap:Envelope>" & vbCrLf
'Call TraceLogMessage("submitted SOAPSTRING:=>" & 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/Build/BuildInfo/03/GetBuildQualities"
requestHTTP.Send soapStr
'''''''DO the XML processing''''''''''''''''''
'========================================================================
' Load the respone.xml into DOM for XPATH processing
'========================================================================
bOK = xmlDOC2.load(requestHTTP.responseXML)
Set oAPI = CreateObject("MOM.ScriptAPI")
'Set oBag = oAPI.CreatePropertyBag()
Set oBag = oAPI.CreateTypedPropertyBag(3)
IF xmlDOC2.parseError.errorCode <> 0 Then
myError = xmlDOC2.parseError
Call TraceLogMessage("You have parse error on loading XmlDOC2" )
Call oBag.AddValue("Status","ERROR")
ELSE
IF requestHTTP.status = "200" THEN
Call oBag.AddValue("Status","OK")
'Call TraceLogMessage("Status: OK")
ELSE
Call oBag.AddValue("Status","ERROR")
'Call TraceLogMessage("Status: ERROR")
END IF
Call oAPI.AddItem(oBag)
Call oAPI.Return(oBag)
END IF
'''########## 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() & "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
</ScriptBody>
<TimeoutSeconds>360</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>