Exchange 2003 Mailflow Discovery

Microsoft.Exchange.SyntheticTransaction.Mailflow.Discovery (Discovery)

This rule discovers the Exchange 2003 Mailflow Monitoring Component

Knowledge Base article:

Summary

This discovery rule discovers the Exchange 2003 Mailflow monitoring component on an Exchange Backend server.

Configuration

There is no configuration required. To disable local Exchange 2003 Server role discovery disable (override) the rule “Exchange 2003 Server Initial Discovery”.

EAS Logon monitor via synthetic transactions requires configuration performed by the “Exchange Management Pack Configuration Wizard”.

Element properties:

TargetMicrosoft.Exchange.ServerRole.2003
EnabledTrue
Frequency3600
RemotableFalse

Object Discovery Details:

Discovered Classes and their attribuets:

Member Modules:

ID Module Type TypeId RunAs 
DiscoveryDataSource DataSource System.CommandExecuterDiscoveryDataSource Default

Source Code:

<Discovery ID="Microsoft.Exchange.SyntheticTransaction.Mailflow.Discovery" Enabled="onStandardMonitoring" Target="Microsoft.Exchange.ServerRole.2003" ConfirmDelivery="false" Remotable="true" Priority="Normal">
<Category>Discovery</Category>
<DiscoveryTypes>
<DiscoveryClass TypeID="Microsoft.Exchange.SyntheticTransaction.Mailflow"/>
</DiscoveryTypes>
<DataSource ID="DiscoveryDataSource" TypeID="System!System.CommandExecuterDiscoveryDataSource">
<IntervalSeconds>3600</IntervalSeconds>
<ApplicationName>%windir%\System32\cscript.exe</ApplicationName>
<WorkingDirectory/>
<CommandLine>$file/DiscoverMicrosoftExchangeSyntheticTransactionMailflow.js$ 0 $MPElement$ $Target/Id$ $Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/PrincipalName$ $Target/Property[Type="Microsoft.Exchange.ServerRole.2003"]/DistinguishedName$ $Target/Host/Property[Type="Windows!Microsoft.Windows.Computer"]/NetbiosComputerName$</CommandLine>
<TimeoutSeconds>300</TimeoutSeconds>
<RequireOutput>true</RequireOutput>
<Files>
<File>
<Name>DiscoverMicrosoftExchangeSyntheticTransactionMailflow.js</Name>
<Contents><Script>
//Copyright (c) Microsoft Corporation. All rights reserved.
//*************************************************************
// $ScriptName: "Exchange - Mailflow Discovery" $
//
// TBD: This assumes that there are no Public Folders and/or Mailboxes on a frontend server.
// However this is not a must requirement, just a recommendation.
// For now we assume that a Frontend server does not have databases
//
// $File: DiscoverMicrosoftExchangeSyntheticTransactionMailflow.js $
//
//*************************************************************

// Define Constants

var REGKEY_NOT_EXIST = -2147024894;

var NO_REGKEY_SENTINEL = "...";

var SourceType, SourceID, ManagedEntityId, TargetComputer,DistinguishedName,NetBiosComputerName;

if(WScript.Arguments.Unnamed.Count == 6){
SourceType = WScript.Arguments(0);
SourceID = WScript.Arguments(1) ;
ManagedEntityId = WScript.Arguments(2);
TargetComputer = WScript.Arguments(3);
DistinguishedName = WScript.Arguments(4);
NetBiosComputerName=WScript.Arguments(5);
}else{
WScript.quit();
}

var oAPI;
oAPI = new ActiveXObject("Mom.ScriptAPI");

var MAILFLOW_BASE_REG_KEY = "HKEY_LOCAL_MACHINE\\SOFTWARE\\Microsoft\\Exchange MOM\\Mail Flow\\";
var SEND_TO_MBX_REG_PATH = MAILFLOW_BASE_REG_KEY + NetBiosComputerName + "\\SendToMailbox";
var SEND_TO_SRV_REG_PATH = MAILFLOW_BASE_REG_KEY + NetBiosComputerName + "\\SendTo";
var EXPECTED_FROM_REG_PATH = MAILFLOW_BASE_REG_KEY + NetBiosComputerName + "\\ExpectedFrom";


function CreateEvent(strSource, lngEventID, lngEventType, strMsg)
{
oAPI.LogScriptEvent(strSource, lngEventID, lngEventType, strMsg);
}

// Checks if this server is configured to perform any mail flow verification
function IsMailFlowMonitoringEnabled()
{
var blnResult = false;

if ( (IsConfigRegEntryPresent(SEND_TO_MBX_REG_PATH)) ||
(IsConfigRegEntryPresent(SEND_TO_SRV_REG_PATH)) ||
(IsConfigRegEntryPresent(EXPECTED_FROM_REG_PATH)))
{
blnResult = true;
}

return blnResult;
}

// Checks if the string containg an entry value represents an attempt to configure mail flow. This function
// does not validate the entry it only checks if it is not empty.
function IsConfigRegEntryPresent(strConfigEntryRegPath)
{
var blnResult = false;
var strConfigEntryValue = GetRegEntry(strConfigEntryRegPath);

if (strConfigEntryValue!= null)
{
// Trim the string
strConfigEntryValue = strConfigEntryValue.replace(/(^\s+)|(\s+$)/g, "");
if ((strConfigEntryValue.length &gt; 0) &amp;&amp; (strConfigEntryValue != NO_REGKEY_SENTINEL))
blnResult = true;
}

return blnResult;
}


function GetRegEntry(strRegEntry)
{
var strEntryValue = "";
var objShell = new ActiveXObject("WScript.Shell");
var strEntryValue = NO_REGKEY_SENTINEL;
var ERROR_FILE_NOT_FOUND = -2147024894; //ERROR_FILE_NOT_FOUND = 0x00000002

try {
strEntryValue = objShell.RegRead(strRegEntry);
} catch(err) {
if (err.number != ERROR_FILE_NOT_FOUND)
throw err;
strEntryValue = NO_REGKEY_SENTINEL;
}
// Deals with the case when the value was created but not touched, in this case RegRead will return the registry entry
if (typeof(strEntryValue) == "string")
if (strRegEntry.toLowerCase() == strEntryValue.toLowerCase())
strEntryValue = NO_REGKEY_SENTINEL;

return (strEntryValue);
}

MainRoutine:
{
var discoveryData;
discoveryData = oAPI.CreateDiscoveryData(SourceType, SourceID, ManagedEntityId);

bMailFlowEnabled = IsMailFlowMonitoringEnabled();
if(bMailFlowEnabled==true){
var oExchangeMailFlowInstance;
// Create Server (Exchange &amp; Exchange Frontend) collection with the
// Computer (full netbios name: domain\servername) as scope
oExchangeMailFlowInstance=discoveryData.CreateClassInstance("$MPElement[Name='Microsoft.Exchange.SyntheticTransaction.Mailflow']$");
oExchangeMailFlowInstance.AddProperty("$MPElement[Name='Windows!Microsoft.Windows.Computer']/PrincipalName$", TargetComputer);
oExchangeMailFlowInstance.AddProperty("$MPElement[Name='Microsoft.Exchange.ServerRole.2003']/DistinguishedName$", DistinguishedName);
oExchangeMailFlowInstance.AddProperty("$MPElement[Name='System!System.Entity']/DisplayName$", "Mail Flow");
// Add it to the discovery data
discoveryData.AddInstance(oExchangeMailFlowInstance);
}
// Pass back the result to MOM
oAPI.Return(discoveryData);
}//MainRoutine
</Script></Contents>
</File>
</Files>
</DataSource>
</Discovery>