BizTalk Health Monitor is a valuable tool to validate the current state of a BizTalk Server Environment. I encourage you to use recurrently review warnings and act on the issues. We use it extensively when doing BizTalk Health Checks and working with support cases. A useful feature is the possibility to add custom queries and rules.
If you want to read more about basic functions of BHM visit the BizTalk Health Monitor Team blog
My sample: ExtBHM-CustomExamples
Adding a Custom Query
BHM Queries collect information to which you can apply rules. If you have some information about your solution that you want to include as part of the health review. Custom queries can be of different types, the possibilities are a bit different, the table below enumerates the types and shows how information is presented. The option I used most is PowerShell, generally I create a script that I can create, and test manually and then just add the full path to the script and send parameters.
|WMI||WQL Select Statement, all properties included on the select will be accessible for rules and display. About WQL
SELECT AdapterName, HostName, IsDefault FROM MSBTS_SendHandler2 Where ( HostName = ‘TrackingHost’ )
|SQL||SQL Select Statement, all columns included in the Select statement will be accessible for rules and display. Do not query the BizTalk databases. Changes to the BizTalk databases is not advisable and not supported.
SELECT @@SERVERNAME AS ServerName, name, recovery_model_desc FROM sys.databases
Where database_id > 4
|VBS||VB Script, each line printed to the console will be collected but no additional columns. Validate the line text or row count.
Set g_objShell = createobject(“Wscript.shell”)
MaxDTCLogSize = g_objShell.RegRead (“HKEY_LOCAL_MACHINE\SOFTWARE\MICROSOFT\MSDTC\MaxLogSize”)Wscript.Echo MaxDTCLogSize
|PowerShell||PowerShell Script each line printed to the console will be collected but no additional columns. Validate the line text or row count.
$QueryString = Gwmi Win32_OperatingSystem -Comp MyComputer
|BAT||A batch of commands each line printed to the console will be collected but no additional columns. Validate the line text or row count.
ECHO LISTENING && netstat -ano | find /c “LISTENING”
ECHO SYN_SENT && netstat -ano | find /c “SYN_SENT”
ECHO SYN_RCVD && netstat -ano | find /c “SYN_RCVD”
ECHO ESTABLISHED && netstat -ano | find /c “ESTABLISHED”
ECHO FIN_WAIT_1 && netstat -ano | find /c “FIN_WAIT_1”
ECHO CLOSING && netstat -ano | find /c “CLOSING”
ECHO FIN_WAIT_2 && netstat -ano | find /c “FIN_WAIT_2”
ECHO TIME_WAIT && netstat -ano | find /c “TIME_WAIT”
|CMD||Output from one command each line printed to the console will be collected but no additional columns. Validate the line text or row count.
- Navigate to the profile you want to customize, tab Queries
- Click on New Query after selecting the type you want to use
- Add the Query commands
- Set properties like Caption and target
- Test and select Ok when done
Each query has a target which is the name of the server where to run the query. There are some macros to address the query to multiple servers in an environment. You can use ALLBTSVR to run a query on every BizTalk Server by setting the TargetID element in the configuration file.
Note: I have only made it work with PowerShell queries.
Adding a Custom Rule
A rule acts on the data collected with a query. Rules can be set to give a warning on each failing instance or once for all errors. You can have more than one condition for a rule. In a condition you can validate a column value (%GLOBALPROP_REPORTVALUE:##COLNAME##%) or the number or rows generated by the query(%GLOBALPROP_ROWCOUNT%). Actions give you the possibility to act when conditions are met. Actions can use data from the failing rows and have URLs to documentation, i.e. to a wiki with information on what to do.
- Navigate to the profile you want to customize, tab Rules
- Write a name and add description comments. Set evaluation rows and trigger actions.
- Select Commit changes
- Select and edit the default condition
- Select Commit changes
- Add more conditions if needed
- Edit the default action to match your requirements
- Select Commit changes
- Test and Save
Activating the rules
Now that we have rules we need to activate them by going to the Information Level tab and select the custom queries we want to have in the profile.
Moving the profile to another environment
The profile configuration files are stored under %ProgramData%\Microsoft\BizTalkHealthMonitor as xml files with a name starting with MBVSETTINGS_. Simply edit the file to match the names on the new environment and save it in the new location.