ntoptest.py

来自「ntop网络监控软件,使用方面」· Python 代码 · 共 33 行

PY
33
字号
#!/usr/bin/env pythonimport urllib, timeURL = "http://localhost:3000/dumpData.html?language=python"print "Getting NTop stats in Python format"statsText = ''attempt = 1# NTop takes a while to build the statswhile not statsText.count("hostNumIpAddress"):	print "Attempt #" + str(attempt)	try:		statsText = urllib.urlopen(URL).read()	except IOError:		"NTop timed out, is it active?"	assert statsText.count("ntopDict"), \		"ntopDict not in output"	assert attempt < 100, \		"Could not get stats from NTop"	attempt += 1	# give it a little while	time.sleep(2)try:	exec(statsText)except:	print "Problems interpreting the stats"else:	print "Found stats for the following hosts:"	for host in ntopDict.keys():		print hostprint "All done."

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?