-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Now, you don't need to count on your own how many hosts you have. +Script optimizations. Special thanks to @ablaziak.
- Loading branch information
1 parent
8594d26
commit 97f9303
Showing
1 changed file
with
6 additions
and
7 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,16 +1,15 @@ | ||
import os | ||
numberOfHosts = 1 #Enter the number of hosts would you like to ping. | ||
Hosts = [] #Enter your hosts in the list. | ||
hosts = [""] #Enter your hosts in the list. | ||
print("Script for checking that servers are working.") | ||
print("Author: Julian Korgol.") | ||
print("https://juliankorgol.com/") | ||
n = 0 | ||
numberOfHosts = len(hosts) | ||
while n < numberOfHosts: | ||
answer = os.system("ping " +Hosts[n]) | ||
answer = os.system("ping " +hosts[n]) | ||
if answer == 0: | ||
print(Hosts[n] + "\033[92m" + " It's working!") | ||
n += 1 | ||
print(hosts[n] + "\033[92m" + " It's working!") | ||
else: | ||
print(Hosts[n] + "\033[91m" + " It's down!") | ||
n += 1 | ||
print(hosts[n] + "\033[91m" + " It's down!") | ||
n += 1 | ||
print("\033[0m") |