Hi there.
I'm trying to clone a HTTP Push Advanced sensor via API then push to it.
(note: username and password url parameters have been removed)
This is the clone via API:
/api/duplicateobject.htm?id=2094&name=new_sensor_name&targetid=2080
After clone I change sensor token:
/api/setobjectproperty.htm?id=2106&name=httppushtoken&value=new_token
Then resume (un-pause):
/api/pause.htm?id=2106&action=1
When I then attempt to push data to this sensor I receive:
{ "status": "Ok", "Matching Sensors": "0" }
I have noticed in my testing that if I wait for a few minutes then re-issue the push request it then succeeds. But waiting a few minutes in my code is undesirable.
What else do I need to do via API so that my new sensor can receive push?
Article Comments
I tried adding a sleep of 10s to my code after cloning the sensor but it did not resolve the issue - I still get Matching Sensors = 0 on that immediate push after creating the sensor.
I then increased the sleep time and eventually at 60s sleep after creating a sensor did I get successful data push. This does seem like an awfully long pause to put in my code!
Is there any way to trigger / force the port listener to come up?
If not, can you recommend and API method to poll the server to check the sensor listener is up? Ideally without pushing dummy data.
In case it's helpful, we are using version 16.2.23.3171
Aug, 2016 - Permalink
Is your sensor actually resumed? You can check the availability like this, in Powershell:
http://pastebin.com/raw/WwUhrGLP
If it works, the output will look something like this:
Name Value ---- ----- ReponseCode OK ResponseUri <your-url>:5050/A442C3E9-7C86-4F18-8CA4-A565AE4EB2C2 NewSensorID -1
If anything goes wrong:
[23.08.2016 10:12:37] error URL could not be called. Error: System.Net.WebException [23.08.2016 10:12:37] notes The connection with the remote host could not be established.
Hope that it's somewhat helpful :)
Aug, 2016 - Permalink
Yes - sensor is definitely resumed. I have implemented polling every 3 seconds and after about 45s the sensor becomes active and then my code successfully pushes the first data set. If there's any better way to do this I'd be grateful to hear from you. Thanks for your help to date.
Aug, 2016 - Permalink
You could try installing the latest version of PRTG, where it hopefully works faster :)
Aug, 2016 - Permalink
We now have the latest version installed but no change to our issue. After cloning and un-pause, the code attempts to send the first push repeatedly (every 6 seconds) until the response comes back with "Matching Sensors = 1". This consistently takes about 45s each time I run this test.
If I run your powershell script during the 45s I get a successful response so the sensor is alive. But it just isn't able to receive the first push until 45s later.
It appears that I can create a clone via the web UI and it is ready to accept data in less than 45s (maybe even immediately). So there must be a way to fix this.
Sep, 2016 - Permalink
Turns out that after a bit of fiddling, an initial scan of the sensor via /api/scannow.htm?id={new-id} after the sensor being resumed solves the problem:
[22.09.2016 09:23:56] information Starting sensor creation for Testing (GUID: 2f4826a3-4cd5-40c5-97c2-f4ad13c8264a) [22.09.2016 09:23:57] success Sensor created successfully. New sensor ID: 8205 [22.09.2016 09:23:57] success Sensor has been resumed. [22.09.2016 09:23:58] success Sensor is now accepting data (0.57s) [22.09.2016 09:23:58] information Starting sensor creation for Testing (GUID: 83b3a639-2a40-49e4-b5d7-be253055b6aa) [22.09.2016 09:23:58] success Sensor created successfully. New sensor ID: 8206 [22.09.2016 09:23:58] success Sensor has been resumed. [22.09.2016 09:24:00] success Sensor is now accepting data (0.731s)
Sep, 2016 - Permalink
You don't need to wait a few minutes, a few seconds (5-10) should be sufficient for the port listener to come up.
Aug, 2016 - Permalink