How to report currently active users?

Before taking down an application for upgrade or maintenance we like to check which (if any) users are currently active (ie: have explicitly accessed a page).

Is there some way to report this (ideally with an SQL query), other than grepping the access log using something like:

fgrep -v -e '"GET /rest/' localhost_access_log.2012-12-06.txt | tail

2 answers

1 accepted

We use a macro based on Andrew Frayling's work:

https://answers.atlassian.com/questions/33385/macro-that-produces-a-list-of-users-last-login-date

You can tweak it to get users who have accessed pages within the last few minutes, for example.

Another thing we do is use Google Analytics, and check the real-time stats. That will tell you how many users are currently using the site (within the last 1 minute, I think), and what pages they are on.

hth,

matt

Many thanks Matthew, I'll try that when I get some time.

For now, since Atlassian confirm they have nothing (https://support.atlassian.com/browse/CSP-92874) I'm using a slightly more elaborate access log report:

awk '
/ "GET \/rest/ { next }	# Ignore Ajax fetches
{
   userName = $3                    # $1: IP, $2: Hyphen usually
   TS = $4                          # In form [dd/Mmm/yyyy:hh:mm:ss    $5: +0000] $6: $GET $7: /url/...
   USERS[userName] = substr(TS, 2)  # Array key is name, value is timestamp
}
END {
   for (userName in USERS)
      print USERS[userName], userName
}
' `ls -t localhost_access_log.*.txt | sed -n 1,2p` | sort # Check last 2 days' logs

Sorry - `back-quoted` command on last line above should have "| tac" at end. ie:

' `ls -t localhost_access_log.*.txt | sed -n 1,2p | tac` | sort

Hi Peter,

This SQL query should be enough to retrieve all users that belong in a group which has global permissions:

SELECT DISTINCT u.lower_user_name
FROM cwd_user u
JOIN cwd_membership m ON u.id = child_user_id
JOIN cwd_group g ON m.parent_id = g.id
JOIN spacepermissions sp ON g.group_name = sp.permgroupname
WHERE permtype='USECONFLUENCE' AND u.active = 'T';

Hope it helps!

Thanks Alyson - that's handy, but I want currently active users. eg: to see if I need to postpone down time and/or contact them when about to take Confluence down.

Suggest an answer

Log in or Sign up to answer
How to earn badges on the Atlassian Community

How to earn badges on the Atlassian Community

Badges are a great way to show off community activity, whether you’re a newbie or a Champion.

Learn more
Community showcase
Posted Jul 10, 2018 in Confluence

We want to see the templates you've created in Confluence!

Hi Community, Jessica here from the Confluence Product Marketing team!  July’s community challenge is all about sharing pictures  — and as an extension of our first post on what ...

1,020 views 23 13
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you