This is a question about creating sensors via the API. After cloning a Http Push Advanced sensor it is paused, so we then un-pause the sensor. The sensor is inactive for a time, so we poll the server until 'Matching Sensors=1', indicating the sensor is active and ready to receive data.
Sometimes, however, the newly created sensor is paused (probably the unpause command failed) and therefore the process fails.
The problem is that between the time the sensor is unpaused (which happens immediately after cloning) and the time the sensor becomes active (which is about 45 seconds) the code currently cannot tell whether the sensor is unpaused & inactive, or paused & inactive.
How can we check via the API if a newly cloned sensor that isn't yet active has successfully been unpaused? I.e. is there a status available via API for sensors that will indicate each of active status and paused status?
Hope all this makes sense, Paul
Article Comments
The only check we perform is to see whether the sensor is ready for accepting data:
http://prtghost:5050/sensor_token_string
The response is json:
{ "status": "Ok", "Matching Sensors": "0" }
We keep polling the server with this request until "Matching Sensors" = "1"
What is the API call to get status code?
As for reproducing, we will do some more testing and let you know if it is reproducible or maybe just a developer machine glitch.
Paul.
Sep, 2016 - Permalink
Dear Paul
This method you are using provides the readable sensor status. It is also possible to get the raw status code. For an example sensor ID 2123, the core API call looks like
/api/getsensordetails.json?id=2123
The property "statusid" contains the aforementioned numeric status code.
Sep, 2016 - Permalink
Dear Paul
Which API call are you using to extract the sensor status? In principle, you can detect the current status:
However, the unpause command should not fail. Can you reproduce that or tie it to a general PRTG overload? Would it be an option to send the unpause API call several times?
Sep, 2016 - Permalink