I dont know how the Monastry is doing this, but if I had to implement it I would keep a last-activity timestamp in my database for all user sessions, and if a session has seen activity (i.e.: loaded a page from my site) in the last, say, 5 minutes, I would declare this a "currently online visitor".