Last active
December 12, 2019 23:53
-
-
Save chriselsen/1d548194428048d0e65ce9760511efb5 to your computer and use it in GitHub Desktop.
Python Script to analyze RIPE Atlas measurement result
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python3 | |
import requests | |
from ripe.atlas.sagan import Result | |
from ripe.atlas.cousteau import Probe | |
source = "https://atlas.ripe.net/api/v2/measurements/23515276/latest/?format=json" | |
response = requests.get(source).json() | |
for result in response: | |
parsed_result = Result.get(result) | |
probe = Probe(id=parsed_result.probe_id) | |
probe_country = probe.country_code | |
probe_id = parsed_result.probe_id | |
try: | |
probe_result = parsed_result.responses[0].abuf.answers[0].address | |
except: | |
probe_result = "None" | |
status = "Not OK <====" | |
if (probe_country == "CN" and probe_result == "127.0.0.1"): | |
status = "OK" | |
if (probe_country != "CN" and probe_result == "1.2.3.4"): | |
status = "OK" | |
if (probe_result == "None"): | |
status = "Unknown" | |
print(probe_country + ": " + str(probe_id) + ": " + probe_result + ": " + status) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment