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

Service providing sensordata in json format

Votes:

0

We have a service that outputs a set of monitoring data (channels) in json or xml format. What is the most efficient way of getting these data into PRTG? Do I have to use one sensor per channel - or is it possible to use one sensor per group?

Sample JSON:
{
 "general": {
  "Exceptions": "0"
 },
 "tcp": {
  "TCPTelegramsIn": "0",
  "TCPTelegramsOut": "0",
  "TCPResponseTime": "0",
  "TCPErrors": "0",
  "TCPConnects": "0",
  "TCPDisconnects": "0",
  "TCPTelegramsInCL": "9.49940747546472E-43",
  "TCPTelegramsOutCL": "0",
  "TCPResponseTimeCL": "0",
  "TCPErrorsCL": "0",
  "TCPConnectsCL": "0",
  "TCPDisconnectsCL": "0"
 },
 "notifications": {
  "NotificationsIn": "0",
  "NotificationsOut": "0"
 },
 "m3api": {
  "M3APICalls": "2.06414875439106E-9",
  "M3APIErrors": "0",
  "M3APIResultCounts": "0",
  "M3APIResponseTime": "8.57911826043786E-8"
 },
 "db": {
  "DBReads": "8401.19020875096",
  "DBWrites": "4828.46466000697",
  "DBErrors": "0"
 },
 "data": {
  "PSDOrders": "0",
  "PSDMoveOrders": "0",
  "PSDPickOrders": "0"
 }
}


[edit] I just wrapped the json code so it's readable

json prtg sensor

Created on Jun 10, 2015 7:45:28 AM

Last change on Jun 10, 2015 8:29:41 AM by  Stephan Linke [Paessler Support]



7 Replies

Votes:

0

The best way to get this into PRTG is via the EXE/Script (Advanced) sensor. Create a PowerShell script that creates an object from the JSON response (using ConvertFrom-JSON) and put the values into their corresponding channels.

Edit On the other hand, if you can modify the service to output the numeric values in brackets as a 3rd output option, you can use the HTTP content sensor. Whatever causes the least work for you :)

Created on Jun 10, 2015 8:30:35 AM by  Stephan Linke [Paessler Support]

Last change on Jun 10, 2015 8:36:48 AM by  Stephan Linke [Paessler Support]



Votes:

0

That would be nice - our service already provides the json data through http - adding another format would be trivial.

Could you make a "bracket example" based on my original sample, to clarify how it is done properly?

Created on Jun 10, 2015 8:50:52 AM



Votes:

0

Something like this:

Exceptions: [0]
TCPTelegramsIn: [0]
TCPTelegramsOut: [0] 
TCPResponseTime: [0] 
TCPErrors: [0] 
TCPConnects: [0] 
TCPDisconnects: [0] 
TCPTelegramsInCL: [9.49940747546472E-43] 
TCPTelegramsOutCL: [0] 
TCPResponseTimeCL: [0] 
TCPErrorsCL: [0] 
TCPConnectsCL: [0] 
TCPDisconnectsCL: [0] 
NotificationsIn: [0] 
NotificationsOut: [0] 
M3APICalls: [2.06414875439106E-9] 
M3APIErrors: [0] 
M3APIResultCounts: [0] 
M3APIResponseTime: [8.57911826043786E-8]
DBReads: [8401.19020875096] 
DBWrites: [4828.46466000697] 
DBErrors: [0] 
PSDOrders: [0] 
PSDMoveOrders: [0]
PSDPickOrders: [0]

The text is actually obligatory, PRTG only cares for what's within the brackets. They're put into channels automatically, the line number resembles the channel ID. Make sure to set the channel number during the creation of the sensor correctly, otherwise, the sensor will error (not enough values).

Created on Jun 10, 2015 9:31:55 AM by  Stephan Linke [Paessler Support]

Last change on Jun 11, 2015 6:35:26 AM by  Stephan Linke [Paessler Support]



Votes:

0

Thanks!

Just a thought: It would be nice if you made a proper JSON format specification which adds units and grouping. So much easier to develop towards a proper spec.

Created on Jun 10, 2015 11:52:15 AM



Votes:

0

Well the sensor is not designed specifically to work with JSON values, more for values on a website that need to be tracked. It should be rather easy to develop a PowerShell script that iterates through a given JSON response and creates the channels accordingly :)

Created on Jun 11, 2015 6:38:03 AM by  Stephan Linke [Paessler Support]



Votes:

0

Hi All,

What would be the case for a JSON output with an Array?

{
  "@count": 3,
  "@start": 1,
  "@totalcount": 3,
  "Messages": [],
  "ResourceName": "Incident",
  "ReturnCode": 0,
  "content": [
    {"Incident": {"IncidentID": "IM10231"}},
    {"Incident": {"IncidentID": "IM10258"}},
    {"Incident": {"IncidentID": "IM10261"}}
  ]
}

As the ConvertFrom-Json doesn't play nice with the JSON arrays. Output goes from above to:

@{
@count=3; 
@start=1; 
@totalcount=3; 
Messages=System.Object[]; 
ResourceName=Incident; 
ReturnCode=0; 
content=System.Object[]
}

Created on Jan 30, 2017 3:57:24 PM



Votes:

0

You can access them via $object.content[0].Incident.IncidentID :)

Created on Jan 31, 2017 9:18:19 AM by  Stephan Linke [Paessler Support]




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.