How to get confluence licensed users count from database

Narra Sreenu May 19, 2020

I am new to confluence. I just would like know how to get confluence licensed users count. Currently, our organisation has limit of 10000  users. And in this 4935 signed up users. I mean 4935 used. But when trying get count for licensed users from data base using following query I got only 2932. I am not understanding why both displaying different. Please let me whether I am using correct query or not getting licensed users count for confluence.

 

SELECT count(
(users.lower_user_name))
FROM
cwd_user users
JOIN
cwd_directory userdir
ON
users.directory_id=userdir.id
WHERE
users.lower_user_name IN
(
SELECT DISTINCT
lower(permusername)
FROM
SPACEPERMISSIONS
WHERE
permtype='USECONFLUENCE')
OR users.lower_user_name IN
(
SELECT
u.lower_user_name
FROM
cwd_user u
JOIN
cwd_directory d
ON
u.directory_id = d.id
JOIN
cwd_membership m
ON
u.id = m.child_user_id
JOIN
cwd_group g
ON
g.id = parent_id
JOIN
SPACEPERMISSIONS sp
ON
g.lower_group_name =lower(sp.permgroupname)
WHERE
permtype='USECONFLUENCE' )
AND users.active='T'
AND userdir.active='T'
ORDER BY
1;

2 answers

1 vote
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 19, 2020

Don't bother with the database, it's complex and you're looking at the wrong thing anyway.

Go to Admin -> Global permissions and get the list of groups that have "can use" in there.  The members of those groups are the ones that give you  the 4953 (note, that deduplicates users - if you're in three of the groups for example, you only count once to the 4953)

Narra Sreenu May 19, 2020

Thank you for response. But, I have different situation like I need to read the list of licensed users from data base.  So, I google it and tried with multiple queries but mostly the results are getting below 3000. But, when I verify the count in Confluence Admin page it has 4900+ used licenses.

 

May be you are right, one user can have multiple licenses. because of that count is varying. But, I need total licenses used count using script. I don't have knowledge how to get that.

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 19, 2020

"I need to read from the database" does not explain what you are trying to do.  It is almost certainly the wrong way to do it.

Instead of running off down the path of a probably complex and inaccurate solution, could you explain what you are trying to achieve instead?

Your original question was "I want to get the number of licenced users" and you then said you had 4935.  Assuming that is from the Confluence system information, licence or user list pages, then it is already the answer.  Why are you trying to replicate it using another method?

Narra Sreenu May 19, 2020

I am trying to create a console job to get the count of licensed users and need to notify the admins if count crossed certain limit. For that, I am trying to fetch the signed up users count and verifying count is crossed or not in console. But, my problem is I am unable fetch actual count  that displayed in the admin page. Please let me know if you have other ways to read the count if it is not possible from database.

I am still not understanding why reading from database is not right way.

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
May 19, 2020

The database is not right because you are asking it the wrong question.  Because it's messy and can't tell you the right answer unless you completely understand it.

Best way to do this would be to note what group(s) let you into Confluence (they rarely change once set up) and then get the list of users in those groups over the REST API 

0 votes
Denis Burdukovskiy June 9, 2020

Suggest an answer

Log in or Sign up to answer
TAGS
AUG Leaders

Atlassian Community Events