Hey guys,
i want to integrate a solar-logging device into my prtg monitor. This device provides data with JSON with HTTP Post Request.
Actually im not able to show this data via browser. But i get the data with using curl in windows command line.
##############################
Device manual says:
The actually data you can get with a HTTP Post Request. The requestet Object has to be in body:
POST /getjp HTTP/1.1 Host: 192.168.1.10 (IP-Adress of the device) ... Content-Length: 20 Connection: keep-alive Pragma: no-cache Cache-Control: no-cache {„801“:{„170“:null}}
The answer should show a JSON-Objekt as String in Body:
HTTP/1.1 200 OK Date: Mon, 31 Mar 2014 10:42:32 GMT Server: IPC@CHIP Content-Type: text/plain Transfer-Encoding: chunked {„801“:{„170“:{„100“:“31.03.14 10:42:15“,“101“:0,“102“:0,“103“:0,“104“:0,“105“:0,“106“:0,“107“:3527647, “108“:0,“109“:0,“110“:0,“111“:0,“112“:0,“113“:1132434,“114“:0,“115“:0,“116“:45000}}}
##############################
So i tested different Sensors with PRTG but none ofe them worked. With windows cmd using curl i get the relevant data without problems. this is the key iam using:
curl -X POST -H "Content-Type: application/json" -d '{\"801\":{\"170\":null}}' 192.168.1.10/getjp |
And this is the answer i get:
{"801":{"170":{"100":"11.02.19 07:42:35","101":0,"102":0,"103":0,"104":0,"105":0,"106":22679,"107":631999,"108":1618447,"109":426525009,"110":0,"111":0,"112":0,"113":0,"114":0,"115":0,"116":82095}}}
So the question is how to get this data into PRTG. Whats the correct Sensor to do this und how to configure the sensor correctly. Can you help me please?
Article Comments
Hi,
yes i already tried the Rest Custom Sensor.
So now i did this again with following settings:
Request Method - POST Post-Data: POST /getjp HTTP/1.1 Host: 192.168.1.10 (IP-Adress of the device) ... Content-Length: 20 Connection: keep-alive Pragma: no-cache Cache-Control: no-cache {„801“:{„170“:null}}
Protocol is set to http
no Authentication
no own http-header
With REST Request i tried different parameters.
With /getjp?{„801“:{„170“:null}} i think iam close to a solution but there is still a mistake in syntax i think, but i dont now what it is. I get this failure:
Cannot parse content from entdpoint http://192.168.1.10/getjp?{„801“:{„170“:null}}: invalid character '{' looking for beginning of object key string body: {{"QUERY IMPOSSIBLE 000"}}.
With /getjp?[„801“:[„170“:null]] i get this failure:
Cannot parse content from entdpoint http://192.168.1.10/getjp?[„801“:[„170“:null]]: no data.
Opening http://192.168.1.10/getjp?{"801":{"170":null}} get me this message in browser:
{{"QUERY IMPOSSIBLE 000"}}
But as i wrote curl works fine.
Feb, 2019 - Permalink
Hi there,
Is there any reason you submit the POST Data in the URL? Usually it should look like this, URL:
http://192.168.1.10/getjp? |
POST Data:
[„801“:[„170“:null]] |
Or:
{„801“:{„170“:null}} |
Best regards.
Feb, 2019 - Permalink
Hi there!
Opening http://192.168.1.10/getjp?{„801“:{„170“:null}} is also showing me Bad Image src.
So i tried different parameters with and without using Post with different PRTG sensores belonging to JSON, XML and REST but all with bad luck. The only thing with worked is the curl. Any suggetions the compile this to use it with PRTG?
So far i dont have a HTTP Request witch replies the data.
Using { or [ gaves no different to the outputs.
Feb, 2019 - Permalink
Hi there,
As mentioned, using this URL is not the correct format. You can't put the body of a POST request into the requested URL. In regards of the sensor settings, this should help you:
- Request Method: POST
- Postdata:
{"801":{"170":null}} |
- HTTP Headers: Use custom HTTP headers
- Custom HTTP Headers:
Content-Type: application/json |
- REST Query: /getjp
Afterwards the REST Custom Sensor should be able to request the data.
Best regards.
Feb, 2019 - Permalink
Hi,
so i solved my problem using the script sensor which runs the relevant powershell skript returning variables. Thanks!
Feb, 2019 - Permalink
Hi there,
Have you checked the REST Custom Sensor already?
https://www.paessler.com/manuals/prtg/rest_custom_sensor
This allows you to monitor JSON and XML APIs via defined templates that use JSON-Path. You can find some example templates on your Core Server under "C:\Program Files (x86)\PRTG Network Monitor\Custom Sensors\rest\". Additionally, please check the manual linked above where different functions are explained.
Best regards.
Feb, 2019 - Permalink