Agent Last Event probe

Microsoft.SystemCenter.AgentHealth.LastEvent.ProbeType (ProbeActionModuleType)

This probe collect agent last event

Element properties:

TypeProbeActionModuleType
IsolationAny
AccessibilityInternal
RunAsDefault
InputTypeSystem.BaseData
OutputTypeSystem.OleDbData

Member Modules:

ID Module Type TypeId RunAs 
OLEDB ProbeAction Microsoft.SystemCenter.AgentHealth.OleDBRMS.ProbeType Default

Source Code:

<ProbeActionModuleType ID="Microsoft.SystemCenter.AgentHealth.LastEvent.ProbeType" Accessibility="Internal" Batching="false" PassThrough="false">
<Configuration>
<xsd:element minOccurs="1" name="QueryTimeout" type="xsd:integer"/>
<xsd:element minOccurs="1" name="WatchPeriodHr" type="xsd:integer"/>
<xsd:element minOccurs="1" name="OneRowPerItem" type="xsd:boolean"/>
<xsd:element minOccurs="1" name="MaxEventAgeHr" type="xsd:integer"/>
</Configuration>
<ModuleImplementation Isolation="Any">
<Composite>
<MemberModules>
<ProbeAction ID="OLEDB" TypeID="Microsoft.SystemCenter.AgentHealth.OleDBRMS.ProbeType">
<QueryTimeout>$Config/QueryTimeout$</QueryTimeout>
<Query>
select #T.Path,
CAST(MAX(LastTime) as nvarchar(50)) As 'LastEvent',
CASE
WHEN Isnull(MAX(LastTime),'01-01-80') &lt; DateAdd(hh,-$Config/MaxEventAgeHr$,getutcdate())
Then 'KO'
Else 'OK'
END As 'Status'
From
(
Select CAST(ME.Path as nvarchar(255)) As [Path],
CASE
WHEN IsNull([Path], '')='' THEN ''
WHEN CHARINDEX('.', [Path]) = 0 Then [Path]
ELSE SUBSTRING(Path,1,CHARINDEX('.', Path)-1)
END As 'Netbios'
From dbo.ManagedEntityGenericView ME
Inner join dbo.ManagedTypeView MT
on ME.MonitoringClassId=MT.Id
AND MT.Name = 'Microsoft.SystemCenter.HealthService'
where IsDeleted=0
) As #T
left join
(
select distinct LoggingComputer,
MAX(TimeGenerated) As 'LastTime'
from dbo.EventView
where TimeGenerated &gt; dateadd(hh,-$Config/WatchPeriodHr$,getutcdate())
group by LoggingComputer
) As #E
on #E.LoggingComputer = #T.Path
or #E.LoggingComputer=#T.[Netbios]
group by Path
</Query>
<OneRowPerItem>$Config/OneRowPerItem$</OneRowPerItem>
</ProbeAction>
</MemberModules>
<Composition>
<Node ID="OLEDB"/>
</Composition>
</Composite>
</ModuleImplementation>
<OutputType>System!System.OleDbData</OutputType>
<InputType>System!System.BaseData</InputType>
</ProbeActionModuleType>