Index Agent Filtered Log File Provider

ComTrade.EMC.Documentum.xPloreIndexServer.Windows.DS.IndexAgent.Logfile.Provider (DataSourceModuleType)

Gets filtered data from Index Agent log file

Element properties:

TypeDataSourceModuleType
IsolationAny
AccessibilityPublic
RunAsComTrade.EMC.Documentum.Library.DocumentumActionAccount
OutputTypeSystem.Event.Data

Member Modules:

ID Module Type TypeId RunAs 
logProvider DataSource System.ApplicationLog.GenericLogReader Default
createPropertyBag ProbeAction Microsoft.Windows.ScriptPropertyBagProbe Default
filterData ConditionDetection System.ExpressionFilter Default
filterEmpty ConditionDetection System.LogicalSet.ExpressionFilter Default
mapData ConditionDetection System.Event.GenericDataMapper Default

Source Code:

<DataSourceModuleType ID="ComTrade.EMC.Documentum.xPloreIndexServer.Windows.DS.IndexAgent.Logfile.Provider" Accessibility="Public" RunAs="CTDmLib!ComTrade.EMC.Documentum.Library.DocumentumActionAccount" Batching="false">
<Configuration>
<IncludeSchemaTypes>
<SchemaType>System!System.ExpressionEvaluatorSchema</SchemaType>
</IncludeSchemaTypes>
<xsd:element minOccurs="1" name="LogfilePath" type="xsd:string"/>
<xsd:element minOccurs="1" name="LogfilePattern" type="xsd:string"/>
<xsd:element minOccurs="1" name="LogIsUTF8" type="xsd:boolean"/>
<xsd:element minOccurs="1" name="Expression" type="ExpressionType"/>
</Configuration>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<DataSource ID="logProvider" TypeID="ApplicationLog!System.ApplicationLog.GenericLogReader">
<LogFileDirectory>$Config/LogfilePath$</LogFileDirectory>
<LogFilePattern>$Config/LogfilePattern$</LogFilePattern>
<LogIsUTF8>$Config/LogIsUTF8$</LogIsUTF8>
</DataSource>
<ProbeAction ID="createPropertyBag" TypeID="Windows!Microsoft.Windows.ScriptPropertyBagProbe">
<ScriptName>CTDmMPIALogDataToPropertyBagPerfProv.js</ScriptName>
<Arguments>$Data/Params/Param[1]$</Arguments>
<ScriptBody><Script>
function extractMultiLineString(f) {
return f.toString().
replace(/^[^\/]+\/\*!?/, '').
replace(/\*\/[^\/]+$/, '').
replace(/\*\\\//g, '*/');
};
var trim = function (str) {
return str.replace(/^\s+|\s+$/g,"");
};
var inData = "";
var n = 0;
for (n = 0; n &lt; WScript.Arguments.length; n++) {
inData += WScript.Arguments(n) + ' ';
}
CTLogger = function (oApi) {
var M_LOGLEVELINFO = 0;
var M_LOGLEVELWARNING = 2;
var M_LOGLEVELERROR = 1;
var m_oMomApi = oApi;
var m_nLogLevel = M_LOGLEVELERROR;
this.LoggingLevel = function(lValue) {
m_nLogLevel = lValue;
};
this.MomAPI = function(lValue) {
m_oMomApi = lValue;
};
this.LOGLEVELINFO = function() {
return M_LOGLEVELINFO;
};
this.LOGLEVELWARNING = function(){
return M_LOGLEVELWARNING;
};
this.LOGLEVELERROR = function() {
return M_LOGLEVELERROR;
};
var WriteStdErr = function (sMessage, nEventId, nSeverity) {
try {
var sMsg = "";
switch (nSeverity)
{
case 0 :
sMsg = "[" + WScript.ScriptName + " - Info]: EventId: " + nEventId + " Message: " + sMessage;
break;
case 1 :
sMsg = "[" + WScript.ScriptName + " - Error]: EventId: " + nEventId + " Message: " + sMessage;
break;
case 2 :
sMsg = "[" + WScript.ScriptName + " - Warning]: EventId: " + nEventId + " Message: " + sMessage;
break;
}
WScript.StdErr.WriteLine(sMsg);
}
catch (e){
}
};
var WriteStdOut = function (sMessage, nEventId, nSeverity) {
try {
var sMsg = "";
switch (nSeverity) {
case 0 :
sMsg = "[" + WScript.ScriptName + " - Info]: EventId: " + nEventId + " Message: " + sMessage;
break;
case 1 :
sMsg = "[" + WScript.ScriptName + " - Error]: EventId: " + nEventId + " Message: " + sMessage;
break;
case 2 :
sMsg = "[" + WScript.ScriptName + " - Warning]: EventId: " + nEventId + " Message: " + sMessage;
break;
}
WScript.StdOut.WriteLine(sMsg);
}
catch (e) {
}
};
var WriteEventLog = function (sMessage, nEventId, nSeverity) {
m_oMomApi.LogScriptEvent(WScript.ScriptName, nEventId, nSeverity, sMessage);
};
var IsNumeric = function (dt) {
var RE = /^-{0,1}\d*\.{0,1}\d+$/;
return (RE.test(dt));
};
var WriteLog = function (sMessage, nEventId, nSeverity) {
try {
if (IsNumeric(nSeverity) &amp;&amp; IsNumeric(nEventId)) {
if ( ! m_oMomApi) {
switch (m_nLogLevel) {
case 0 :
if (nSeverity == 1) {
WriteStdErr(sMessage, nEventId, nSeverity);
}
else {
WriteStdErr(sMessage, nEventId, nSeverity);
}
break;
case 1 :
if (nSeverity == 1) {
WriteStdErr(sMessage, nEventId, nSeverity);
}
break;
case 2 :
if (nSeverity == 1) {
WriteStdErr(sMessage, nEventId, nSeverity);
}
else if ( nSeverity == 2) {
WriteStdErr(sMessage, nEventId, nSeverity);
}
break;
}
}
else {
switch (m_nLogLevel) {
case 0 :
WriteEventLog(sMessage, nEventId, nSeverity);
break;
case 1 :
if (nSeverity == 1) {
WriteEventLog(sMessage, nEventId, nSeverity);
}
break;
case 2 :
if (nSeverity &gt; 0) {
WriteEventLog(sMessage, nEventId, nSeverity);
}
break;
}
}
}
}
catch (e) {
}
};
this.WriteError = function (sMessage, nEventId) {
WriteLog (sMessage, nEventId, M_LOGLEVELERROR);
};
this.WriteWarning = function (sMessage, nEventId) {
WriteLog (sMessage, nEventId, M_LOGLEVELWARNING);
};
this.WriteInfo = function(sMessage, nEventId) {
WriteLog (sMessage, nEventId, M_LOGLEVELINFO);
};
};
var trim = function (str) {
return str.replace(/^\s+|\s+$/g,"");
};
var oAPI = new ActiveXObject("MOM.ScriptAPI");
var oLogger = new CTLogger(oAPI);
var ctEventNo = 17350;
inData = trim(inData);
//WScript.Echo(inData);
// process data.
//2012-04-07 15:16:10,130 ERROR ConnectorThread [Connector Docbase_Normal_Mode_Connector:#0][DM_INDEX_AGENT_UNEXPECTED_CONNECTOR_EXCEPTION] Unexpected excpetion in the 'Docbase_Normal_Mode_Connector' connector.
var re = new RegExp("(.*,\\d+)\\s+(\\w+)\\s+(.*)\\[(.*)\\]\\s*\\[(.*)\\]\\s+(.*)", "mg");
/*\1: 2012-04-07 15:16:10,130
\2: ERROR
\3: ConnectorThread
\4: Connector Docbase_Normal_Mode_Connector:#0
\5: DM_INDEX_AGENT_UNEXPECTED_CONNECTOR_EXCEPTION
\6: Unexpected excpetion in the 'Docbase_Normal_Mode_Connector' connector.*/
var lns = inData.split("\r\n");
var found = false;
if (lns &amp;&amp; lns != undefined) {
var k = 0;
for (k = 0; k &lt; lns.length; ++k)
{
var oBag = oAPI.CreatePropertyBag();
var oMatches = re.exec(lns[k]);
if (oMatches) {
oBag.AddValue("InputData", lns[k]);
oBag.AddValue("TimeStamp", oMatches[1]);
oBag.AddValue("MessageType", oMatches[2].toLowerCase());
oBag.AddValue("Application", oMatches[3] + " - " + oMatches[4]);
oBag.AddValue("MessageCode", oMatches[5]);
oBag.AddValue("MessageText", oMatches[6]);
oAPI.AddItem(oBag);
oBag = null;
found = true;
}
}
}
if (found) {
oAPI.ReturnItems();
} else {
var oBg = oAPI.CreatePropertyBag();
oAPI.Return(oBg);
oBg = null;
}
oAPI = null;
</Script></ScriptBody>
<TimeoutSeconds>300</TimeoutSeconds>
</ProbeAction>
<ConditionDetection ID="filterData" TypeID="System!System.ExpressionFilter">
<Expression>$Config/Expression$</Expression>
</ConditionDetection>
<ConditionDetection ID="mapData" TypeID="System!System.Event.GenericDataMapper">
<EventOriginId>$Target/Id$</EventOriginId>
<PublisherId>$MPElement$</PublisherId>
<PublisherName>IndexAgentGenericLog</PublisherName>
<Channel>$Data/Property[@Name="Application"]$</Channel>
<LoggingComputer/>
<EventNumber>0</EventNumber>
<EventCategory>3</EventCategory>
<EventLevel>0</EventLevel>
<UserName/>
<Description>$Data/Property[@Name="MessageText"]$</Description>
<Params>
<Param>$Data/Property[@Name="InputData"]$</Param>
<Param>$Data/Property[@Name="TimeStamp"]$</Param>
<Param>$Data/Property[@Name="Application"]$</Param>
<Param>$Data/Property[@Name="MessageType"]$</Param>
<Param>$Data/Property[@Name="MessageCode"]$</Param>
<Param>$Data/Property[@Name="MessageText"]$</Param>
</Params>
</ConditionDetection>
<ConditionDetection ID="filterEmpty" TypeID="System!System.LogicalSet.ExpressionFilter">
<Expression>
<RegExExpression>
<ValueExpression>
<XPathQuery Type="String">Property[@Name="Application"]</XPathQuery>
</ValueExpression>
<Operator>MatchesRegularExpression</Operator>
<Pattern>.+</Pattern>
</RegExExpression>
</Expression>
<EmptySet>Block</EmptySet>
<SetEvaluation>Any</SetEvaluation>
</ConditionDetection>
</MemberModules>
<Composition>
<Node ID="mapData">
<Node ID="filterEmpty">
<Node ID="createPropertyBag">
<Node ID="filterData">
<Node ID="logProvider"/>
</Node>
</Node>
</Node>
</Node>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.Event.Data</OutputType>
</DataSourceModuleType>