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

Returning integers to EXE sensor

Votes:

0

Hi Guys,

I am trying to check if a folder is written to in the last 24hr using EXE (i know the folder sensor exists but it will not work in this situation) however i am having issues with the returning value being read correctly by PRTG.

here is the sensor script

$Today = Get-Date
$FileList = Get-ChildItem -LiteralPath 'UNCPATH' -File 

$AgeLimitHours = 24

foreach ($FL_Item in $FileList)
    {
    $HoursOld = [math]::Round(($Today - $FL_Item.LastWriteTime).TotalHours, 0)

    if ($HoursOld -le $AgeLimitHours)
        {
        'value:2' -f $AgeLimitHours
        }
        else
        {
        'value:1'
        }
    }

This returns: {{{ value:1 value:1 value:1 value:1 value:1 value:2 }} for 6 files over 24hr old and 1 file under 24hrs old. However PRTG only reads 0 as a value. It does however display 1 or 2 directly under the name, as a message?

How can i ensure that the value output is read properly?

custom custom-script-exe custom-sensor

Created on Mar 9, 2018 1:08:15 PM

Last change on Mar 9, 2018 1:30:07 PM by  Luciano Lingnau [Paessler]



1 Reply

Accepted Answer

Votes:

0

Hello Samuel,
thank you for your KB-Post.

If you want to have a sensor capable of displaying multiple results, you need to work with the "Advanced" custom sensor variants, that expect JSON or XML. This way you can have up to 50 channels. Please have a look at this KB-Post to understand how the data should look like:

When working with the non-advanced sensors, you can only have one value, but you can have a message. The output should look like this:

value:message

Example for a value of 5 with text "Everything OK" in Powershell:

Write-Host "5:Everything OK"
exit 0

Best Regards,
Luciano Lingnau [Paessler Support]

Created on Mar 9, 2018 1:35:22 PM by  Luciano Lingnau [Paessler]




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.