Exemplo n.º 1
0
        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 globalData.sensors == list():
        logging.critical("[%s]: No sensors configured. " % 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 1:
        # 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):
            globalData.smtpAlert.sendCommunicationAlert(connectionRetries)

        if globalData.serverComm.initializeCommunication() is True:
            # if smtp alert is activated
            # => send email that communication problems are solved
            if not globalData.smtpAlert is None:
                globalData.smtpAlert.sendCommunicationAlertClear()
Exemplo n.º 2
0
			smtpFromAddr, smtpToAddr)
	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 globalData.sensors == list():
		logging.critical("[%s]: No sensors configured. " % fileName)
		sys.exit(1)

	# generate object for the communication to the server and connect to it
	serverComm = ServerCommunication(server, serverPort,
		serverCertificate, username, password, globalData)
	connectionRetries = 1
	while 1:
		# 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):
			globalData.smtpAlert.sendCommunicationAlert(connectionRetries)

		if serverComm.initializeCommunication() is True:
			# if smtp alert is activated
			# => send email that communication problems are solved
			if not globalData.smtpAlert is None:
				globalData.smtpAlert.sendCommunicationAlertClear()
			
Exemplo n.º 3
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 globalData.sensors == list():
        logging.critical("[%s]: No sensors configured. " % fileName)
        sys.exit(1)

    # generate object for the communication to the server and connect to it
    serverComm = ServerCommunication(server, serverPort, serverCertificate,
                                     username, password, globalData)
    connectionRetries = 1
    while 1:
        # 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):
            globalData.smtpAlert.sendCommunicationAlert(connectionRetries)

        if serverComm.initializeCommunication() is True:
            # if smtp alert is activated
            # => send email that communication problems are solved
            if not globalData.smtpAlert is None:
                globalData.smtpAlert.sendCommunicationAlertClear()

            connectionRetries = 1
Exemplo n.º 4
0
    except Exception as e:
        logging.exception("[%s]: Could not parse config." % fileName)
        sys.exit(1)

    random.seed()

    # check if smtp is activated => generate object to send eMail alerts
    if smtpActivated is True:
        globalData.smtpAlert = SMTPAlert(smtpServer, smtpPort, smtpFromAddr,
                                         smtpToAddr)
    else:
        globalData.smtpAlert = None

    # generate object for the communication to the server and connect to it
    globalData.serverComm = ServerCommunication(
        server, serverPort, serverCAFile, username, password, clientCertFile,
        clientKeyFile, ManagerEventHandler(globalData), 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):
            globalData.smtpAlert.sendCommunicationAlert(connectionRetries)

        if globalData.serverComm.initialize() is True:
            # if smtp alert is activated
            # => send email that communication problems are solved
            if globalData.smtpAlert is not None:
                globalData.smtpAlert.sendCommunicationAlertClear()
Exemplo n.º 5
0
		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)

	# generate a screen updater thread (that generates the GUI)
	globalData.screenUpdater = ScreenUpdater(globalData)
	# set thread to daemon
	# => threads terminates when main thread terminates	
	globalData.screenUpdater.daemon = True
	globalData.screenUpdater.start()

	# generate object for the communication to the server and connect to it
	globalData.serverComm = ServerCommunication(server, serverPort,
		serverCertificate, username, password, globalData)
	connectionRetries = 1
	while 1:
		# 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):
			globalData.smtpAlert.sendCommunicationAlert(connectionRetries)

		if globalData.serverComm.initializeCommunication() is True:
			# if smtp alert is activated
			# => send email that communication problems are solved
			if not globalData.smtpAlert is None:
				globalData.smtpAlert.sendCommunicationAlertClear()