cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

Is there an API that can get the time each user of a feature acquired the license?

Is there an API that can get the time each user of a feature acquired the license?

Summary

Is there an API that can get the time each user of a feature acquired the license?

Question

We're trying to figure out how to get the time each use of a feature actually acquired the license. When they have a feature, the users consuming that feature's license are returned from the line below:

users = lc_userlist(lm_job, feature);

This is a list of structures of type LM_USERS which has a member time. This timestamp would be helpful for reports if it is the time the particular user checked out the license. However, it appears the value of the timestamp is basically unpredictable and there doesn't appear to be any documentation regarding what it really is.

We're interested in the time each particular user of a feature acquired the license to that feature from the server. Can we get it from the lc_userlist? If not, any other API? Does LM_A_VD_GENERIC_INFO provide the information we require?

Please note, this detail is available via LMTools under Server Status-> Individual Feature -> Perform Status Enquiry.


Answer

You can get the desired information using the below code snippet.

users = lc_userlist(lm_job, feature);

      printf("Start time = %s", ctime(&users->next->time)); 

      printf("Feature = %s\n", feature);

      printf("User = %s\n", users->next->name);

Additional Information

The list of users returned by lc_userlist() includes a special record, indicated by an empty user name (name[0]==0), which contains the total number of licenses supported by the daemon for the specified feature (in the nlic field), and the daemon?s idea of the current time (in the time field). To obtain the vendor daemon?s current time you have to specifically reference that special record.

For example:

users = lc_userlist(lm_job, feature);

                while (users)

                {

                                if (users->time != 0 && users->name[0] != 0)

                                {

                                                printf("%s, %s, %ld\n", users->name, users->node);

 

                                                time (&rawtime);

                                                t = localtime (&rawtime);

 

                                                strftime(buffer, 80, "Checkout time: %I:%M%p\n", t);

                                                puts (buffer);

                                }

                                users=users->next;

    }

 

Also, you can obtain the timestamp using LM_A_VD_GENERIC_INFO, for example:

 

c = (CONFIG *)0;

 

                    for (conf = lc_next_conf(lm_job, feature, &c);conf;

                                                             conf=lc_next_conf(lm_job, feature, &c))

                    {

                                         gi.feat = conf;

 

                                         if (lc_get_attr(lm_job, LM_A_VD_GENERIC_INFO, (short *)&gi))

                                         {

                                                             lc_perror(lm_job, "LM_A_VD_GENERIC_INFO");

                                         }

                                         else

                                         {

                                                             server_time = gi.server_current_time;

                                                             t = localtime(&server_time);

                                                             printf("License was checked out at %d:%d:%d\n", t->tm_hour, t->tm_min, t->tm_sec);

                                         }

                    }
Labels (1)
Was this article helpful? Yes No
No ratings
Version history
Last update:
‎Nov 14, 2018 10:41 PM
Updated by: