RIPE-NCC / ripe-atlas-cousteau

Python client for RIPE ATLAS API
GNU General Public License v3.0
65 stars 26 forks source link

Cousteau does not support setting time intervals for measurements? #45

Closed SAWassermann closed 7 years ago

SAWassermann commented 7 years ago

Hi!

I would like to use Cousteau for launching periodic measurements for one week (every 30 minutes). However, I can't find a possibility to set the time interval between my measurements. When launching my measurements, they are indeed launched for one week, but with the default time interval between them (so 240 seconds / 900 seconds).

My code looks as follows

for IP in SERVER_IPS:
    pings.append(Ping(af=4, target=IP, description=MEASUREMENT_DESCRIPTION))
    traceroutes.append(Traceroute(af=4, target=IP, protocol='ICMP', description=MEASUREMENT_DESCRIPTION))
atlas_request = AtlasCreateRequest(start_time=datetime.strptime('24 Feb 2017 17:00:00', '%d %b %Y %H:%M:%S'),
                                   stop_time=datetime.strptime('03 March 2017 17:00:00', '%d %B %Y %H:%M:%S'),
                                   key=API_KEY, measurements=pings + traceroutes,sources=[PROBES])
(is_success, response) = atlas_request.create()

I unfortunately didn't find any argument for AtlasCreateRequest() that allows setting the interval to a custom value. Maybe I have missed something in the documentation?

If this functionality is not yet implemented, it would be great to be able to call

atlas_request = AtlasCreateRequest(start_time=datetime.strptime('24 Feb 2017 17:00:00', '%d %b %Y %H:%M:%S'),
                                   stop_time=datetime.strptime('03 March 2017 17:00:00', '%d %B %Y %H:%M:%S'),
                                   interval=1800,
                                   key=API_KEY, measurements=pings + traceroutes,sources=[PROBES])
(is_success, response) = atlas_request.create()

to launch measurements every 30 minutes for the week from 24.02 until 3.3.

Woutifier commented 7 years ago

Hi @SAWassermann,

The interval is a property of the actual measurement and not of the request itself (unlike the start and stop datetime).

In your case:

for IP in SERVER_IPS:
    pings.append(Ping(af=4, target=IP, description=MEASUREMENT_DESCRIPTION, interval=1800))
    traceroutes.append(Traceroute(af=4, target=IP, protocol='ICMP', description=MEASUREMENT_DESCRIPTION, interval=1800))
atlas_request = AtlasCreateRequest(start_time=datetime.strptime('24 Feb 2017 17:00:00', '%d %b %Y %H:%M:%S'),
                                   stop_time=datetime.strptime('03 March 2017 17:00:00', '%d %B %Y %H:%M:%S'),
                                   key=API_KEY, measurements=pings + traceroutes,sources=[PROBES])
(is_success, response) = atlas_request.create()

Good luck! :-)

SAWassermann commented 7 years ago

Thanks @Woutifier for your help :) !