示例#1
0
			# 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))

			# ping specific options
			sensor.timeout = int(item.find("ping").attrib[
				"timeout"])
			sensor.intervalToCheck = int(item.find("ping").attrib[
				"intervalToCheck"])
			sensor.host = str(item.find("ping").attrib[
				"host"])
			sensor.execute = str(item.find("ping").attrib[
				"execute"])

			# check if description is empty
			if len(sensor.description) == 0:
				raise ValueError("Description of sensor '%s' is empty."
					% section)

			# check if the id of the sensor is unique
			for registeredSensor in globalData.sensors:
				if registeredSensor.id == sensor.id:
示例#2
0
            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()
            for alertLevelXml in item.iterfind("alertLevel"):
                sensor.alertLevels.append(int(alertLevelXml.text))

            # ping specific options
            sensor.timeout = int(item.find("ping").attrib["timeout"])
            sensor.intervalToCheck = int(
                item.find("ping").attrib["intervalToCheck"])
            sensor.host = str(item.find("ping").attrib["host"])
            sensor.execute = makePath(str(item.find("ping").attrib["execute"]))

            # check if description is empty
            if len(sensor.description) == 0:
                raise ValueError("Description of sensor %d is empty." %
                                 sensor.id)

            # check if the id of the sensor is unique
            for registeredSensor in globalData.sensors:
                if registeredSensor.id == sensor.id:
                    raise ValueError("Id of sensor %d " % sensor.id +
                                     "is already taken.")
示例#3
0
		# 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")
				sensor.execute = config.get(section, "execute")

				# check if description is empty
				if len(sensor.description) == 0:
					print "Description of sensor '%s' is empty." % section
					sys.exit(1)

				# check if the id of the sensor is unique
				for registeredSensor in globalData.sensors:
					if registeredSensor.id == sensor.id:
						print "Id of sensor '%s'" % section \
						+ "is already taken."