Good evening everyone,

I need to retrieve a large amount of sensors (and their channels) with one API request and return the whole list in JSON or XML. Unfortunately I can't seem to get any further than either having all the sensors values without the channel data, or the channel data but then it is only for a single sensor.

It is not feasible due to the total amount of sensors to perform a API call for each one of them because that would take too long (and create an asynchronous mess)

How can this be done ... and please don't tell me it cant :-)

Thanks Michaël


Article Comments

Hello Michaël,
thank you for your KB-Post/Inquiry.

Unfortunately I don't really have good news. Most API calls will only contain the value of a sensor's primary channel.

If you need all channels, you need to work with /api/table.xml?content=channels, in which case a sensor ID must be specified/supplied (for instance: &id=1234)

Best Regards,
Luciano Lingnau [Paessler Support]


Oct, 2018 - Permalink

Hi Luciano,

Unfortunately then in this case I would have to iterate through all sensors with individual /api/table.xml?content=channels&id=n requests which is not workable due to the delay it would create in rendering the data.

What is the structure of the data files you use (as you don't us any rdbms for this purpose), then I can maybe write my own api extension.

Thanks
Michaël


Oct, 2018 - Permalink

Hello Michaël,
thank you for your reply.

Would you mind elaborating about what exactly you're trying to achieve? Why exactly do you want to get all live sensor data out of PRTG? What do you want to do with it?

But yes, I agree that iterating trough every possible sensor in your installation o get the live data for each channel from every sensor could take a while.

Depending on what you're trying to achieve, the following may save you some work:

However, direct access to the data files is not an option, they are binary-encoded in a proprietary format. The API is the only available interface with the data.

Best Regards,
Luciano Lingnau [Paessler Support]


Oct, 2018 - Permalink

Any chance that PAESSLER has added the ability to pull all Channels from the API instead of per sensor?


Apr, 2022 - Permalink

Hello uramirez_074,
thank you for your inquiry.

While we don't plan to make any major changes to the existing PRTG API, we're working on a new API that is being built from the ground up to be more flexible and user-friendly. While it is far from being production ready, this is the API that we'll be extending and maintaining in the future. I encourage you to have a look at the following:

While the new API v2 is far from being complete, as per the API Reference you should already be able to issue a /api/v2/sensors?offset=0&limit=100&include_all_channels=true and this would include all channels for every sensor in the result.

However, it's very important to keep in mind that the API v2 in it's current state is still an Alpha version and breaking changes (as well as bugs) might still be common in this phase. You can read more about it in the links above.

Best Regards,
Luciano Lingnau [Paessler]


Apr, 2022 - Permalink