New Question
 
 
PRTG Network Monitor

Intuitive to Use.
Easy to manage.

200.000 administrators have chosen PRTG to monitor their network. Find out how you can reduce cost, increase QoS and ease planning, as well.

Free PRTG
Download >>

 

What is this?

This knowledgebase contains questions and answers about PRTG Network Monitor and network monitoring in general. You are invited to get involved by asking and answering questions!

Learn more

 

Top Tags


View all Tags


Problem with EXE/XML Sensor

Votes:

0

Your Vote:

Up

Down

Hi, I have a problem with some Custom EXE/XML sensor. I need to measure load time and bytes received for some web page, but the trick is, that every day I need to use other URL - so I can't just use typical HTTP Advanced Sensor and I wrote some custom sensor in Powershell that should return data I need. The code is as follow:

First I build the proper URL:

[string]$IP = "x.x.x.x"
[string]$Data = [string]((Get-Date).AddDays(-1)).Year+"-"+[string]((Get-Date).AddDays(-1)).Month+"-"+[string]((Get-Date).AddDays(-1)).Day

$URL = "http://$IP/...........&UpdateDate=$Data"

Then I run commands to get page load time, status and data size:

$ResponseTime = Measure-Command {$WebParam = Invoke-WebRequest -Uri $URL -DisableKeepAlive | Select StatusCode, RawContentLength}

$ResponseTimeMS = [math]::Round($ResponseTime.TotalMilliseconds)
$BytesReceived = $WebParam.RawContentLength
$StatusCode = $WebParam.StatusCode

And finally I build output for PRTG:

Write-Host 
"<prtg>"
    "<result>"
        "<channel>Response Time</channel>"
            "<value>$ResponseTimeMS</value>"
            "<Unit>miliseconds</Unit>"
            "<LimitMode>0</LimitMode>"
            "<LimitMaxError>0</LimitMaxError>"
            "<ShowChart>1</ShowChart>"
            "<ShowTable>1</ShowTable>"
    "</result>"
    "<result>"
        "<channel>Bytes Received</channel>"
            "<value>$BytesReceived</value>"
            "<Unit>bytes</Unit>"
            "<LimitMode>0</LimitMode>"
            "<LimitMaxError>0</LimitMaxError>"
            "<ShowChart>1</ShowChart>"
            "<ShowTable>1</ShowTable>"
    "</result>"
    "<result>"
        "<channel>Status Code</channel>"
            "<value>$StatusCode</value>"
            "<Unit>status</Unit>"
            "<LimitMode>0</LimitMode>"
            "<LimitMaxError>0</LimitMaxError>"
            "<ShowChart>1</ShowChart>"
            "<ShowTable>1</ShowTable>"
    "</result>"
"</prtg>"


Everything works perfect when I run sensor directly from the server - it shows proper values, etc. But when I run it from the sensor, it shows strange things - for example StatusCode and BytesReceived are always 0, ResponseTime is definitiv wrong as well. It looks like it actually doesn't ask proper URL, but I have no idea what can be wrong - it's simple code, without remoting, variables in awkward format, etc. Could you take a look and help me with it? Custom EXE sensors are very powerful but because of such problems are sometimes very unintuitive :(

Thanks Marcin

custom-script-exe exexml xml

Created on Dec 4, 2017 9:25:22 PM by  Marcin (0) 1

Last change on Dec 5, 2017 10:04:22 AM by  Dariusz Gorka [Paessler Support]



1 Reply

Votes:

0

Your Vote:

Up

Down

Hi there,

Please activate the "Write EXE result to disk" option in the sensor's settings and forward us the log files (Result of Sensor XXX.Data.txt and Result of Sensor XXX.txt) located on the corresponding probe under "C:\ProgramData\Paessler\PRTG Network Monitor\Logs (Sensors)". Please forward us the logfile to [email protected] by using the following Subject "PAE964241".

Best regards.

Created on Dec 5, 2017 10:05:55 AM by  Dariusz Gorka [Paessler Support]

Last change on Dec 5, 2017 10:05:59 AM by  Dariusz Gorka [Paessler Support]



Please log in or register to enter your reply.


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.