9 Replies · Latest reply on Jan 3, 2018 11:34 AM by Sangram Nanda

    determine which node a user is logged into?

      I would like to be able to determine which node a user is logged into? I'm able to see logged in users (v_user_session) but if I understand correctly this list only contains user sessions on the node that I'm currently logged into. Is there a way to determine which node a user is logged into (which node they have an active session on)?

       

      -Thanks

        • Re: determine which node a user is logged into?
          Subhajit Das

          Hi Bryan,

           

          You can do a /stats.do after your Service-Now instance URL and in the following information you will be able to see your logged in Node.

          For User sessions you can use the Claimed By column to see which node the user is logged into.

           

          Thanks,

          Subhajit

          Thanks,
          Subhajit

          Hit Like, Helpful or Correct based upon the impact of the response

          • Re: determine which node a user is logged into?
            Andrew Lawlor

            I think a simple way to do this for an individual user is to query the syslog_transaction table. Here's a basic script that should suite your needs. You can add it to a Script Include and call it from a UI Action on the User table to provide a quick way to find a user's node. Just keep in mind that any given user can have multiple sessions open with different browsers -- so you might want to use the session field of the syslog_transaction table to account for this.

             

            function findUserNode(userID) {

             

            if (userID)

              {

              var logs = new GlideRecord('syslog_transaction');

              logs.addQuery('sys_created_by', userID);

              logs.addQuery('sys_created_on', '>', gs.minutesAgo(15)); // This is arbitrary

               // You should add an order by here -- use sys_created_on  

              logs.setLimit(1);

              logs.query();

              if (logs.next())  // change to a loop if you want nodes for multiple sessions.

              {

              var node = logs.system_id.toString();

              var num = node.indexOf(':');

              var nodeName = node.substring(parseInt(num + 1), parseInt(node.length));

              gs.addInfoMessage("User " + userID + " is currently logged into node: " + nodeName);

              }

              else

              {

              gs.addInfoMessage("User " + userID + "is not currently logged in");

              }

              }

            }

              • Re: determine which node a user is logged into?
                Andrew Lawlor

                I'm working on something similar, and after thinking about it for awhile, we can get much more useful and relevant information using GlideAggregate instead:

                 

                function getSessionInfo(userID) {

                if (userID)

                {

                var ga = new GlideAggregate('syslog_transaction');

                ga.addQuery('sys_created_on', '>', gs.minutesAgo(15)); // again, this is arbitrary.

                ga.addQuery('sys_created_by', userID);

                ga.groupBy('session'); // This gives us relevant data for each session -- one user might have multiple sessions going.

                ga.groupBy('system_id'); // Also grouping by node.

                ga.addAggregate('AVG', 'network_time'); // Additional info, if you want it.

                ga.addAggregate('AVG', 'response_time');

                ga.query();

                 

                 

                while (ga.next())

                {

                gs.print("Data for session ID: " + ga.session);

                gs.print("User: " + userID);

                gs.print("Node: " + ga.system_id);

                var secs = (parseFloat(ga.getAggregate('AVG', 'response_time')))/1000;

                gs.print("AVG Response Time: " + secs);

                 

                } // end while

                } // end if

                }

                 

                Something like this would work well in a UI action (infomessage), homepage widget or as its own UI Page/GlideDialogWindow.

                 

                Andrew

              • Re: determine which node a user is logged into?
                Nadia Russell

                If your just looking to find what node a user is on you can check it 2 different ways.

                 

                     1. Have the user type stats.do in the left nav. Then ask them for the cluster node name.

                     2. Under System Diagnostics > Active Transactions (All Nodes) add the user field to your list view and search for the user that way.

                 

                Nadia

                • Re: determine which node a user is logged into?
                  Sangram Nanda

                  Screen Shot 2018-01-03 at 2.32.46 PM.png

                   

                  Transaction(All user ) >

                  System Id will tell you node  , created by will be the user