Query for agent status and response time pollers enabled and disabled

SELECT
     n.Caption
    ,n.IP_Address
    ,n.Engine.ServerName
    ,n.ObjectSubType
    ,n.Uri AS [NodeUri]
    ,p1.PollerType1 AS [EnabledPoller1]
    ,p2.PollerType2 AS [EnabledPoller2]
    ,p3.PollerType3 AS [DisabledPoller3]
    ,p4.PollerType4 AS [DisabledPoller4]
    ,p1.p1Uri AS [EnabledPollerUri1]
    ,p2.p2Uri AS [EnabledPollerUri2]
    ,p3.p3Uri AS [DisabledPollerUri3]
    ,p4.p4Uri AS [DisabledPollerUri4]
FROM Orion.Nodes AS n
LEFT JOIN ( SELECT p.PollerID, p.PollerType AS [PollerType1], p.Enabled, p.NetObjectID, p.NetObjectType, p.Uri AS [p1Uri]
FROM Orion.Pollers AS p ) AS p1 ON n.NodeID = p1.NetObjectID AND p1.NetObjectType = 'N' AND p1.Enabled = 1 AND p1.PollerType1 LIKE 'N.Status.%'
LEFT JOIN ( SELECT p.PollerID, p.PollerType AS [PollerType2], p.Enabled, p.NetObjectID, p.NetObjectType, p.Uri AS [p2Uri]
FROM Orion.Pollers AS p ) AS p2 ON n.NodeID = p2.NetObjectID AND p2.NetObjectType = 'N' AND p2.Enabled = 1 AND p2.PollerType2 LIKE 'N.ResponseTime.%'
LEFT JOIN ( SELECT p.PollerID, p.PollerType AS [PollerType3], p.Enabled, p.NetObjectID, p.NetObjectType, p.Uri AS [p3Uri]
FROM Orion.Pollers AS p ) AS p3 ON n.NodeID = p3.NetObjectID AND p3.NetObjectType = 'N' AND p3.Enabled = 0 AND p3.PollerType3 LIKE 'N.Status.%'
LEFT JOIN ( SELECT p.PollerID, p.PollerType AS [PollerType4], p.Enabled, p.NetObjectID, p.NetObjectType, p.Uri AS [p4Uri]
FROM Orion.Pollers AS p ) AS p4 ON n.NodeID = p4.NetObjectID AND p4.NetObjectType = 'N' AND p4.Enabled = 0 AND p4.PollerType4 LIKE 'N.ResponseTime.%'
WHERE n.ObjectSubType = 'Agent'
AND ( p1.PollerType1 = 'N.Status.Agent.Native' OR p2.PollerType2 = 'N.ResponseTime.Agent.Native' )

Anonymous