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

PRTG Custom Sensor - Keep running into JSON or XML does not match

Votes:

0

Hello,

I hope someone might be able to spot what is going wrong or encountered a similar issue. I have a powershell script that I use to output JSON, but I've also tried XML. Regardless of what I'm using it keeps giving the error: XML: The returned XML does not match the expected schema. (code: PE233) -- JSON: The returned JSON does not match the expected structure (Invalid JSON.). (code: PE231).

I'm at a loss as to what's happening or what I'm missing. I even tried copy pasting the simple examples from the websites and the KB to see if those would work. They do not. So clearly something is happening. One of the first things I've checked is to make sure I'm using spaces in JSON and not tabs. I also it through Visual Studio Code to see if any mistakes/problems were detected. There is no other output being generated besides the write-output statement.

Is there a logfile that I can check to get a more accurate indication of the error?

Here's the JSON Powershell output snippet:

Write-Output @"
{
    "prtg": {
        "result": [
            {
                "channel": "70th",
                "value": "$70",
                "float": "1",
                "unit": "msec"
            },
            {
                "channel": "80th",
                "value": "$80",
                "float": "1",
                "unit": "msec"
            }
        ]
    }
}
"@

Execution from Powershell:

PS C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\EXEXML> .\test.ps1
{
    "prtg": {
        "result": [
            {
                "channel": "70th",
                "value": "",
                "float": "1",
                "unit": "msec"
            },
            {
                "channel": "80th",
                "value": "9.50417999999998",
                "float": "1",
                "unit": "msec"
            }
        ]
    }
}

The same error occurs when I use this simple example:

{
    "prtg": {
        "result": [
            {
                "channel": "First channel",
                "value": 10
            },
            {
                "channel": "Second channel",
                "value": 20
            }
        ]
    }
}

custom json prtg xml

Created on Aug 9, 2022 12:38:30 PM



1 Reply

Votes:

2

I have found the issue. The script was running into an error due to the sourcing of another powershell script. This was causing extra output. The error with sourcing was caused by permissions and the context from which PRTG ran the script.

Created on Aug 11, 2022 10:11:47 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.