Hello. I'm following https://helpdesk.paessler.com/en/support/solutions/articles/7600006366853-is-it-possible-to-monitor-the-copy-of-a-file-from-one-server-to-another-and-get-the-speed-of-the-t but can't get it to work. Error message is:

Response not wellformed: "(<prtg> <result> <channel>Transfer Time</channel> <value>00:00:00.0474189</value> </result> <text>OK</text> </prtg> )" (code: PE132)

Here's my NasMonitor.ps1:

$time=Measure-Command -Expression {Copy-Item D:\Permanent\NasMonitor\NasMonitor.txt \\192.168.1.103\nas\60Zona\NasMonitor} Write-Host "<prtg>" Write-Host "<result>" "<channel>Transfer Time</channel>" "<value>"+ $time +"</value>" "</result>" "<text>OK</text>" Write-Host "</prtg>"

When I execute it from PowerShell it works. Enabling Write EXE result to disk, Result of Sensor 2073.txt shows:

<prtg> <result> <channel>Transfer Time</channel> <value>00:00:00.0407119</value> </result> <text>OK</text> </prtg>

And Result of Sensor 2073.Data.txt shows:

Data['blockedsens'].asString := ''; Data['canlinux'].asString := '1'; Data['channel'].asString := 'Value'; Data['channelinfos'].asString := '{"1":{"Unit":"oukTimeResponse","CustomUnit":"","ValueLookupName":"","LimitMode":"0","LimitMinError":"","LimitMinWarning":"","LimitMaxError":"","LimitMaxWarning":""},"2":{"Unit":"oukCustom","CustomUnit":"#","ValueLookupName":"","LimitMode":"0","LimitMinError":"","LimitMinWarning":"","LimitMaxError":"","LimitMaxWarning":""}}'; Data['channelnames'].asString := 'Execution Time'#$D#$A + '1'#$D#$A + 'Value'#$D#$A + '2'#$D#$A + ''; Data['environment'].asString := ''; Data['exefile'].asString := 'NasMonitor.ps1'; Data['exeparams'].asString := ''; Data['fastcount'].asString := '0'; Data['host'].asString := '192.168.1.103'; Data['hostv6'].asString := ''; Data['inerror'].asString := '1'; Data['interfacenumber'].asString := ''; Data['inum'].asString := ''; Data['ipversion'].asString := '0'; Data['isexesensor'].asString := '1'; Data['lastmsg'].asString := '#O132 (<prtg> <result> <channel>Transfer Time</channel> <value>00:00:00.0423838</value> </result> <text>OK</text> </prtg> )'; Data['lastuptime'].asString := '0'; Data['linuxlogindomain'].asString := ''; Data['linuxloginpassword'].asString := '***'; Data['monitorchange'].asString := '0'; Data['mutexname'].asString := ''; Data['notonpod'].asString := '0'; Data['reboot'].asString := '42820.9591687269'; Data['reqmsginterval'].asString := '60'; Data['resultfile'].asString := 'Result of Sensor 2073.txt'; Data['sensorid'].asString := '2073'; Data['simulate'].asString := '0'; Data['timeout'].asString := '60'; Data['tlsexplicit_default'].asString := ''; Data['tlsexplicit_ftp'].asString := ''; Data['tlsexplicit_imap'].asString := ''; Data['tlsexplicit_pop3'].asString := ''; Data['tlsexplicit_port'].asString := ''; Data['tlsexplicit_smtp'].asString := ''; Data['unit'].asString := '#'; Data['uptimecount'].asString := '0'; Data['usednstime'].asString := '0'; Data['usewindowsauthentication'].asString := '0'; Data['valuetype'].asString := '0'; Data['windowslogindomain'].asString := ''; Data['windowsloginpassword'].asString := '***'; Data['windowsloginusername'].asString := ''; Data['writeresult'].asString := '1';

I can't see what's malformed. File is being copied and transfer time is being shown. What am I missing?


Article Comments

Hikari,

My Guess, you are using a "EXE/Script" sensor, you should be using an "EXE/Script Advanced"

In short, "EXE/Script" has a simple and single plain text response, like "88:OK"

"EXE/Script Advanced", needs XML, and can return multiple values.

From the page you linked, try the following code in a "EXE/Script" $time=Measure-Command -Expression {Copy-Item C:\filetocopy.txt C:\Wherefileiscopied} write-host $time":ok"

OR

Try the following code in an "EXE/Script Advanced"

$time=Measure-Command -Expression {Copy-Item C:\filetocopy.txt C:\Wherefileiscopied} Write-Host "<prtg>" Write-Host "<result>" "<channel>Transfer Time</channel>" "<value>"+ $time.seconds +"</value>" "</result>" "<text>OK</text>" Write-Host "</prtg>"


Mar, 2017 - Permalink

Hello,

THank you for the KB-Post. The error message actually already hints on the issue:

{{{Response not wellformed: "(<prtg> <result> <channel>Transfer Time</channel> <value>00:00:00.0474189</value> </result> <text>OK</text> </prtg> )" (code: PE132)}}}

The problem is that the return value isn't exactly a number here with the date format including colons. PRTG expects either integers there or a float. Have the script calculate a value in only seconds (or milliseconds) here, and only return this then as one single number, and it should work.

best regards.


Mar, 2017 - Permalink

Thanks. I managed to make it work this way

Write-Host "<prtg>" Write-Host "<result>" "<channel>Transfer Time</channel>" "<value>"+ $time.ToString("ss\.fffff") +"</value>" "</result>" "<text>OK</text>" Write-Host "</prtg>"

Output is

<prtg> <result> <channel>Transfer Time</channel> <value>00.23773</value> </result> <text>OK</text> </prtg>

PRTG shows OK as last message. But value seems to not be recording. Its log table has a Transfer Time column, that remains with value "0 #". It seems to be ignoring the float point part.


Mar, 2017 - Permalink

It appears that the float-setting is not set in the response. From the API-documentation in your very own PRTG ("Setup"->"PRTG API"->"Custom Sensors"):

The value as integer or float. Please make sure the <Float> setting matches the kind of value provided. Otherwise PRTG will show 0 values.	

Mar, 2017 - Permalink

Thank you for your KB.

For completed the script Powershell above :

$time=Measure-Command -Expression {Copy-Item C:\filetocopy.txt C:\Wherefileiscopied}
Write-Host "<prtg>"
Write-Host "<result>"
"<channel>Transfer Time</channel>"
"<value>"+ $time.ToString("ss\.fffff") +"</value>"
"<Unit>TimeSeconds</Unit>"
"<Float>1</Float>"
"</result>"
"<text>OK</text>"
Write-Host "</prtg>"

Sep, 2018 - Permalink