Esempio n. 1
0
     widget.removeKey("total")
     # ===============================
     # Protocol Packets Widget Data
     # ===============================
 if widgetId.lower() == "protocolpackets":
     # pie chart is a serie of key-value pairs
     wdata = interface.pktsStats(i)
     wdata = filter_dict(wdata, lambda k, v: v > 0)
     widget.setProperties(wdata)
     widget.removeKey("total")
     # ===============================
     # Security Packets Widget Data
     # ===============================
 if widgetId.lower() == "securitypackets":
     # table is a serie of key-value pairs
     wdata = interface.securityPkts(i)
     wdata = filter_dict(wdata, lambda k, v: v > 0)
     widget.setProperties(wdata)
     widget.removeKey("total")
     # ===============================
     # NetFlow Widget Data
     # ===============================
 if widgetId.lower() == "netflowstats":
     # pie chart is a serie of key-value pairs
     widget.setProperties(interface.netflowStats(i))
     widget.removeKey("total")
     # ===============================
     # SFlow Widget Data
     # ===============================
 if widgetId.lower() == "sflowstats":
     # pie chart is a serie of key-value pairs
Esempio n. 2
0
     widget.removeKey('total')
 # ===============================
 # Protocol Packets Widget Data
 # ===============================
 if (widgetId.lower() == "protocolpackets"):
     # pie chart is a serie of key-value pairs
     wdata = interface.pktsStats(i)
     wdata = filter_dict(wdata, lambda k, v: v > 0)
     widget.setProperties(wdata)
     widget.removeKey('total')
 # ===============================
 # Security Packets Widget Data
 # ===============================
 if (widgetId.lower() == "securitypackets"):
     # table is a serie of key-value pairs
     wdata = interface.securityPkts(i)
     wdata = filter_dict(wdata, lambda k, v: v > 0)
     widget.setProperties(wdata)
     widget.removeKey('total')
 # ===============================
 # NetFlow Widget Data
 # ===============================
 if (widgetId.lower() == "netflowstats"):
     # pie chart is a serie of key-value pairs
     widget.setProperties(interface.netflowStats(i))
     widget.removeKey('total')
 # ===============================
 # SFlow Widget Data
 # ===============================
 if (widgetId.lower() == "sflowstats"):
     # pie chart is a serie of key-value pairs
Esempio n. 3
0
            addr['ipv6'] = interface.ipv6(i)
            info['address'] = addr

            if ((len(mode) == 0) or not (mode == "list")):
                stats = {}
                stats['pktsStats'] = interface.pktsStats(i)
                stats['bytesStats'] = interface.bytesStats(i)
                stats['throughputStats'] = interface.throughputStats(i)

                ip = {}
                ip['tcp'] = interface.tcpStats(i)
                ip['udp'] = interface.udpStats(i)
                ip['icmp'] = interface.icmpStats(i)
                ip['ip'] = interface.ipStats(i)

                stats['securityPkts'] = interface.securityPkts(i)
                stats['netflowStats'] = interface.netflowStats(i)
                stats['sflowStats'] = interface.sflowStats(i)
                stats['cpacketStats'] = interface.cpacketStats(i)
                stats['ip'] = ip
                info['stats'] = stats

            rsp[interface.uniqueName(i)] = info

except Exception as inst:
    print type(inst)  # the exception instance
    print inst.args  # arguments stored in .args
    print inst  # __str__ allows args to printed directly

ntop.sendHTTPHeader(1)  # 1 = HTML
ntop.sendString(json.dumps(rsp, sort_keys=True, indent=4))
Esempio n. 4
0
                    'bytes': rs.pop('lastFiveMinsBytes', '')
                }
                if (len(rs) > 0): adapter['other'] = rs

                throughputStats = {
                    "metadata": {
                        "type": "groupedtable",
                        "title": "Interface Throughput",
                        "unit": "bps",
                        "mode": "gauge",
                        "total": total
                    },
                    "data": adapter
                }

                rs = interface.securityPkts(i)
                total = rs.pop('total', sum(rs.values()))
                securityPkts = {
                    "metadata": {
                        "type": "barchart",
                        "title": "Security Packet Statistics",
                        "unit": "packets",
                        "mode": "counter",
                        "total": total
                    },
                    "data": rs
                }
                # Build traffic info for interface
                if_traffic = [
                    pktsStats, bytesStats, securityPkts, throughputStats
                ]
Esempio n. 5
0
	addr['ipv6'] = interface.ipv6(i)
	info['address'] = addr

	if((len(mode) == 0) or not(mode == "list")):
		stats = {}
		stats['pktsStats'] = interface.pktsStats(i)
		stats['bytesStats'] = interface.bytesStats(i)
		stats['throughputStats'] = interface.throughputStats(i)
		
		ip = {}
		ip['tcp'] = interface.tcpStats(i)
		ip['udp'] = interface.udpStats(i)
		ip['icmp'] = interface.icmpStats(i)
		ip['ip'] = interface.ipStats(i)
		
		stats['securityPkts'] = interface.securityPkts(i)	
		stats['netflowStats'] = interface.netflowStats(i)
		stats['sflowStats'] = interface.sflowStats(i)
		stats['cpacketStats'] = interface.cpacketStats(i)
		stats['ip'] = ip
		info['stats'] = stats

	rsp[interface.uniqueName(i)] = info

except Exception as inst:
    print type(inst)     # the exception instance
    print inst.args      # arguments stored in .args
    print inst           # __str__ allows args to printed directly

ntop.sendHTTPHeader(1) # 1 = HTML    
ntop.sendString(json.dumps(rsp, sort_keys=True, indent=4))
Esempio n. 6
0
				bytesStats = { "metadata": { "type":"piechart", "title":"Bytes Statistics", "unit": "bytes", "mode" : "counter", "total": total }, "data" : rs }

				rs = interface.throughputStats(i)
				total = rs.pop('total',sum(rs.values()))
				
				adapter = {}
				adapter['actual'] = {'packets': rs.pop('actualPkts',''), 'bytes': rs.pop('actualBytes','')}
				adapter['peak'] = {'packets': rs.pop('peakPkts',''), 'bytes': rs.pop('peakBytes','')}
				adapter['last minute'] = {'packets': rs.pop('lastMinPkts',''), 'bytes': rs.pop('lastMinBytes','')}
				adapter['last 5 minutes'] = {'packets': rs.pop('lastFiveMinsPkts',''), 'bytes': rs.pop('lastFiveMinsBytes','')}
				if (len(rs) > 0): adapter['other'] = rs
				
				throughputStats = { "metadata": { "type":"groupedtable", "title":"Interface Throughput", "unit": "bps", "mode" : "gauge", "total": total }, "data" : adapter }
			
				rs = interface.securityPkts(i)
				total = rs.pop('total',sum(rs.values()))
				securityPkts = { "metadata": { "type":"barchart", "title":"Security Packet Statistics", "unit": "packets", "mode" : "counter", "total": total}, "data" : rs }
				# Build traffic info for interface
				if_traffic = [pktsStats, bytesStats, securityPkts, throughputStats]
				
				rs = interface.netflowStats(i)
				if(len(rs) > 0):
					total = rs.pop('total',sum(rs.values()))
					if_traffic.append({"metadata": {"type":"table", "title":"Netflow Statistics", "unit": "bytes", "mode" : "counter", "total": total}, "data":rs})

				rs = interface.sflowStats(i)
				if(len(rs) > 0):
					total = rs.pop('total',sum(rs.values()))
					if_traffic.append({"metadata": {"type":"piechart", "title":"SFlow Statistics", "unit": "bytes", "mode" : "counter", "total": total}, "data":rs})