What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general.

Learn more

PRTG Network Monitor

Intuitive to Use. Easy to manage.
More than 500,000 users rely on Paessler PRTG every day. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free Download

Top Tags


View all Tags

How can I monitor licenses in my network?

Votes:

0

I need to monitor multiple licenses on several Hosts (like firewall appliances, antivirus servers, etc.). How can I do that with PRTG?

firewalls license license-expiration

Created on May 27, 2014 8:39:26 AM by  Stephan Linke [Paessler Support]

Last change on May 27, 2014 8:39:55 AM by  Stephan Linke [Paessler Support]



23 Replies

Accepted Answer

Votes:

2

To monitor the licenses that are used in your network, regardless of the appliance or software, please create an EXE/Script Advanced sensor which uses the PowerShell script given below.

Set up Monitoring of license status

  • Open a text editor.
  • Copy the following code and paste it into the editor:
Param([string]$ExpirationDate)

$DateDifference = New-TimeSpan -Start (Get-Date) -End $ExpirationDate
$Days = $DateDifference.Days
$DaysPassed = ($Days * -1)
if($Days -gt 0){
                Write-Host "$($Days):License expires in $($Days) day(s)."
                exit 0 }
if($Days -eq 0){
                Write-Host "$($Days):The license expires today!";
                exit 1
}
if($Days -lt 0){
                Write-Host "0:License expired for $($DaysPassed) days!"
                exit 1
}
  • Save the file and name it, e.g., license_status.ps1
  • Place the script in the \Custom Sensors\EXE sub-directory of your PRTG installation to ensure that the EXE/Script Advanced sensor can pick up the same.
  • Create a new EXE/Script Sensor .
    • Choose license_status.ps1 as executable.
    • As Parameter, pass the following: ExpirationDate="2015-31-12"
    • Please note that the date format must suit your system default (i.e. DD.MM.YYYY for german)

The sensor will show you the remaining days of your license. It also shows how many days the license is already expired if that is the case. Please don't forget to set lower limits in the channel settings to get notified a few days earlier.

Best regards.

Created on May 27, 2014 8:53:00 AM by  Stephan Linke [Paessler Support]

Last change on Sep 27, 2018 10:03:31 AM by  Erhard Mikulik [Paessler Support]



Votes:

0

Hi,

This script doesn't work anymore (error code PE231). Do you have one that works with version 18.3.42?

Thanks & regards

Created on Jul 17, 2018 12:38:00 PM



Votes:

0

It should work properly. How are you passing the parameters?


Kind regards,
Stephan Linke, Tech Support Team

Created on Jul 17, 2018 12:49:34 PM by  Stephan Linke [Paessler Support]



Votes:

0

Has somebody already test it with PRTG 18x ? If it doesn't work, has somebody an update ?

Regards

Frederic

Created on Jul 24, 2018 12:31:19 PM



Votes:

0

It should work properly. How are you passing the parameters?

Created on Jul 24, 2018 1:09:25 PM by  Stephan Linke [Paessler Support]



Votes:

0

@prtg_eurogentec

I copied the above code in an ps1 file: expdate.ps1 then execute it in powershell with .\expdate.ps1 "01-12-2018" this works for me. (datetime is german, you may need to enter 'expdate.ps1 2018-12-01' for your country"

ergards Thomas

Created on Jul 25, 2018 7:49:54 AM



Votes:

0

Thomas is correct here, make sure the date notation matches the region of the PRTG server (i.e. the Windows setting). Otherwise, it'll probably error. Regardless of PRTG's version :) Thanks for chiming in, Thomas!


Kind regards,
Stephan Linke, Tech Support Team

Created on Jul 25, 2018 8:47:35 AM by  Stephan Linke [Paessler Support]



Votes:

0

Getting this error: New-TimeSpan : Cannot bind parameter 'End'. Cannot convert value "" to type "System.DateTime"

Any idea on how to fix this?

Created on Mar 20, 2019 3:34:05 PM



Votes:

0

What's your server region and what does the end date look like?


PRTGapi | Feature Requests | WMI Issues | SNMP Issues

Kind regards,
Stephan Linke, Tech Support Team

Created on Mar 20, 2019 3:41:45 PM by  Stephan Linke [Paessler Support]



Votes:

0

United States

DD/MM/YYYY

Created on Mar 20, 2019 3:53:52 PM



Votes:

0

Try MM/DD/YYYY instead :) That should work with that region.


PRTGapi | Feature Requests | WMI Issues | SNMP Issues

Kind regards,
Stephan Linke, Tech Support Team

Created on Mar 21, 2019 7:47:40 AM by  Stephan Linke [Paessler Support]



Votes:

