Browse Source

change ss data

windows^2
Florian N 12 years ago
parent
commit
3ef9e50e32
  1. 4
      main/views.py
  2. 6
      templates/main.html

4
main/views.py

@ -299,11 +299,11 @@ def get_netstat():
Get ports and applications
"""
try:
pipe = os.popen("ss -tnp | grep ESTAB| awk '{print $4, $5}'")
pipe = os.popen("ss -tnp | grep ESTAB | awk '{print $4, $5}'| sed 's/::ffff://g' | awk -F: '{print $1, $2}' | sort -n | uniq -c")
data = pipe.read().strip().split('\n')
pipe.close()
data = [i.split(None, 3) for i in data]
data = [i.split(None, 4) for i in data]
except Exception, err:
data = str(err)

6
templates/main.html

@ -289,7 +289,9 @@
<table class="table table-hover table-condensed table-bordered">
<thead>
<tr>
<th>Local</th>
<th>Count</th>
<th>Local IP</th>
<th>Local Port</th>
<th>Foreign</th>
</tr>
</thead>
@ -411,7 +413,7 @@ dashboard.getNetstat = function() {
$.getJSON('/info/getnetstat/', function(data) {
var tr='';
$.each( data, function( index, item){
tr+='<tr><td>'+item[0]+'</td><td>'+item[1]+'</td></tr>';
tr+='<tr><td>'+item[0]+'</td><td>'+item[1]+'</td><td>'+item[2]+'</td><td>'+item[3]+'</td></tr>';
})
tr+='';
$("#get-netstat").html( tr );

Loading…
Cancel
Save