Count - Users Logged in at a time and storing result

nvermanverma Member Posts: 396
My Manager has asked me to create a table that will keep track of no. of user that are logged on to the database. We want this table to be run every 5 minutes. This is being done because one of our client is starting to run low on the no. of user licences. We would like to find out when we have the most user traffic and how many users were logged in. This information must be saved on a table, because our ultimate goal is to create a report, which will display the time at which max no. of users were logged on each day. I am not really sure where to begin. Any suggestions.

My manager told me if I were to go to FILE-> DATABASE-> INFORMATION->SESSIONS, I can see the number of current sessions (users that are logged in). :D

Is it possible to automate the table so it could run every 5 minutues and store the result????.

Comments

  • SavatageSavatage Member Posts: 7,142
    edited 2012-05-31
    Is the real issue that some sessions are open & unattended?

    If so there are many posts about automatically loggin out user sessions after a set amount of time has passed (10 mins, 20 mins, 30 min, etc) without activity.

    This will insure that you have just active users logged in creating space for those who need to login from being locked out. Search forum for "Kill Idle Sessions"

    Else increase your concurrent users in your license.

    Also, we use in G/L Setup - there is a user setup where we check off "Register Time" and it stores the times in table 51 "User Time Register" We've modified CU1 & that table to include some new fields like
    "Login Time"
    "Logout Time"
    "Day"
    LogInStart()
    ..
    ..
    LogInDate := TODAY;
    LogInTime := TIME;
    ..
    
    LogInEnd()
    ..
    ..
      IF RegisterTime THEN BEGIN
        LogOutDate := TODAY;
        LogOutTime := TIME;
    ..
    
  • nvermanverma Member Posts: 396
    I just talked to my manager again, and he suggested that I should create a codeunit instead and he suggested that I should make it work by using the OnRun Trigger and when its working manually, he will show me how we to automate it so it would run every 5 mintues.

    Let me bang my head against the wall ](*,) and try to figure it out before I ask you guyz for help. :D

    The bottom line is to show this information to the client, so that we could buy more licenses.
  • SavatageSavatage Member Posts: 7,142
    See my post above - nav have the ability to store the times of users.
    And we then can run reports off of that table.

    What your manager is asking doesn't make sence to me. You either have enough licensed user sessions or you don't. Now if some users are leaving there sessions open & unattended then that's what you need to attack by closing these sessions.

    I mean for how log do you plan on logging this info?
    What if all your sessions are full early one day, midday then next or late at night the next.
    Will you be telling some users they can't work between x:xx o'clock?
  • David_SingletonDavid_Singleton Member Posts: 5,479
    nverma wrote:
    My Manager has asked me to create a table that will keep track of no. of user that are logged on to the database.
    You do know that there is a standard function in Navision that will give you this info right? ](*,)
    David Singleton
  • gerrykistlergerrykistler Member Posts: 149
    You can use the Session virtual table to get this information and it might be helpful to also get the user's idle time in the process in order to know if it would help to be killing sessions of idle users.
    Gerry Kistler
    KCP Consultores
  • nvermanverma Member Posts: 396
    I just had a quick question. I have been able to count the total number of users that are logged on to the live database. I am not sure how to do the next step. Once its done counting I want the count to be written to a table(UsersLogged) to this field (Current Users) . and every time i run this codeunit it should add the count to the next line of the table. I tried this line but it didnt work: UsersLoggedOn."Current Users" := TotalUsers; :(

    Code is written on the OnRun trigger on the codeunit.
    TotalUsers :=0 ;
    
    Session.SETRANGE("Database Name", 'MODC - Live');
    IF Session.FINDSET THEN
      REPEAT
    
        TotalUsers += 1;
       //     UsersLoggedOn.INSERT;
      UNTIL Session.NEXT = 0;
    // UsersLoggedOn."Current Users" := TotalUsers;
    MESSAGE('Total Users %1', TotalUsers);
    
  • gerrykistlergerrykistler Member Posts: 149
    You need a primary key on the table maybe it is the DateTime, or an Entry No. If you use DateTime, no problem you will be creating a unique record each time. If you use EntryNo., then just get the last value in the table and increment it.
    Gerry Kistler
    KCP Consultores
  • SavatageSavatage Member Posts: 7,142
    What I notice from your replys from multiple posts is that you appear never to question your "manager".
    And even tho other suggestions are made you seem to just plow thru with the "managers" requests. You can have all your users loggin in at once doing nothing or 1 user doing heavy posting. Now you are not learning anything about usage by just saving the # of logged in users every 5 minutes in my opinion.

    and closing unused/unactive sessions is where your focus should be.
  • gerrykistlergerrykistler Member Posts: 149
    I agree with Harry just tracking users logged in does not give you much. You ought to choose an idle time limit and track not only total users but idle users as well. Then you will have something you can analyze and can intelligently decide if your problem is idle users not logging out or if you are using TS or Citrix, not logging out properly, or you really need to purchase addition user sessions. This information is in the Session table, so getting this information at the same time will be easy.
    Gerry Kistler
    KCP Consultores
  • nvermanverma Member Posts: 396
    I see your point and I agree with kicking the user off after a certain idle time. But, what I am trying to do is just create a table which has the total number of users that are logged on and collect data for few weeks and then present it to the client so they could take the appropriate steps to get more licenses.

    I am doing this table just to get the proof to show them we are getting close to using up all the licenses.
  • gerrykistlergerrykistler Member Posts: 149
    You are not doing your customer any service if you do not include idle users. You would be far better ahead with customer relations if you included idle users, and if that is the problem then sell them something to kill the idle users. If you find out it is not idle users then go ahead and sell them more user sessions. But if you sell them user sessions and then they find out their problem really was idle users, they will not be a happy customer. I have found if I think of the customer first, I will come out ahead in the long run.
    Gerry Kistler
    KCP Consultores
  • nvermanverma Member Posts: 396
    There are already measures in place to kick the user off after a certain idle time. This little piece that I am working on is to show them we are in need of more licenses.
  • gerrykistlergerrykistler Member Posts: 149
    It would have saved all of us time if you had bothered to mention this little piece of information when idle users was first mentioned.
    Gerry Kistler
    KCP Consultores
  • nvermanverma Member Posts: 396
    my bad....

    how do i write the count to the UserLoggedON table....i did setup a primary key called Line No. (integer -data type) and i increment it at the end of codeunit...but still nothing...any idea what i might be doing wrong....?????
  • gerrykistlergerrykistler Member Posts: 149
    Well you have commented out an Insert - it is in the wrong place (it needs to be at the end of your loop) - if you do not insert you will have nothing. I dont know what else without seeing your latest code.
    Gerry Kistler
    KCP Consultores
  • nvermanverma Member Posts: 396
    putting the insert at the end of the lop and adding an INIT at the begining of the loop made it work....thanks... :D
Sign In or Register to comment.