예제 #1
0
                configRoot.find("smtp").find("server").attrib["host"])
            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 all alerts
        for item in configRoot.find("alerts").iterfind("alert"):

            # PLACE YOUR CODE HERE
            # replace the creation of an instance of the template alert
            # class with your own alert class (you can also add
            # your own needed configuration parameters for this alert)
            alert = TemplateAlert()

            # these options are needed by the server to
            # differentiate between the registered alerts
            alert.id = int(item.find("general").attrib["id"])
            alert.description = str(item.find("general").attrib["description"])

            alert.alertLevels = list()
            for alertLevelXml in item.iterfind("alertLevel"):
                alert.alertLevels.append(int(alertLevelXml.text))

            # check if description is empty
            if len(alert.description) == 0:
                raise ValueError("Description of alert %d is empty." %
                                 alert.id)
예제 #2
0
		smtpActivated = config.getboolean("smtp", "smtpActivated")
		if smtpActivated is True:
			smtpServer = config.get("smtp", "server")
			smtpPort = config.getint("smtp", "serverPort")
			smtpFromAddr = config.get("smtp", "fromAddr")
			smtpToAddr = config.get("smtp", "toAddr")

		# parse all alerts
		for section in config.sections():
			if section.find("alert") != -1:

				# PLACE YOUR CODE HERE
				# replace the creation of an instance of the template alert
				# class with your own alert class (you can also add
				# your own needed configuration parameters for this alert)
				alert = TemplateAlert()



				# these options are needed for the by the server to
				# differentiate between the registered alerts
				alert.id = config.getint(section, "id")
				alert.description = config.get(section, "description")
				alert.alertLevels = map(int,
					config.get(section, "alertLevels").split(","))

				# register alert levels globally (only once)
				for alertLevel in alert.alertLevels:
					if not alertLevel in globalData.alertLevels:
						globalData.alertLevels.append(alertLevel)
예제 #3
0
                configRoot.find("smtp").find("server").attrib["host"])
            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 all alerts
        for item in configRoot.find("alerts").iterfind("alert"):

            # PLACE YOUR CODE HERE
            # replace the creation of an instance of the template alert
            # class with your own alert class (you can also add
            # your own needed configuration parameters for this alert)
            alert = TemplateAlert()



            # these options are needed by the server to
            # differentiate between the registered alerts
            alert.id = int(item.find("general").attrib["id"])
            alert.description = str(item.find("general").attrib["description"])

            alert.alertLevels = list()
            for alertLevelXml in item.iterfind("alertLevel"):
                alert.alertLevels.append(int(alertLevelXml.text))

            # check if description is empty
            if len(alert.description) == 0:
                raise ValueError("Description of alert %d is empty."
예제 #4
0
        smtpActivated = config.getboolean("smtp", "smtpActivated")
        if smtpActivated is True:
            smtpServer = config.get("smtp", "server")
            smtpPort = config.getint("smtp", "serverPort")
            smtpFromAddr = config.get("smtp", "fromAddr")
            smtpToAddr = config.get("smtp", "toAddr")

        # parse all alerts
        for section in config.sections():
            if section.find("alert") != -1:

                # PLACE YOUR CODE HERE
                # replace the creation of an instance of the template alert
                # class with your own alert class (you can also add
                # your own needed configuration parameters for this alert)
                alert = TemplateAlert()

                # these options are needed for the by the server to
                # differentiate between the registered alerts
                alert.id = config.getint(section, "id")
                alert.description = config.get(section, "description")
                alert.alertLevels = map(
                    int,
                    config.get(section, "alertLevels").split(","))

                # register alert levels globally (only once)
                for alertLevel in alert.alertLevels:
                    if not alertLevel in globalData.alertLevels:
                        globalData.alertLevels.append(alertLevel)

                # check if description is empty