예제 #1
0
            smtpPort = int(
                configRoot.find("smtp").find("server").attrib["port"])
            smtpFromAddr = str(
                configRoot.find("smtp").find("general").attrib["fromAddr"])
            smtpToAddr = str(
                configRoot.find("smtp").find("general").attrib["toAddr"])

        # Parse alertr.de account settings.
        tempConf = configRoot.find("alerts")
        alertrUsername = str(tempConf.attrib["username"])
        alertrPassword = str(tempConf.attrib["password"])

        # parse all alerts
        for item in configRoot.find("alerts").iterfind("alert"):

            alert = PushAlert(globalData)

            # Read the push notification settings.
            alert.username = alertrUsername
            alert.password = alertrPassword
            alert.channel = str(item.find("push").attrib["channel"])
            alert.encSecret = str(item.find("push").attrib["secret"])
            alert.subject = str(item.find("push").attrib["subject"])
            alert.templateFile = make_path(
                str(item.find("push").attrib["templateFile"]))

            # check if the template file exists
            if not os.path.isfile(alert.templateFile):
                raise ValueError("Message template file '%s' does not exist." %
                                 alert.templateFile)
예제 #2
0
            smtpPort = int(
                configRoot.find("smtp").find("server").attrib["port"])
            smtpFromAddr = str(
                configRoot.find("smtp").find("general").attrib["fromAddr"])
            smtpToAddr = str(
                configRoot.find("smtp").find("general").attrib["toAddr"])

        # Parse alertr.de account settings.
        tempConf = configRoot.find("alerts")
        alertrUsername = str(tempConf.attrib["username"])
        alertrPassword = str(tempConf.attrib["password"])

        # parse all alerts
        for item in configRoot.find("alerts").iterfind("alert"):

            alert = PushAlert(globalData)

            # Read the push notification settings.
            alert.username = alertrUsername
            alert.password = alertrPassword
            alert.channel = str(item.find("push").attrib["channel"])
            alert.encSecret = str(item.find("push").attrib["secret"])
            alert.subject = str(item.find("push").attrib["subject"])
            alert.templateFile = makePath(
                str(item.find("push").attrib["templateFile"]))

            # check if the template file exists
            if not os.path.isfile(alert.templateFile):
                raise ValueError("Message template file '%s' does not exist."
                    % alert.templateFile)
예제 #3
0
    # Sending test messages for the configured alerts.
    for alert in alerts:
        logging.info("[%s]: Sending message for alert id %d (%s)." %
                     (fileName, alert["id"], alert["description"]))

        globalData.pushRetryTimeout = 5
        globalData.pushRetries = 1

        subject = "Test message for alert with id %d" % alert["id"]
        message = "This is a test message for the alert:\n\n" \
            + "Id: %d\nDescription: %s\n\nCheers,\nalertR" \
            % (alert["id"], alert["description"])

        # Initialize alert object.
        alertObj = PushAlert(globalData)
        alertObj.id = alert["id"]
        alertObj.description = alert["description"]
        alertObj.username = alert["username"]
        alertObj.password = alert["password"]
        alertObj.channel = alert["channel"]
        alertObj.encSecret = alert["encSecret"]
        alertObj.templateFile = alert["templateFile"]
        alertObj.alertLevels = list()
        alertObj.subject = subject
        alertObj.initializeAlert()

        sensorAlert = SensorAlert()
        sensorAlert.state = 1
        sensorAlert.timeReceived = int(time.time())
예제 #4
0
    for alert in alerts:
        logging.info("[%s]: Sending message for alert id %d (%s)."
            % (fileName, alert["id"], alert["description"]))



        globalData.pushRetryTimeout = 5
        globalData.pushRetries = 1

        subject = "Test message for alert with id %d" % alert["id"]
        message = "This is a test message for the alert:\n\n" \
            + "Id: %d\nDescription: %s\n\nCheers,\nalertR" \
            % (alert["id"], alert["description"])

        # Initialize alert object.
        alertObj = PushAlert(globalData)
        alertObj.id = alert["id"]
        alertObj.description = alert["description"]
        alertObj.username = alert["username"]
        alertObj.password = alert["password"]
        alertObj.channel = alert["channel"]
        alertObj.encSecret = alert["encSecret"]
        alertObj.templateFile = alert["templateFile"]
        alertObj.alertLevels = list()
        alertObj.subject = subject
        alertObj.initializeAlert()

        sensorAlert = SensorAlert()
        sensorAlert.state = 1
        sensorAlert.timeReceived = int(time.time())