Skip to content

Commit

Permalink
UPTIME!!!
Browse files Browse the repository at this point in the history
  • Loading branch information
Donatello-Carboni committed Sep 29, 2024
1 parent 6f223d7 commit b55427a
Showing 1 changed file with 24 additions and 29 deletions.
53 changes: 24 additions & 29 deletions stressTest.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,35 +99,30 @@
# print(f"Number of functions: {len(functions)}")


import json
from datetime import datetime
import requests

def get_uptime():
url = "https://api.uptimerobot.com/v2/getMonitors"

payload = "api_key=m797755729-8a15e04da92d199157c69016"
headers = {
'content-type': "application/x-www-form-urlencoded",
'cache-control': "no-cache"
}

response = requests.request("POST", url, data=payload, headers=headers)
# Your API Token
API_TOKEN = 'F4UDuW3PnVe2oT3FuffE'
TEST_ID = '7346731' # Replace with your actual test ID

# Set the URL for the API endpoint
url = f'https://api.statuscake.com/v1/uptime/{TEST_ID}'

# Set the headers with the Authorization token
headers = {
'Authorization': f'Bearer {API_TOKEN}',
'Accept': 'application/json' # Optional, ensures you get JSON response
}

# Make the GET request
response = requests.get(url, headers=headers)

# Check if the request was successful
if response.status_code == 200:
data = response.json()

if data['stat'] == 'ok':
monitors = data['monitors']
for monitor in monitors:
name = monitor['friendly_name']
uptime_ratio = monitor['all_time_uptime_ratio']
status = monitor['status']

print(f"Monitor: {name}")
print(f"Uptime: {uptime_ratio}%")
print(f"Status: {'Up' if status == 2 else 'Down'}")
print("---")
else:
print("Failed to retrieve monitor data")

if __name__ == "__main__":
get_uptime()
uptime = data['data']['uptime']
print(f"Uptime: {uptime}")
else:
print(f"Failed to retrieve data. Status code: {response.status_code}")
print(response.text)

0 comments on commit b55427a

Please sign in to comment.