Hey i have made a little tool for ping any website / ip in python.
So my bot works find but i wan't to add a feature for get the average.
My code below :
import os, time, requests
url = 'WEBHOOK URL'
while True:
hostname = "google.com"
response = os.system("ping -c 1 " + hostname)
if response == 0:
print (hostname, 'is online!')
data = {
"content" : "Message content",
"username" : "Author name"
}
data["embeds"] = [
{
"description" : "Google is onligne",
"title" : "TITLE EMBEDS"
}
]
requests.post(url, json = data)
time.sleep(900)
else:
data = {
"content" : "Message content",
"username" : "Author name"
}
data["embeds"] = [
{
"description" : "Google is offligne",
"title" : "TITTLE EMBEDS"
}
]
requests.post(url, json = data)
print (hostname, 'is down!')
time.sleep(900)
This code works very nice, but i wanna to complete my code with getting the average speed like :
with someting like this :
Average speed is result of ping.
When i do this :
print (response)
i get :
0
I wan't to get something like :
Average = 49ms
But i don't know how to do this...
Thanks for you're help
PROBLEM FIXED WITH PYTHONPING