|
47 | 47 |
|
48 | 48 | filename = sys.argv[0] # Sets a variable for the script name
|
49 | 49 | logdir = os.getenv("logs") # Set the variable logdir by getting the OS environment logs
|
50 |
| -logfile = 'ping_'+appgroup+'_'+site+'.log' # Set the variable logfile, using the arguments passed to create the logfile |
51 |
| -logfilename=os.path.join(logdir, logfile) # Set the variable logfilename by joining logdir and logfile together |
| 50 | +logfile = 'ping_' + appgroup + '_' + site + '.log' # Set the variable logfile, using the arguments passed to create the logfile |
| 51 | +logfilename = os.path.join(logdir, logfile) # Set the variable logfilename by joining logdir and logfile together |
52 | 52 | confdir = os.getenv("my_config") # Set the variable confdir from the OS environment variable - 1.2
|
53 |
| -conffile = (appgroup+'_servers_'+site+'.txt') # Set the variable conffile - 1.2 |
54 |
| -conffilename=os.path.join(confdir, conffile) # Set the variable conffilename by joining confdir and conffile together - 1.2 |
| 53 | +conffile = (appgroup + '_servers_' + site + '.txt') # Set the variable conffile - 1.2 |
| 54 | +conffilename = os.path.join(confdir, conffile) # Set the variable conffilename by joining confdir and conffile together - 1.2 |
55 | 55 |
|
56 | 56 | f = open(logfilename, "w") # Open a logfile to write out the output
|
57 | 57 | for server in open(conffilename): # Open the config file and read each line - 1.2
|
58 |
| - ret = subprocess.call(myping + server, shell=True,stdout=f,stderr=subprocess.STDOUT) # Run the ping command for each server in the list. |
| 58 | + ret = subprocess.call(myping + server, shell=True, stdout=f, stderr=subprocess.STDOUT) # Run the ping command for each server in the list. |
59 | 59 | if ret == 0: # Depending on the response
|
60 | 60 | f.write (server.strip() + " is alive" + "\n") # Write out that you can receive a reponse
|
61 | 61 | else:
|
62 | 62 | f.write (server.strip() + " did not respond" + "\n") # Write out you can't reach the box
|
63 | 63 |
|
64 |
| -print ("\n\tYou can see the results in the logfile : "+ logfilename); # Show the location of the logfile |
| 64 | +print ("\n\tYou can see the results in the logfile : " + logfilename); # Show the location of the logfile |
0 commit comments