From 2a2e795ec7e438a06e52c1b999e7363d3f323e8d Mon Sep 17 00:00:00 2001 From: Florian N Date: Fri, 6 Jun 2014 09:56:17 -0400 Subject: [PATCH] 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)