SQL query for agent status -> online, offline, stale

Hi,

Is there an sql query to get agent status like online, offline, and stale? Similar to what you get when you go to Agent Management platform and can see what assets are online, offline, or stale. Thank you.