From 0f036a5227ea19262663bbb4819b37e5a1cf6993 Mon Sep 17 00:00:00 2001 From: Florian N Date: Thu, 5 Jun 2014 22:19:11 -0400 Subject: [PATCH 1/3] Remove any elements form list if not split at 4 Interesting data in issue #23 --- main/views.py | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/main/views.py b/main/views.py index f30e552..a2de518 100755 --- a/main/views.py +++ b/main/views.py @@ -310,7 +310,8 @@ def get_netstat(): pipe.close() data = [i.split(None, 4) for i in data] - + data[:] = [e for e in data if len(e) == 4] + except Exception, err: data = str(err) From 2a2e795ec7e438a06e52c1b999e7363d3f323e8d Mon Sep 17 00:00:00 2001 From: Florian N Date: Fri, 6 Jun 2014 09:56:17 -0400 Subject: [PATCH 2/3] Update ss command Update the ss command for get_netstat() to account for possible empty lines --- main/views.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main/views.py b/main/views.py index a2de518..6efcab9 100755 --- a/main/views.py +++ b/main/views.py @@ -305,12 +305,12 @@ def get_netstat(): Get ports and applications """ try: - pipe = os.popen("ss -tnp | grep ESTAB | awk '{print $4, $5}'| sed 's/::ffff://g' | awk -F: '{print $1, $2}' | sort -n | uniq -c") + pipe = os.popen("ss -tnp | grep ESTAB | awk '{print $4, $5}'| sed 's/::ffff://g' | awk -F: '{print $1, $2}' | awk 'NF > 0' | sort -n | uniq -c") data = pipe.read().strip().split('\n') pipe.close() data = [i.split(None, 4) for i in data] - data[:] = [e for e in data if len(e) == 4] +# data[:] = [e for e in data if len(e) == 4] except Exception, err: data = str(err) From 8c7ac359f1166256e433f72300a200e2ce1a94a4 Mon Sep 17 00:00:00 2001 From: Florian N Date: Sun, 8 Jun 2014 20:16:02 -0400 Subject: [PATCH 3/3] small clean up --- main/views.py | 1 - 1 file changed, 1 deletion(-) diff --git a/main/views.py b/main/views.py index 6efcab9..eb32022 100755 --- a/main/views.py +++ b/main/views.py @@ -310,7 +310,6 @@ def get_netstat(): pipe.close() data = [i.split(None, 4) for i in data] -# data[:] = [e for e in data if len(e) == 4] except Exception, err: data = str(err)