Example #1
0
	def testGetPid(self):
		"Test that we can get the conninfo for a particular PID and that it looks correct."
		conntrack._clearmaps()
		conntrack.up(1, "127.0.0.3", ("abc", "def", "GLOBAL"))
		conntrack.up(2, "127.0.0.4", ("test",))
		self.assertEqual(str(conntrack.getpid(1)), "<CI: PID 1, IP 127.0.0.3, classes: abc def GLOBAL>")
		self.assertEqual(str(conntrack.getpid(2)), "<CI: PID 2, IP 127.0.0.4, classes: test>")
Example #2
0
def repstate():
	log.report("status: total lifetime connections: %d" % (totconnects,))
	pids = conntrack.getpids()
	if len(pids) == 0:
		log.report("status: no active connections.")
	else:
		log.report("status: %d active connections:" % len(pids))
		pids.sort()
		# Now, this is only a snapshot, so take care here. A kid could
		# have died before we get around to pulling it.
		for pid in pids:
			try:
				pi = str(conntrack.getpid(pid))
			except KeyError:
				continue
			log.report("status: " + pi)
	# This is put at the bottom to bookend the active connection info.
	log.report("status: per IP first/last connection times entries: %d" % \
		   (hinfo.iptimessize()))
	if threadcount or threadhigh > 1:
		log.report("status: %d active rules evaluation threads (%d highwater)." % \
			   (threadcount, threadhigh))

	# totruleTime is already a float, because time.time() returns them.
	if totrules and totruleTime:
		log.report("status: average rule evaluation time over %d evals: %0.4f seconds" % (totrules, totruleTime / totrules))

	if totloops:
		log.report("status: %d loops, %d conns, %0.1f conns average" %
			   (totloops, totconns, (totconns*1.0)/totloops))