File tree Expand file tree Collapse file tree 2 files changed +40
-0
lines changed
Expand file tree Collapse file tree 2 files changed +40
-0
lines changed Original file line number Diff line number Diff line change 1+ import ping3
2+ import time
3+
4+ def ping_servers (server_list ):
5+ while True :
6+ for server in server_list :
7+ response_time = ping3 .ping (server )
8+ if response_time is not None :
9+ print (f"{ server } is up (Response Time: { response_time } ms)" )
10+ else :
11+ print (f"{ server } is down! ALERT!" )
12+
13+ time .sleep (60 ) # Ping every 60 seconds
14+
15+ if __name__ == "__main__" :
16+ servers_to_monitor = ["google.com" , "example.com" , "localhost" ]
17+
18+ print ("Network Monitoring Script" )
19+ print ("Press Ctrl+C to stop monitoring" )
20+
21+ try :
22+ ping_servers (servers_to_monitor )
23+ except KeyboardInterrupt :
24+ print ("\n Monitoring stopped." )
Original file line number Diff line number Diff line change 1+ # Network_Monitor
2+
3+ Short description of package/script
4+
5+ - This Script Was simple to setup
6+ - Need import ping3
7+
8+
9+ ## Setup instructions
10+
11+
12+ Just Need to run this command "pip install ping3" then run the Network_Monitor.py file and for running python3 is must be installed!
13+
14+ ## Detailed explanation of script, if needed
15+
16+ This Script Is Only for Network_Monitoring use only!
You can’t perform that action at this time.
0 commit comments