Beispiel #1
0
def main():
	""" Initialize monitoring """
	print 'TrafficMon started.\nPress <Ctrl>-C to shut down.'
	# initialize interface indices for monitored nodes
	# These are router nodes which we have explicitly pointed out to be polled
	for node in config.Nodes:
		logging.debug('Initializing node ' + `node`)
		if nodes.find(node):
			continue
		n = nodes.create(node)
		n.type = nodes.ROUTER
		nodes.add(n)
	
	# finish initialization, start monitoring threads for router nodes
	logging.debug('Starting AODV thread for ' + `node.address`)
	threads.add(gatherers.rrdtool.AodvThread(node))
	
	# TODO: modularize backends
	for node in nodes.collection:
		if (node.type == nodes.ROUTER):
			if (config.Simulate):
				logging.debug('Starting SNMP poll thread for ' + `node.address`)
				threads.add(gatherers.rrdtool.SnmpPollThread(node))	
			else:
				logging.debug('Starting simulated SNMP thread for ' + `node.address`)
				threads.add(gatherers.rrdtool.SimulationPollThread(node))
				
			logging.debug('Starting graphing thread for ' + `node.address`)
			threads.add(rendering.rrdtool.GraphingThread(node))
Beispiel #2
0
def initialize():
	# generate and update nodes collection
	gatherers.simulatesink.populate()
	logging.debug('Starting simulator thread')
	threads.add(gatherers.simulatesink.SimulatorThread())

	for node in nodes.collection:
		if (node.type == nodes.ROUTER):
			logging.debug('Starting graphing thread for ' + `node.address`)
			threads.add(rendering.rrd.GraphingThread(node))

	logging.debug('Starting weathermap thread')
	threads.add(rendering.weathermap.WeathermapThread())
Beispiel #3
0
def initialize():
    import gatherers.rrdsink, logging, threads

    # finish initialization, start monitoring threads for router nodes
    logging.debug("Starting AODV thread")
    threads.add(gatherers.rrdsink.AodvThread())

    import nodes

    for node in nodes.collection:
        if node.type == nodes.ROUTER:
            logging.debug("Starting SNMP poll thread for " + ` node.address `)
            threads.add(gatherers.rrdsink.GathererThread(node))

            import rendering.rrd

            logging.debug("Starting graphing thread for " + ` node.address `)
            threads.add(rendering.rrd.GraphingThread(node))

    import rendering.weathermap

    logging.debug("Starting weathermap thread")
    threads.add(rendering.weathermap.WeathermapThread())
Beispiel #4
0
	def loop_aodv(self):

		for target in nodes.collection:

			# BUG: (maybe?) if a node does not have SNMP there's no way
			# to fetch its SNMP status
			if target.type != nodes.ROUTER:
				continue

			# first, reset neighbours list so we can redetect links
			target.neighbours = {}

			############
			text = None
			global execResults
			logging.debug('loop_aodv for %s' % target.address)
			
			try:
				execResults[target.address] = \
						snmp.walk(target.address, (1,3,6,1,4,1,2021,8))
				# try and increase interval
				if self.interval > 10:
					self.interval -= 1

			except Exception, e:
				logging.error('Unable to get AODV output for ' +
					`target.address` + ': ' + `e`)

				# try and reduce traffic interval
				if self.interval < 30:
					self.interval += 1
				continue

			target.aodv_data = \
					aodv.parse(str(execResults[target.address][8][0][1]))
			target.wifi_data = \
					wifi.parse(str(execResults[target.address][9][0][1]))

			for interface in target.aodv_data:
				# fetch entry for this link
				entry = target.aodv_data[interface]
				destaddress = entry['destination']

				# check if it already exists
				dest = nodes.find(destaddress)

				if dest == None:
					# add newly discovered nodes to collection
					dest = nodes.create(destaddress)
					nodes.add(dest)

					try:
						logging.debug(snmp.walk(dest.address,
								snmp.load_symbol('SNMPv2-MIB',
										'sysDescr'))[0][0][1])
						# no problems here. this destination supports SNMP
						dest.type = nodes.ROUTER

						logging.debug('Starting SNMP poll thread for ' + `dest.address`)
						threads.add(GathererThread(dest))

						logging.debug('Starting graphing thread for ' + `dest.address`)
						threads.add(rendering.rrd.GraphingThread(dest))

					except Exception, e:
						if e.message == 'requestTimedOut':
							# assume machine does not have SNM
							# assume machine does not have SNMP?
							logging.debug('PROBING %s has timed out!' % dest.address)
							dest.type = nodes.GENERIC
						else:
							# we have a real error!
							logging.error(e)


				# also check for AODV gateway nodes
				gateway = nodes.find(entry['gateway'])
				if gateway == None:
					gateway = nodes.create(entry['gateway'])
					nodes.add(gateway)

					try:
						logging.debug(snmp.walk(gateway.address,
								snmp.load_symbol('SNMPv2-MIB',
										'sysDescr'))[0][0][1])
						# no problems here. this gateway supports SNMP
						gateway.type = nodes.ROUTER

						logging.debug('Starting SNMP poll thread for ' + `gateway.address`)
						threads.add(GathererThread(gateway))

						logging.debug('Starting graphing thread for ' + `gateway.address`)
						threads.add(rendering.rrd.GraphingThread(gateway))

					except Exception, e:
						if e.message == 'requestTimedOut':
							# assume machine does not have SNMP?
							logging.debug('PROBING %s has timed out!' % gateway.address)
							gateway.type = nodes.GENERIC
						else:
							# we have a real error!
							logging.error(e)
Beispiel #5
0
		# These are router nodes which we have explicitly pointed out to be polled
		for node in config.Nodes:
			logging.debug('Initializing node ' + `node`)
			if nodes.find(node):
				continue
			n = nodes.create(node)
			n.type = nodes.ROUTER
			nodes.add(n)
		
		# do any processing defined by plugin
		logging.debug('Initializing plugin')
		plugin.initialize()
		
		# start web server
		logging.debug('Starting web server')
		threads.add(webserver.WebThread())
		
		# print thread pool status
		num_threads = threads.size()
		if num_threads > 0:
			print str(num_threads), 'threads executing...'
			while 1:
				try:
					input = raw_input()
				except (EOFError, KeyboardInterrupt):
					break
		else:
			print 'Nothing to monitor.'
	except (EOFError, KeyboardInterrupt):
		pass
	
Beispiel #6
0
				
				# update global routing table
				# BUG: we forgot to separate interfaces!!
				routes[target] = {
					'if_index': index +1,
					'if_name': oid[0][1]
				}
				# prepare to create worker thread
				options.update(routes[target])
				
				logging.debug('Starting link poll thread for ' + `target` + 
					' ' + oid[0][1])
				threads.add(LinkPollThread(options))
		
		logging.debug('Starting Weathermap thread')
		threads.add(WeathermapThread(options))

#------------------------------------------------------------------------------ 
class LinkPollThread(MonitorThread):
	"""
	Thread for monitoring a link's routing tables over a set period
	"""

	def __init__(self, options):
		super(LinkPollThread, self).__init__()
		self.func = self.loop_monitor
		self.interval = config.TrafficInterval
		self.if_index = options['if_index']
		self.if_name = options['if_name']
		self.target = options['host']