I have a list of IP addresses and I am pinging them all and getting the result, now from here based on whether IP is up/down as 1/0, I want to store that data into an HTML table. I want to ping each IP address 24 times at an interval of 1 hour. How can I ping at an interval of 1 hour for 24 times and based on the result, how can I create an HTML table? The HTML table should have 2 columns. First is IP address name and second is total no of up connection. Like if the IP address is UP for all the 24 times, the count should show 24 on HTML table.
This for python 3+ version. I have created a .txt file in which I have stored all the IP addresses. I am opening that file and pinging each IP address one by one and that is successfully working. Now from here onwards I have no idea how to approach.
import os
import time
with open('ping.txt') as file:
sw = file.read()
sw = sw.splitlines()
for ip in sw:
os.system('cls')
print('\n\nPinging now:' , ip)
response = os.system("ping -n 3 {}".format(ip))
if response == 0:
print(ip, 'is good!')
else:
print(ip, 'is bad!')
print('-'*50)
The expected output should be an HTML table with 2 columns. One is IP address details and other is the total number of successful counts. Ex,
IP ADDRESS Count
192.12.12.1 23