MCPcopy Index your code
hub / github.com/geekcomputers/Python / linux

Function linux

powerup_checks.py:62–78  ·  view source on GitHub ↗
()

Source from the content-addressed store, hash-verified

60
61
62def linux(): # This is the function to run if it detects the OS is nix.
63 f = open("server_startup_" + strftime("%Y-%m-%d") + ".log", "a") # Open the logfile
64 for server in open(serverfile, "r"): # Read the list of servers from the list
65 ret = subprocess.call(
66 "ping -c 3 %s" % server,
67 shell=True,
68 stdout=open("/dev/null", "w"),
69 stderr=subprocess.STDOUT,
70 ) # Ping the servers in turn
71 if ret == 0: # Depending on the response
72 f.write(
73 "%s: is alive" % server.strip().ljust(15) + "\n"
74 ) # Write out to the logfile is the server is up
75 else:
76 f.write(
77 "%s: did not respond" % server.strip().ljust(15) + "\n"
78 ) # Write to the logfile if the server is down
79
80
81def get_servers(query): # Function to get the servers from the database

Callers 1

mainFunction · 0.70

Calls

no outgoing calls

Tested by

no test coverage detected