# # # Summary: heartBeat.py sends a ping to each of the chunkservers in the # # host.txt file. If the chunkserver responds, it adds it to an # # activehosts file, so all responsive chunkserver addresses are # # stored in one location. If the chunkserver does not respond, # # heartBeat.py makes sure it is removed from the activehosts list # # # ################################################################################# import socket, time, os, config, logging, sys, listener import functionLibrary as fL #import debugging fL.debug() ############################################################################### # Define heartBeat Object # ############################################################################### # Define a heartBeat object which will be used to ping the chunkservers and add those that # respond to an activehosts log, while removing those that do not respond from the # activehosts log
# The listenerConfig contains the name of the log that will store all # errors, the number of items per line, which will determine how many # items are stored on each line (such as, if this number is set at 60, # the history of the CPU (and every part) will go back 60 items into its # past.) The delayTime will determine how often (in seconds) the program # will run through, and files is a list of every file that is supposed to # be in the folder in which the listener is running. # # ############################################################################### import psutil, time, sys, logging, os, re, listenerConfig import functionLibrary as fL # import debugging fL.debug() ########################## # V A R I A B L E S # ########################## # The time that the program waits before running again is given in an argument. delayTime = listenerConfig.delayTime # name of the log in which all of the information about the system (such as the # CPU and memory) is stored logName = listenerConfig.logName logging.debug("Name of listen log: " + logName)