# ---------------------------------------------------- # watchXsiservers # # Bernard Lebel # August 2004 # # watchXsiservers is a little script that checks for the presence # of network locations, and sends an error in case the target path # is no longer inaccessible. # This is meant to watch over frequently accessed critical # shared ressources. # # # Installation # Put file into C:\PythonXX\Lib # Remove "_public" from file name # The script requires the easygui.py file to be installed # in the Lib directory. # # # Usage # Launch Python interpreter (ideally command line) # Run: # import watchXsiservers # # The script will run indefinitely until the command line # shell is closed, the script stopped, or the servers it # watches are no longer available. # # This script is written to watch two servers. # Feel free to modify it for your needs. # ---------------------------------------------------- # Import block import time import os import easygui # ---------------------------------------------------- # Add as many variable as you have network locations to watch bServer1 = True bServer2 = True while True: # Check if server 1 has to be tested if bServer1 == True: # Check if path on the network is still available # Replace path1 with the actual path to the folder if not os.path.exists( '\\\\path1' ): easygui.msgbox( message = 'server1 stopped responding at: ' + time.ctime(), title = 'ALERT - ALERT - ALERT' ) # Make server 1 untestable bServer1= False # Server successfully reached else: print 'server1 successfully reached at ' + time.ctime() # Check if server 2 has to be tested if bServer2 == True: # Check if path on the network is still available # Replace path2 with the actual path to the folder if not os.path.exists( '\\\\path2' ): easygui.msgbox( message = 'server2 stopped responding at: ' + time.ctime(), title = 'ALERT - ALERT - ALERT' ) # Make server 2 untestable bServer2= False # Server successfully reached else: print 'server2 successfully reached at ' + time.ctime() # Wait five minutes (300 seconds) before testing servers again #time.sleep( 5 ) time.sleep( 300 )