Last active
April 30, 2019 05:55
-
-
Save timdenholm/c115c241f243ca90c97f5c471503fd34 to your computer and use it in GitHub Desktop.
Get SCOM Agents
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
USE OperationsManager | |
GO | |
SELECT | |
CASE | |
WHEN LOWER(ManagedEntityGenericView.DisplayName) LIKE LOWER('%.%') | |
THEN REPLACE(SUBSTRING(ManagedEntityGenericView.DisplayName,1,CHARINDEX('.',ManagedEntityGenericView.DisplayName)),'.','') | |
ELSE ManagedEntityGenericView.DisplayName | |
END AS host, | |
CASE | |
WHEN InMaintenanceMode = 1 THEN 'Yes' | |
WHEN InMaintenanceMode = 0 THEN 'No' | |
ELSE CONVERT(VARCHAR(2), InMaintenanceMode) | |
END AS scom_agent_maintenance, | |
CASE | |
WHEN IsAvailable = 1 THEN 'Yes' | |
WHEN IsAvailable = 0 THEN 'No' | |
ELSE CONVERT(VARCHAR(2), IsAvailable) | |
END AS scom_agent_active, | |
hs.Version AS scom_agent_Version, | |
hs.PatchList AS scom_agent_patch_list | |
FROM ManagedEntityGenericView | |
INNER JOIN ManagedTypeView ON ManagedEntityGenericView.MonitoringClassId = ManagedTypeView.Id | |
INNER JOIN ( | |
SELECT | |
BaseManagedEntityId, | |
PatchList, | |
Version | |
FROM MT_HealthService | |
) hs ON ManagedEntityGenericView.BaseManagedEntityId = hs.BaseManagedEntityId | |
WHERE (ManagedTypeView.Name = 'Microsoft.SystemCenter.Agent') | |
ORDER BY host |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment