schrodinger.application.licensing.lmgrd_log_parser module¶
- class schrodinger.application.licensing.lmgrd_log_parser.event(time, feature, tokens, user, host)¶
Bases:
tuple
- feature¶
Alias for field number 1
- host¶
Alias for field number 4
- time¶
Alias for field number 0
- tokens¶
Alias for field number 2
- user¶
Alias for field number 3
- exception schrodinger.application.licensing.lmgrd_log_parser.UsageError(msg)¶
Bases:
Exception
- __init__(msg)¶
- schrodinger.application.licensing.lmgrd_log_parser.parse_logfile(logfile)¶
Parse an lmgrd logfile and return a list of checkin/checkout events.
Checkin/checkout events are reported as named tuples of type ‘event’. (See the parse_events() header doc for a description.)
- schrodinger.application.licensing.lmgrd_log_parser.parse_events(loglines)¶
Read the lines of an lmgrd log file, and return a list of checkin/checkout events. Loglines is an iterable that provides the lines of the log file.
Checkin/checkout events are reported as named tuples of type ‘event’, which have the elements (time, feature, tokens, user, host). The ‘tokens’ element is a signed integer; positive token counts represent checkouts and negative counts represent checkins. The time is a datetime. The ‘feature’, ‘host’, and ‘user’ elements are strings.
Checkin/checkout events include only the time for the event; the date needs to be determined separately. The date is reported in the log file at startup and periodically on TIMESTAMP lines. TIMESTAMP lines are not written at midnight, for some reason, and so transitions from one day to the next need to be inferred from the hour of the checkin/checkout time.
NOTE: If the lmgrd log doesn’t include the startup output, events logged before the first TIMESTAMP line will be ignored.
Sample log file checkout/in and timestamp lines are shown below.:
23:06:31 (lmgrd) FLEXnet Licensing (v11.10.0.0 build 95001 x64_mac10) started on Simon-Gaos-MacBook-Pro.local (Mac) (10/30/2012) 13:20:41 (SCHROD) OUT: "MMLIBS" saunders@ancalagon 13:20:41 (SCHROD) IN: "MMLIBS" saunders@ancalagon 9:10:40 (lmgrd) TIMESTAMP 10/31/2012 9:10:40 (SCHROD) TIMESTAMP 10/31/2012 9:42:58 (SCHROD) OUT: "SUITE_22JAN2013" saunders@Simon-Gaos-MacBook-Pro.local (4 licenses) 9:42:58 (SCHROD) OUT: "GLIDE_SP_DOCKING" saunders@Simon-Gaos-MacBook-Pro.local (4 licenses) 9:42:58 (SCHROD) IN: "SUITE_22JAN2013" saunders@Simon-Gaos-MacBook-Pro.local (4 licenses) 9:42:58 (SCHROD) IN: "GLIDE_SP_DOCKING" saunders@Simon-Gaos-MacBook-Pro.local (4 licenses) 21:37:00 (lmgrd) TIMESTAMP 10/31/2012 11:46:36 (SCHROD) UPGRADE: "PRIMEX_MAIN" golubkov@lori.schrodinger.com (1->8 licenses)
- schrodinger.application.licensing.lmgrd_log_parser.period_start(event_time, period)¶
Returns the start time for the reporting interval in which the given event time lies. The event time is a datetime; the period (the length of a reporting interval) is a timedelta.
Note: If the period is less than a day, there must be an integral number of reporting intervals per day. If it’s greater than a day, the period must be an integral number of days. These assumptions aren’t verified here.
If the period is zero, the event_time is returned.
- schrodinger.application.licensing.lmgrd_log_parser.format_usage_row(row, features)¶
Return a string containing a summary of the data in one row of the usage table. The first element is a timestamp (datetime); the remaining elements are the usage for each feature, in the interval ending at that time. This is just used for debug output.
- schrodinger.application.licensing.lmgrd_log_parser.maximum_usage(events, features, period, start=None, stop=None, user='', host='', init=[])¶
Take the list of checkin/checkout events and features, and return a table with the maximum number of tokens checked out at a time for each feature over each time period.
The result is a list of rows (lists). Each row represents a single period, with the end-time for that period followed by the maximum number of tokens checked out for each feature (in the same order as the input ‘features’ list.)
- schrodinger.application.licensing.lmgrd_log_parser.time_weighted_usage(events, features, period, start=None, stop=None, user='', host='', init=[])¶
Take the list of checkin/checkout events and features, and return a table with the total usage of each feature in token-hours for each time period. Events can be filtered by user and host, and by the start and stop times for the analysis. The number of tokens checked out for each feature at the beginning of the log can be specified using the init parameter (a dict, mapping feature name to token count.)
The result is a list of rows (lists). Each row represents a single period, with the end-time for that period followed by the usage for each feature (in the same order as the input ‘features’ list) in token-hours.
- schrodinger.application.licensing.lmgrd_log_parser.initial_tokens(events, features, user='', host='')¶
Take the list of checkin/checkout events and features, and returns dicts reporting the apparent number of checked-out tokens for each feature at the point where the log starts, and the final number of tokens still checked out at the point where the log ends.
Ordinarily, this should be zero. If the checkout records are incomplete, there may be more tokens checked in than checked out. The dict returned by this function will be used to make sure the total number of tokens checked out for each feature will never be reported to be negative.
- schrodinger.application.licensing.lmgrd_log_parser.write_events_csv(fname, events)¶
Write the given list of checkin/checkout events to a CSV file.
- schrodinger.application.licensing.lmgrd_log_parser.write_usage_csv(fname, usage, features)¶
Write the given timeline of token usage to a CSV file.
- schrodinger.application.licensing.lmgrd_log_parser.write_overall_usage_csv(fname, usage, features)¶
Write the given overall token usage to a CSV file, with each token’s usage on a separate row.
- schrodinger.application.licensing.lmgrd_log_parser.report_usage(usage, features)¶
Write the token usage timeline to the console. (This is mainly for debugging.)
- schrodinger.application.licensing.lmgrd_log_parser.report_total_usage(total, features)¶
Write the given total usage data for each feature, one per line.
- schrodinger.application.licensing.lmgrd_log_parser.calculate_total_usage(usage, features)¶
Calculate the total usage for each feature by summing down the list of per-period usage data.
A tuple of the totals is returned, with the total usage for the nth feature in the nth position.
- schrodinger.application.licensing.lmgrd_log_parser.parse_args(args=None)¶
Parse the commandline arguments and return a Namespace object containing the option values.
- schrodinger.application.licensing.lmgrd_log_parser.parse_timedelta(text, units='s')¶
Parse the given string as a timedelta. Units may be specified explicitly using one of the symbols “s”, “m”, “h”, “d” (lowercase only). If no units are specified in the text, the default units are assumed.
- schrodinger.application.licensing.lmgrd_log_parser.parse_datetime(text)¶
Parse the given string as a datetime.
- schrodinger.application.licensing.lmgrd_log_parser.main(args=None)¶
Main function