Example #1
0
			configRoot.find("smtp").find("general").attrib[
			"activated"]).upper() == "TRUE")
		if smtpActivated is True:
			smtpServer = str(
				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 sensors
		for item in configRoot.find("sensors").iterfind("sensor"):

			sensor = PingWatchdogSensor()

			# these options are needed by the server to
			# differentiate between the registered sensors
			sensor.id = int(item.find("general").attrib["id"])
			sensor.description = str(item.find("general").attrib[
				"description"])
			sensor.alertDelay = int(item.find("general").attrib["alertDelay"])
			sensor.triggerAlert = (str(item.find("general").attrib[
				"triggerAlert"]).upper() == "TRUE")
			sensor.triggerState = int(item.find("general").attrib[
				"triggerState"])

			sensor.alertLevels = list()
			for alertLevelXml in item.iterfind("alertLevel"):
				sensor.alertLevels.append(int(alertLevelXml.text))
Example #2
0
            configRoot.find("smtp").find(
                "general").attrib["activated"]).upper() == "TRUE")
        if smtpActivated is True:
            smtpServer = str(
                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 sensors
        for item in configRoot.find("sensors").iterfind("sensor"):

            sensor = PingWatchdogSensor()

            # these options are needed by the server to
            # differentiate between the registered sensors
            sensor.id = int(item.find("general").attrib["id"])
            sensor.description = str(
                item.find("general").attrib["description"])
            sensor.alertDelay = int(item.find("general").attrib["alertDelay"])
            sensor.triggerAlert = (str(
                item.find("general").attrib["triggerAlert"]).upper() == "TRUE")
            sensor.triggerAlertNormal = (str(
                item.find("general").attrib["triggerAlertNormal"]).upper() ==
                                         "TRUE")
            sensor.triggerState = 1

            sensor.alertLevels = list()
Example #3
0
			loglevel = logging.CRITICAL
		else:
			raise ValueError("No valid log level in config file.")

		# parse smtp options if activated
		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 sensors
		for section in config.sections():
			if section.find("sensor") != -1:
				sensor = PingWatchdogSensor()
				sensor.id = config.getint(section, "id")
				sensor.description = config.get(section, "description")
				sensor.alertDelay = config.getint(section, "alertDelay")
				sensor.alertLevel = config.getint(section, "alertLevel")
				sensor.triggerAlert = config.getboolean(section,
					"triggerAlert")
				sensor.triggerAlways = config.getboolean(section,
					"triggerAlways")
				sensor.triggerState = config.getint(section, "triggerState")

				# ctf watchdog specific options
				sensor.timeout = config.getint(section, "timeout")
				sensor.intervalToCheck = config.getint(section,
					"intervalToCheck")
				sensor.host = config.get(section, "host")