Browse Source

Update ss command

Update the ss command for get_netstat() to account for possible empty lines
windows^2
Florian N 12 years ago
parent
commit
2a2e795ec7
  1. 4
      main/views.py

4
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)

Loading…
Cancel
Save