Example #1
0
    # initialize logging
    logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s',
                        datefmt='%m/%d/%Y %H:%M:%S',
                        filename=logfile,
                        level=loglevel)

    # check if sensors were found => if not exit
    if not globalData.sensors:
        logging.critical("[%s]: No sensors configured." % fileName)
        sys.exit(1)

    # Initialize sensors before starting worker threads.
    logging.info("[%s] Initializing sensors." % fileName)
    for sensor in globalData.sensors:
        if not sensor.initializeSensor():
            logging.critical("[%s]: Not able to initialize sensor." % fileName)
            sys.exit(1)

    # generate object for the communication to the server and connect to it
    globalData.serverComm = ServerCommunication(server, serverPort,
                                                serverCAFile, username,
                                                password, clientCertFile,
                                                clientKeyFile, globalData)
    connectionRetries = 1
    logging.info("[%s] Connecting to server." % fileName)
    while True:
        # check if 5 unsuccessful attempts are made to connect
        # to the server and if smtp alert is activated
        # => send eMail alert
        if (globalData.smtpAlert is not None and (connectionRetries % 5) == 0):
Example #2
0
	else:
		globalData.smtpAlert = None

	# initialize logging
	logging.basicConfig(format='%(asctime)s %(levelname)s: %(message)s',
		datefmt='%m/%d/%Y %H:%M:%S', filename=logfile,
		level=loglevel)

	# check if sensors were found => if not exit
	if not globalData.sensors:
		logging.critical("[%s]: No sensors configured." % fileName)
		sys.exit(1)

	# Initialize sensors before starting worker threads.
	for sensor in globalData.sensors:
		if not sensor.initializeSensor():
			logging.critical("[%s]: Not able to initialize sensor."
				% fileName)
			sys.exit(1)

	# generate object for the communication to the server and connect to it
	globalData.serverComm = ServerCommunication(server, serverPort,
		serverCAFile, username, password, clientCertFile, clientKeyFile,
		globalData)
	connectionRetries = 1
	while True:
		# check if 5 unsuccessful attempts are made to connect
		# to the server and if smtp alert is activated
		# => send eMail alert
		if (globalData.smtpAlert is not None
			and (connectionRetries % 5) == 0):