You want the Agent State Detail table. Make a join based on two tables, one table which is the login, and one table which is the logout. Join the two based on agentID and any other conditions you require.
Example of login table:
SELECT agentID, eventDateTime AS loginTime, eventType
FROM dbo.AgentStateDetail AS ASD1
JOIN dbo.Resource AS r ON ASD1.agentID = r.resourceID
WHERE eventType = 2 AND r.dateInactive >= @startDateTime
Example of logout table:
SELECT agentID, eventDateTime AS logoutTime, eventType
FROM dbo.AgentStateDetail AS ASD2
JOIN dbo.Resource AS r ON ASD2.agentID = r.resourceID
WHERE eventType = 3 AND r.dateInactive >= @startDateTime
Join the two, do a date diff and you'll have the duration between the two states. In this example, ready/notready times. Change eventType to suit your needs.
These are the paths to get to each CCX logs through CLI. They may be helpful if you are having issues accessing RTMT or downloading logs through it.
If you want to download them you have to prefix "file get " and you can add one of the options (re...