X-Git-Url: http://git.onelab.eu/?a=blobdiff_plain;f=factory%2Fportsummary;fp=factory%2Fportsummary;h=0000000000000000000000000000000000000000;hb=b81d4faa0fd65a42ae4a9a0191b4684d3aa7ff62;hp=f800632f7be1aa031506d9fcf2a6df3fb928e9cb;hpb=8d38d04aebf97cd4f5a9bc8d1c6586b3daef4685;p=vsys.git diff --git a/factory/portsummary b/factory/portsummary deleted file mode 100755 index f800632..0000000 --- a/factory/portsummary +++ /dev/null @@ -1,63 +0,0 @@ -#!/usr/bin/python - -import os -import sys - -# NOTE: '--inet' lists only ipv4 addresses. -ns = os.popen("ncontext --nid 1 --migrate -- vcontext --xid 1 --migrate -- netstat -apnlut --inet", 'r') -port_summary = {} -for line in ns: - try: - ns_fields = line.split() - if ns_fields[0] == "tcp" or ns_fields[0] == "udp": - (src_ip, src_port) = ns_fields[3].split(':') - (dst_ip, dst_port) = ns_fields[4].split(':') - - port_key='%s-%s' % (src_port, dst_port) - - if src_ip is not "0.0.0.0" and port_key in port_summary: - # skip INADDR_ANY addresses and ports we've already seen. - continue - - conn_state = ns_fields[5] - if ns_fields[0] == "tcp": - proc_field = ns_fields[6] - else: - if conn_state == "ESTABLISHED": - proc_field = ns_fields[6] - else: - proc_field = ns_fields[5] - - if proc_field != "-": - (pid,procname)= proc_field.split('/') - else: - # NOTE: without a PID there is no way to associate with an XID - continue - - if ( ns_fields[0] == "tcp" and src_ip == "0.0.0.0" and conn_state == "LISTEN" ) or \ - ( ns_fields[0] == "udp" and src_ip == "0.0.0.0" ): - type='C' - elif src_ip == "127.0.0.1": - type='l' - elif src_ip != "0.0.0.0" and src_ip != "127.0.0.1": - type='c' - else: - type='?' - - xid_stream = os.popen("vserver-info %s XID" % pid) - xid = xid_stream.read() - - port_summary[port_key] = {'prot' : ns_fields[0], - 'src_port' : src_port, - 'dst_port' : dst_port, - 'slice' : xid[:-1], - 'type': type} - except: - import traceback; traceback.print_exc() - print line - -ports = port_summary.keys() -ports.sort() -for port in ports: - print "%(prot)4s\t%(src_port)6s\t%(dst_port)6s\t%(slice)5s\t%(type)s" % port_summary[port] -