"last 5 minutes", {"packets": rs.pop("lastFiveMinsPkts", ""), "bytes": rs.pop("lastFiveMinsBytes", "")}, ) if len(rs) > 0: widget.setKeyAndValue("other", rs) # ==================================== # Top Hosts by Throughput Widget Data # ==================================== if widgetId.lower() == "tophoststhroughput": topHosts = [] while ntop.getNextHost(i): if ( len(search) > 0 and host.hostResolvedName().lower().find(search.lower()) == -1 and host.ethAddress().lower().find(search.lower()) == -1 and host.ipAddress().lower().find(search.lower()) == -1 ): continue if host.ipAddress() == "": # drop host with no throughput or no ip continue geo = host.geoIP() country = geo.get("country_name", "") countryCode = geo.get("country_code", "") hostType = ( 0 + __P2P__ * host.isP2P() + __VOIP__ * (host.isVoIPHost() | host.isVoIPClient() | host.isVoIPGateway()) + __PRINTER__ * host.isPrinter() + __DIRECTORY__ * host.isDirectoryHost() + __WORKSTATION__ * host.isWorkstation()
'packets': rs.pop('lastFiveMinsPkts', ''), 'bytes': rs.pop('lastFiveMinsBytes', '') }) if (len(rs) > 0): widget.setKeyAndValue('other', rs) # ==================================== # Top Hosts by Throughput Widget Data # ==================================== if (widgetId.lower() == "tophoststhroughput"): topHosts = [] while ntop.getNextHost(i): if (len(search) > 0 and host.hostResolvedName().lower().find( search.lower()) == -1 and host.ethAddress().lower().find(search.lower()) == -1 and host.ipAddress().lower().find( search.lower()) == -1): continue if host.ipAddress() == "": #drop host with no throughput or no ip continue geo = host.geoIP() country = geo.get('country_name', '') countryCode = geo.get('country_code', '') hostType = 0 + __P2P__ * host.isP2P() + __VOIP__ * ( host.isVoIPHost() | host.isVoIPClient() | host.isVoIPGateway()) + __PRINTER__ * host.isPrinter( ) + __DIRECTORY__ * host.isDirectoryHost( ) + __WORKSTATION__ * host.isWorkstation( ) + __HTTPHOST__ * host.isHTTPhost( ) + __FTPHOST__ * host.isFTPhost( ) + __SERVER__ * host.isServer() + __MAILSERVER__ * (
__HTTPHOST__ = 64 __FTPHOST__ = 128 __SERVER__ = 256 __MAILSERVER__ = 512 __DHCP__ = 1024 # form management form = cgi.FieldStorage() # Top hosts for which interface? selectedif = form.getvalue('if', default="") ifIndex = identify_interface_index(selectedif) while ntop.getNextHost(ifIndex): if host.ipAddress() == "": #drop host with no throughput or no ip continue #host.hostResolvedName() #ntop.sendString("%s\n" % host.hostResolvedName()) #ip,mac,name,fingerprint,isFTPhost,isWorkstation,isMasterBrowser,isPrinter,isSMTPhost,isPOPhost,isIMAPhost,isDirectoryHost,isHTTPhost,isVoIPClient,isVoIPGateway,isDHCPServer,isDHCPClient, data = "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s" % ( host.ipAddress(), host.ethAddress(), host.hostResolvedName(), host.fingerprint(), host.isFTPhost(), host.isWorkstation(), host.isMasterBrowser(), host.isPrinter(), host.isSMTPhost(), host.isPOPhost(), host.isIMAPhost(), host.isDirectoryHost(), host.isHTTPhost(), host.isVoIPClient(), host.isVoIPGateway(), host.isDHCPServer(), host.isDHCPClient()) ntop.sendString("%s\n" % data) '''
topHostsByPeakThroughputMetadata = {'type':'updowntable','mode':'gauge','unit':'kbps','title':'Top Hosts by Throughput Peak'} topHostsByAverageThroughputMetadata = {'type':'updowntable','mode':'gauge','unit':'kbps','title':'Top Hosts by Throughput Average'} topHostsByActualThroughputMetadata = {'type':'updowntable','mode':'gauge','unit':'kbps','title':'Top Hosts by Actual Throughput'} topHostsByTransferedBytesMetadata = {'type':'updowntable','mode':'counter','unit':'kB','title':'Top Hosts by Bytes'} topHostsByTransferedPacketsMetadata = {'type':'updowntable','mode':'counter','unit':'packets','title':'Top Hosts by Packet Number'} topHostsByPeakThroughputData = {} topHostsByAverageThroughputData = {} topHostsByActualThroughputData = {} topHostsByTransferedBytesData = {} topHostsByTransferedPacketsData = {} while ntop.getNextHost(ifIndex): if host.ipAddress()=="": #drop host with no throughput or no ip continue geo = host.geoIP() country = geo.get('country_name', '') countryCode = geo.get('country_code', '') hostType = 0 + __P2P__*host.isP2P() + __VOIP__*(host.isVoIPHost()|host.isVoIPClient()|host.isVoIPGateway()) + __PRINTER__*host.isPrinter() + __DIRECTORY__*host.isDirectoryHost() + __WORKSTATION__*host.isWorkstation() + __HTTPHOST__*host.isHTTPhost() + __FTPHOST__*host.isFTPhost() + __SERVER__*host.isServer() + __MAILSERVER__*(host.isSMTPhost()|host.isPOPhost()|host.isIMAPhost()) + __DHCP__*(host.isDHCPClient()|host.isDHCPServer()) thpSent=host.sendThpt() thpRcvd=host.receiveThpt() # set peak throughput # according to direction ( kBps ) thpPeakSent = (thpSent['peak']*8)/1000 thpPeakRcvd = (thpRcvd['peak']*8)/1000
__HTTPHOST__ = 64 __FTPHOST__ = 128 __SERVER__ = 256 __MAILSERVER__ = 512 __DHCP__ = 1024 # form management form = cgi.FieldStorage(); # Top hosts for which interface? selectedif = form.getvalue('if', default="") ifIndex = identify_interface_index(selectedif) while ntop.getNextHost(ifIndex): if host.ipAddress()=="": #drop host with no throughput or no ip continue #host.hostResolvedName() #ntop.sendString("%s\n" % host.hostResolvedName()) #ip,mac,name,fingerprint,isFTPhost,isWorkstation,isMasterBrowser,isPrinter,isSMTPhost,isPOPhost,isIMAPhost,isDirectoryHost,isHTTPhost,isVoIPClient,isVoIPGateway,isDHCPServer,isDHCPClient, data = "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s" % (host.ipAddress(), host.ethAddress(), host.hostResolvedName(), host.fingerprint(), host.isFTPhost(),host.isWorkstation(),host.isMasterBrowser(),host.isPrinter(), host.isSMTPhost(),host.isPOPhost(),host.isIMAPhost(),host.isDirectoryHost(),host.isHTTPhost(), host.isVoIPClient(),host.isVoIPGateway(),host.isDHCPServer(),host.isDHCPClient()) ntop.sendString("%s\n" % data) ''' while ntop.getNextHost(interfaceId): #ip,mac,name,fingerprint,isFTPhost,isWorkstation,isMasterBrowser,isPrinter,isSMTPhost,isPOPhost,isIMAPhost,isDirectoryHost,isHTTPhost,isVoIPClient,isVoIPGateway,isDHCPServer,isDHCPClient, data = "%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s,%s" % (host.ipAddress(), host.ethAddress(), host.hostResolvedName(), host.fingerprint(),