Exemple #1
0
def stop_exp(msm_id_list):
    for measurement_id in msm_id_list:

        atlas_request = AtlasStopRequest(msm_id = measurement_id, key = "fbae8ef7-d73e-413a-af8e-9d709dcc1148")

        (is_success, response) = atlas_request.create()
        print is_success
        print response
Exemple #2
0
def stop_exp(msm_id_list, stop_file):
    with open(stop_file, 'w') as f_stop:
        for measurement_id in msm_id_list:

            atlas_request = AtlasStopRequest(msm_id = measurement_id, key = "fbae8ef7-d73e-413a-af8e-9d709dcc1148")

            (is_success, response) = atlas_request.create()
            if is_success:
                f_stop.write(str(measurement_id) + '\n')
            print is_success
            print response
Exemple #3
0
def main(date, version, probes, asns, repetition, concurrent, description,
         protocol, packets, first_hop, max_hops, paris, bill_to, api_key):
    # define the date and db

    # create empty DataFrame for API-Responses
    measurements = pd.DataFrame()

    # create 100 measurements (limit for concurrent measurements)
    # until every target was selected
    for x in range(0, int(repetition*len(asns)/concurrent)+1):
        for y in range(0, concurrent):
            # check if end of list is reached
            if (y+x*concurrent)/repetition < len(asns):
                # create measurement
                execute_POST_req.main(
                    str(asns['ipv' + str(version)][int(
                        (y+x*concurrent)/repetition)]),
                    len(probes), ",".join(map(str, probes['id'])), version,
                    description, protocol, packets, first_hop, max_hops,
                    paris, bill_to, api_key)
                # read the API-Response into the DataFrame
                apiResponse = pd.read_json('ripeApiResponse.txt')
                if 'measurements' in apiResponse:
                    measurements = measurements.append(apiResponse,
                                                       ignore_index=True,
                                                       sort=True)
            else:
                break

        # wait until measurements are done and stop them to safe RIPE-credits
        # and write them into the db
        time.sleep(1800)
        for x in range(0, len(measurements)):
            # stop measurement
            atlas_request = AtlasStopRequest(msm_id=measurements[
                'measurements'][x], key=api_key, proxies=dict(
                https='socks5://localhost:8080'))
            (is_success, response) = atlas_request.create()

        # pass measurement ids to the script to save them to the db
        Thread(target=measurement_to_db.main,
               args=(date, measurements)).start()

        # empty DataFrame to prevent redundancy
        measurements = pd.DataFrame()
Exemple #4
0
def stop_measurements(monitoring_goal, query_type):
    """Stops running RIPE Atlas measurements."""

    msm_ids, msm_attributes = database.get_measurements(
        monitoring_goal, query_type, True)
    success_counter = 0

    for msm_id in msm_ids:
        atlas_request = AtlasStopRequest(msm_id=msm_id,
                                         key=config['RIPE']['api_key'])

        is_success, response = atlas_request.create()
        # print(is_success, response)
        if is_success:
            database.stop_measurement(msm_id)
            success_counter += 1

    if success_counter == len(msm_ids):
        return True
    else:
        return False
Exemple #5
0
import glob
import json
from ripe.atlas.cousteau import AtlasStopRequest
#code mesurements 1
ATLAS_STOP_API_KEY = ""

failed_measurements = list()

for filepath in glob.iglob('measurements/*.json'):
    with open(filepath) as f:
        data = json.load(f)
    for k, v in data.items():
        for elt in v:
            try:
                for measurement in elt['measurement_id']:
                    atlas_request = AtlasStopRequest(msm_id=measurement,
                                                     key=ATLAS_STOP_API_KEY)
                    (is_success, response) = atlas_request.create()
                    if not is_success:
                        failed_measurements.append(measurement)
            except KeyError:
                pass

with open('measurements-failed-to-stop.txt', 'w') as file:
    for elt in failed_measurements:
        file.write("%i\n" % elt)
def atlas_api_stop_call(msm_id_var):
    #ATLAS_STOP_API_KEY = ""

    atlas_request = AtlasStopRequest(msm_id=msm_id_var, key=ATLAS_STOP_API_KEY)

    (is_success, response) = atlas_request.create()