Orchestrator Robot Status by SQL Script

How to check Robot statuses (Available, Busy, Disconnected, Unresponsive) using SQL script?

The below script can be used in order to check Robot status:

 

SELECT

t.[Name] as 'tenantName'

,r.[Name] as 'robotName'

,m.[Name] as 'machineName'

,CASE qd.[State] WHEN 0 THEN 'Available' WHEN 1 THEN 'Busy' WHEN 2 THEN 'Disconnected' END as 'Unresponsive'

FROM [dbo].Sessions as qd LEFT JOIN [dbo].[Tenants] as t ON t.[Id] = qd.[TenantId]

LEFT JOIN [dbo].[Robots] as r ON r.[Id] = qd.[RobotId]

LEFT JOIN [dbo].[Machines] as m ON m.[Id] = r.[MachineId]

where qd.IsDeleted=0