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

Cusotom sensor permanently throws errors (PE231)

Votes:

0

A powershell script in PRTG is permanently throwing the following exception:

XML: Das zurückgelieferte XML entspricht nicht dem erwarteten Schema. (Code: PE233) -- JSON: Das zurückgelieferte JSON entspricht nicht der erwarteten Struktur (No mapping for the Unicode character exists in the target multi-byte code page). (Code: PE231) indication, that some unicode is used, which is not.

The output of the script, run on the console, is this:

<prtg>
<result>
<channel>
Strom Phase A1
</channel>
<value>
1,54
</value>
<FLOAT>1</FLOAT>
<CustomUnit>A</CustomUnit>
</result>
<result>
<channel>
Strom Phase A2
</channel>
<value>
3,48
</value>
<FLOAT>1</FLOAT>
<CustomUnit>A</CustomUnit>
</result>
<result>
<channel>
Strom Phase A3
</channel>
<value>
2,06
</value>
<FLOAT>1</FLOAT>
<CustomUnit>A</CustomUnit>
</result>
<result>
<channel>
Strom Phase B1
</channel>
<value>
0
</value>
<FLOAT>1</FLOAT>
<CustomUnit>A</CustomUnit>
</result>
<result>
<channel>
Strom Phase B2
</channel>
<value>
0
</value>
<FLOAT>1</FLOAT>
<CustomUnit>A</CustomUnit>
</result>
<result>
<channel>
Strom Phase B3
</channel>
<value>
0
</value>
<FLOAT>1</FLOAT>
<CustomUnit>A</CustomUnit>
</result>
</prtg>

and the underlying scriptcode is that:

"<prtg>"
    "<result>"
        "<channel>"
            "Strom Phase A1"
        "</channel>"
        "<value>"
            echo $result0
        "</value>"
        "<FLOAT>1</FLOAT>"
        "<CustomUnit>A</CustomUnit>"
    "</result>"
    "<result>"
        "<channel>"
            "Strom Phase A2"
        "</channel>"
        "<value>"
            echo $result1
        "</value>"
        "<FLOAT>1</FLOAT>"
        "<CustomUnit>A</CustomUnit>"
    "</result>"
    "<result>"
        "<channel>"
            "Strom Phase A3"
        "</channel>"
        "<value>"
            echo $result2
        "</value>"
        "<FLOAT>1</FLOAT>"
        "<CustomUnit>A</CustomUnit>"
    "</result>"
        "<result>"
        "<channel>"
            "Strom Phase B1"
        "</channel>"
        "<value>"
            echo $result3
        "</value>"
        "<FLOAT>1</FLOAT>"
        "<CustomUnit>A</CustomUnit>"
    "</result>"
        "<result>"
        "<channel>"
            "Strom Phase B2"
        "</channel>"
        "<value>"
            echo $result3
        "</value>"
        "<FLOAT>1</FLOAT>"
        "<CustomUnit>A</CustomUnit>"
    "</result>"
        "<result>"
        "<channel>"
            "Strom Phase B3"
        "</channel>"
        "<value>"
            echo $result5
        "</value>"
        "<FLOAT>1</FLOAT>"
        "<CustomUnit>A</CustomUnit>"
    "</result>"
"</prtg>"

When debugging the sensor, it writes a 514byte File containing (my guess) only whitespaces.

Any idea?

custom-sensor exe-xml powershell

Created on Jun 2, 2015 6:06:45 PM



10 Replies

Votes:

5

Hi Andreas,

When the script is run as a sensor on your PRTG server it most likely returns a different output than the one you expect.

If the script output is some kind of error (e.g. when PowerShell execution is not enabled on your PRTG server) the output will not be in the desired format.

Created on Jun 3, 2015 7:19:04 AM



Votes:

0

Unfortunately, this cant be the case, because other Ps scripts are working well on the probesystem and executionpolicy is set to unrestricted.

However, which powershellversion does prtg invoke to run ps scripts and can this be altered or configured?

Created on Jun 3, 2015 8:42:19 AM



Votes:

0

Just to make sure,

You added this scipt to the 'Custom Sensors/EXEXML' folder of your PRTG installation and added it as a 'EXE/Script Advanced' sensor?

Created on Jun 3, 2015 10:40:52 AM



Votes:

0

yes,, on the core server as on the probes.

Created on Jun 3, 2015 11:21:37 AM



Votes:

0

Did you alrerady try the 'Write EXE result to disk' option in the sensor settings? That should give you a clear view of what the sensor really reports to PRTG.

Created on Jun 3, 2015 11:52:55 AM



Votes:

0

Of course I did ;-), thats what makes me finally confused, as described in the inital post, the debugging output results in a 514 byte file which contains (my guess) only whitespaces (tabs, blanks - nothing I could read or identify). If there where a prob with powershell, it should contain the errormessages the powershell gives back, if there were a problem with the output itself, it should simply be empty or not written at all. So the task is executed, something happens and after writing the sensordebuginfo we have a 514byte "empty" file. So relating to the error given by PRTG, the error is correct, if the malformed, whitespacefilled file represents the return of the exe-sensore, it really has noting in it PRTG could evaluate.

Anyway, the question is why an where did this "shit" happen. Running the same script locally gives correct results in really pretty plan asci-code, no coding oder unicode rubish, pretty< strait ascii....

Oh to mention, if someone might ask: running PRTG on two installations with various probes in the most curren stable versiion...100% same behavior on all servers and probes...

any help ist really apprichiated ;-) tnx

Created on Jun 3, 2015 2:40:16 PM



Votes:

0

Try wrapping your output to something like this:

Write-Host @"
your output goes here
"@

The output from the first post works just fine with PRTG, just tested within my local installation :)

Created on Jun 5, 2015 8:19:33 AM by  Stephan Linke [Paessler Support]



Votes:

0

Thanks Stephan, the wrapping did the trick, at least partially.

Wrapping

Yes the wrapping is a goot idea, and works.

Powershell 3/4 support

After another round of investigation (implementing the wrapping) I ran into timeouts. While investigating this, I found out, taht IMHO functions related to PowerShel v3 or v4 are not working with PRTG (at least the funktion I tried). After a fallback to an implementations which uses only PS v2 commands, it works well. IMHO this should be investigated by th PRTG team.

You can find the resulting sensor under:Topic 28123 - Support for Allnet devices

Tweaks on the devicename

As we are using the %device parameter to tell our script which machine to query, we ran in another litte trouble. It turns out that with the %device parameter the given name of the device is passed an not the dnsname. Don t know if this is intended by desing. IMHO the %device parameter should pass the dns-name. Maybe another issue the PRTG Team should investigate.

After all tnx to all people for helping!

Created on Jun 5, 2015 10:43:28 AM



Votes:

0

Just a little followup, to correct my statement concerning powershell v3 and v4. To clarify, Powershell v3 an v4 in gerneral works, but there is IMHO a problem with the Invoke-WebRequest method which came with Powershell v3. On the other hand, the ConvertFrom-JSON,also introduced with PS v3 works pretty well.

Created on Jun 5, 2015 12:55:57 PM



Votes:

0

if you write at the end exit 0 it works

Created on Feb 19, 2020 9:21:50 AM




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.