Skip to content

Commit e1824e1

Browse files
authored
Update Query 🐦
1 parent e4cc0ae commit e1824e1

1 file changed

Lines changed: 12 additions & 9 deletions

File tree

SQL Queries/OperationsManager/HealthService_Inventory.sql

Lines changed: 12 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,15 @@
11
SELECT
22
Q2.IsAvailable,
3-
Q2.State AS 'HealthState',
3+
CASE Q2.HealthState
4+
WHEN 0 THEN 'Uninitialized'
5+
WHEN 1 THEN 'Healthy'
6+
WHEN 2 THEN 'Warning'
7+
WHEN 3 THEN 'Critical'
8+
WHEN 4 THEN 'Unmonitored'
9+
WHEN 255 THEN 'Not Applicable'
10+
ELSE 'Unknown State'
11+
END AS HealthStateDescription,
412
Q2.ServerName,
5-
Q1.PrimaryManagementServer,
6-
Q1.OSVersion,
7-
Q1.OSBuildNumber,
813
-- Select specific columns from HS. Replace '*' with actual column names if needed.
914
Q1.*
1015
FROM
@@ -31,16 +36,14 @@ LEFT JOIN
3136
SELECT
3237
v1.path as [ServerName],
3338
replace(replace(v1.isavailable,0,'False'),1,'True') as [IsAvailable],
34-
State.displayname as [State]
39+
v1.HealthState
3540
FROM
3641
ManagedEntityGenericView v1
3742
INNER JOIN
3843
ManagedTypeView mv ON v1.MonitoringClassId = mv.Id
39-
LEFT JOIN
40-
DisplayStringView State ON ('OperationalDataTypes.StateType.HealthState.' + CAST(v1.HealthState AS NVARCHAR)) = State.ElementName
4144
WHERE
42-
mv.Name = 'microsoft.systemCenter.agent'
43-
AND State.LanguageCode = 'ENU'
45+
mv.Name = 'microsoft.systemCenter.agent' OR
46+
mv.Name = 'Microsoft.SystemCenter.GatewayManagementServer'
4447
) AS Q2
4548
ON
4649
Q1.DisplayName = Q2.ServerName

0 commit comments

Comments
 (0)