0

I have created this sensor but the result it returns is not correct, the sensor is in warning state with the message 'License expired for days!' and the value is showing as 0. I have ran the powershell manually and that works fine, returning the correct number of days. The parameter I am passing is in the correct date format (the same as when I run the powershell manually on the probe). Any ideas as to why this might be happening?

Thanks

Andy

Created on Mar 25, 2019 10:22:02 AM

Last change on Mar 25, 2019 10:22:02 AM



Votes:

0

Seems that the answer to my question is to set the parameter in PRTG to just the date i.e. "16-12-2019" rather than ExpirationDate="16-12-2019"

Created on Mar 25, 2019 10:44:38 AM



Votes:

0

@aojari thanks for the update, glad it's working now. The proper syntax would be the following
-ExpirationDate '16-12-2019'

Created on Mar 25, 2019 11:06:03 AM by  Stephan Linke [Paessler Support]



Votes:

0

Just adding my two cents here since I ran into this problem.

Creating the ps file I wasn't able to load it, it wouldn't show up in the EXE/Script list when creating a new sensor. Even restarting the core and probe services didn't help. I finally figured out the issue:

This would be useful to you guys who have multiple probes. Since I added the file to the custom sensor folder on the primary server, I can only view it when adding sensors to the local probe. I'm guessing I need to add it to the folder on the probe I would be using the sensor on.

Created on Jan 10, 2022 8:01:13 AM



Votes:

1

Hi ToyRazee,

you are right. If you want to use a custom script on a Remote Probe you need to store the script there. The Remote Probe will only send the results of the sensor scans to the Core Server. This means that all sensors scans are executed by the Probe itself.


Kind regards

Felix Wiesneth - Team Tech Support

Created on Jan 10, 2022 8:16:45 AM by  Felix Wiesneth [Paessler Support]



Votes:

0

This script is working perfectly, thanks for sharing this folks!

The one thing I would like to change as a preference is to set the alert from "warning" when a certain threshold is met to "DOWN"

I seem to be unable to change that category on this sensor. Any advice on that leg?

Thank you, -Travis R.

Created on Oct 3, 2022 3:47:02 PM



Votes:

0

Hi Travis,

If you change the exit code, you can change the state of the sensor. This means that you will need to adjust the script at following point:

...
                exit 1
...

I would recommend to take a look in our manual about the different exit codes here. In addition you will find the codes below:

exit codestatus
0OK
1WARNING
2System Error
3Protocol Error
4Content Error

Kind regards

Felix Wiesneth - Team Technical Support

Created on Oct 4, 2022 6:30:24 AM by  Felix Wiesneth [Paessler Support]



Votes:

0

To try to help, in case someone has the same problem as me. I used the script above in PRTG version 22.3.79.2108+ with various combinations of parameters, but it always returned an error.

I did some research on the internet and in a similar case, I saw that inside the script, the "Write-Host" syntax should be changed to "write-output".

And when creating the sensor, in "parameters", only the date should be placed exactly like this: "28/04/2024".

In my case, the PRTG and server are in Brazilian Portuguese, so the date is dd/MM/aaaa.

Created on Jan 24, 2023 6:52:41 PM

Last change on Jan 25, 2023 6:55:05 AM by  Felix Wiesneth [Paessler Support]



Votes:

0

@razevedo it would help if you could share the error message you get. Are you able to select the script file from the UI?

Created on Jan 25, 2023 8:47:46 AM



Votes:

0

Dear @Toy Razee,

In my case it's working perfectly. I just made the post above to help other people, if they have the same problem as me, because I spent a lot of time trying to solve it.

The error that was appearing before was the same one that has already been posted here by other people: "error code PE231".

Regards.

Created on Jan 27, 2023 12:10:24 PM



Votes:

0

Hi @razevedo noted and thanks for pointing it out. Am sure this thread will help others trying to customize their PRTG installations. The only issue I ran into with scripts is realizing that they need to be specifically loaded to the probe used for the sensors, just loading them onto the core is not enough.

Created on Jan 30, 2023 6:57:41 AM



Votes:

0

Hi,

Thank you for all the inputs.
You are right, you will need to store your custom scripts in C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors on the corresponding Probe, since the sensors (and also custom scripts) will be executed on the Probe and only the results will be forwarded to the Core Server.


Kind regards

Felix Wiesneth - Team Technical Support

Created on Jan 30, 2023 10:15:41 AM by  Felix Wiesneth [Paessler Support]




Disclaimer: The information in the Paessler Knowledge Base comes without warranty of any kind. Use at your own risk. Before applying any instructions please exercise proper system administrator housekeeping. You must make sure that a proper backup of all your data is available.