This script is designed to be used as a PRTG custom sensor to monitor FlexLM license usage. It parses license usage logs and reports the number of currently checked-out licenses for various products, providing multiple channels for monitoring each product.
- Retrieves FlexLM license usage data from the specified server.
- Parses log files and extracts detailed information about license usage (checkout and return events).
- Provides multiple channels in PRTG, one for each license type, displaying the number of active licenses.
- Dynamically adjusts the monitored license count based on log activity.
-
Copy the script
Place the script on the PRTG ServerC:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML -
Create a Custom Sensor
- Log into your PRTG interface.
- Create a new custom sensor on the device that should monitor the license server.
- Select "EXE/Script Advanced" as the sensor type.
- Point the sensor to the script file and provide the required parameter (
Servername) in the sensor settings.-
Parameters =
-Servername %device -
Security Context =
Use Windows credentials of parent device(make sure to specify the credentials, which have the rights to access the target server via Powershell, tryEnter-PSSession -ComputerName $myServer -Credentials (Get-Credential) -
Scanning interval =
10 Minutes(should be sufficient. The script may run for some seconds depending on the size of theC:\Program Files (x86)\SOLIDWORKS Corp\SolidNetWork License Manager\lmgrd.log
-
-
Script Parameters
Servername: The name of the FlexLM license server that the script should connect to. Keep in mind to use %device within PRTG.
-
Channels
The script dynamically creates a PRTG sensor channel for each unique license found in the log file. For each channel, the number of licenses currently checked out will be reported.<prtg> <result> <channel>ProductA</channel> <value>5</value> </result> <result> <channel>ProductB</channel> <value>2</value> </result> <result> <channel>ProductC</channel> <value>0</value> </result> </prtg>Each tag represents a license type and the corresponding number of checked-out licenses.
-
Requirements
- PowerShell 5.1 or later
- Access to the FlexLM license manager's log files
- PRTG with permissions to run PowerShell scripts on the probe
-
Problems
- On any problems try to execute the script in a powershell session and add the credential parameter.
$cred = Get-Credential Invoke-Command -ScriptBlock $scriptblock -ComputerName $Servername -Credential $cred
- On any problems try to execute the script in a powershell session and add the credential parameter.
-
Bonus / Additional Export
- If you aditionally want to export the license usage to a specific folder, just uncomment the following two lines in the script.
$filename = "C:\LicenseUsage\lmgrd_log_analyze_" + (get-date).ToString("yyyyMMdd_HHmmss") + ".csv" $result | Export-Csv -LiteralPath $filename -NoClobber -Encoding UTF8 -Delimiter ";" - (Keep in mind, that the lmgrd logfile is being resetted on every server restart / service restart and that the logfile is being overwritten by the service.)
- If you aditionally want to export the license usage to a specific folder, just uncomment the following two lines in the script.
-
License
- This script is provided as-is, with no warranty or support. Feel free to modify it to suit your environment.

