import subprocess
def main():
host = input("Enter Host: ")
packet = int(input("
Enter Packet: "))
print("
")
ping = subprocess.getoutput(f"ping -w {packet} {host}")
print(ping)
main()
from pythonping import ping
def ping_host(host):
ping_result = ping(target=host, count=10, timeout=2)
return {
'host': host,
'avg_latency': ping_result.rtt_avg_ms,
'min_latency': ping_result.rtt_min_ms,
'max_latency': ping_result.rtt_max_ms,
'packet_loss': ping_result.packet_loss
}
hosts = [
'192.168.48.1',
'192.168.48.135'
]
for host in hosts:
print(ping_host(host))
st = Speedtest()
print("Download:=>", st.download())
print("upload:=>", st.upload())
st.get_servers([])
print("Ping :=>", st.results.ping)