- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2017 03:51 PM
How to get the number of users logged in on each node through script? I know these stats are available in System Diagnostics page, but is there a way to pull that data to a script?
Thanks
Divya Yamani
Solved! Go to Solution.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2017 04:09 PM
Hello Divya,
Thanks for the update. The below blog has detailed info on what you are looking for.
https://servicenowgems.com/2016/04/28/finding-logged-in-users/

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2017 03:54 PM
Hello Divya,
Try with below script.
var gr = GlideRecord('v_user_session');
gr.query();
while (gr.next()){
gs.log("Logged in user: " + gr.user);
}
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2017 04:01 PM
Hi Pradeep,
Thanks for the script, but is there a way to get the same count per node for all the nodes existing in the system? and also i see few of the logged in users to be some random names like rest_system..are these system generated users or created by the instance admin owner?
Thanks
Divya

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2017 04:04 PM
we need to check table : sys_user_session same as logged in users but put the below filters and it gives logged in users currently in your instance irrespective of nodes.
name!=NULL^invalidated=NULL
Regards,
Sachin

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎06-08-2017 04:09 PM
Hello Divya,
Thanks for the update. The below blog has detailed info on what you are looking for.
https://servicenowgems.com/2016/04/28/finding-logged-in-users/