-
Notifications
You must be signed in to change notification settings - Fork 41
Feature request: Track token sub-feature names in user checkout metrics #213
Description
Some FlexLM setups use token-based licensing where a pool (e.g. MSCONE, TLSTOK) is shared across multiple products. When a user checks out a license, the actual product shows up as a sub-feature before the version in lmstat -a:
MSC One tokens (sub-feature keeps the pool prefix):
Users of MSCONE: (Total of 500 licenses issued; Total of 120 licenses in use)
jdoe workstation1 display MSCONE:NASTRAN (v2021.1) (licserver/27000 101), start Mon 3/15 10:30, 5 licenses
asmith workstation2 display MSCONE:ABAQUS (v2021.1) (licserver/27000 201), start Mon 3/15 10:45, 8 licenses
IBM Rational tokens (sub-feature is the product name directly):
Users of TLSTOK: (Total of 1000 licenses issued; Total of 350 licenses in use)
bjones pc-dev01 display ratl_DOORS_NG (v9.7) (ibmsrv/27000 301), start Tue 3/16 8:02, 12 licenses
mwilson pc-dev02 display ratl_rsa#D (v9.0) (ibmsrv/27000 401), start Tue 3/16 9:15, 25 licenses
Right now the exporter picks up the license count (5 licenses, 12 licenses) correctly via the licenses named group, but the sub-feature name (MSCONE:NASTRAN, ratl_DOORS_NG) gets swallowed by the [[:print:]]+ in the user regex and is lost.
So you end up knowing that user X is consuming N tokens from the pool, but not which product. For token-based setups that's really the most important piece of info -- it's what you need for cost allocation and capacity planning.
What I'm proposing
The change is small, 4 files:
collector/regexp.go -- new regex that extracts the sub-token from lines ending with , N license(s):
lmutilLicenseFeatureUsageTokenRegex = regexp.MustCompile(
`^\s+\S+\s+\S+\s+.*?\s+(?P<token>\S+)\s+\(v[\w\.]+\).*\,\s+\d+\s+licenses?`)The regex only matches when there's an extra field between the display and (vXXX), so it won't fire on standard multi-license checkouts. Works with both MSCONE:NASTRAN (colon-prefixed) and ratl_DOORS_NG (plain name) token formats.
collector/structs.go -- new token field on featureUserUsed.
collector/lmstat.go -- after the existing user regex match, run the token regex. If it matches, store the captured sub-feature. New metric flexlm_feature_used_users_tokens{app, name, user, since, version, token}, only emitted when a token is detected.
config/config.go -- new monitor_tokens: true option, same pattern as monitor_users / monitor_reservations / monitor_versions.
Example output:
flexlm_feature_used_users_tokens{app="msc",name="MSCONE",user="jdoe",since="1742648400",version="(v2021.1)",token="MSCONE:NASTRAN"} 5
flexlm_feature_used_users_tokens{app="ibm",name="TLSTOK",user="bjones",since="1742713320",version="(v9.7)",token="ratl_DOORS_NG"} 12
This doesn't touch existing metrics. I have a working diff ready, happy to open a PR if you're interested.