| 36 | |
| 37 | |
| 38 | def linux(): |
| 39 | f = open("server_startup_" + strftime("%Y-%m-%d") + ".log", "a") # Open the logfile |
| 40 | for server in open("startup_list.txt"): # Read the list of servers from the list |
| 41 | ret = subprocess.call( |
| 42 | "ping -c 3 %s" % server, |
| 43 | shell=True, |
| 44 | stdout=open("/dev/null", "w"), |
| 45 | stderr=subprocess.STDOUT, |
| 46 | ) # Ping the servers in turn |
| 47 | if ret == 0: # If you get a response. |
| 48 | f.write("%s: is alive" % server.strip() + "\n") # Print a message |
| 49 | subprocess.Popen(["ssh", server.strip()]) |
| 50 | else: |
| 51 | f.write("%s: did not respond" % server.strip() + "\n") |
| 52 | |
| 53 | |
| 54 | # End of the functions |