Browse Source

v 1.3

windows^2
Florian N 12 years ago
parent
commit
9b136441bf
  1. 18
      main/views.py
  2. 2
      pydash/settings.py
  3. 1
      templates/main.html
  4. 6
      usage/views.py

18
main/views.py

@ -255,7 +255,7 @@ def get_cpu_usage():
"""
Get the CPU usage and running processes
"""
try:
try:
pipe = os.popen("ps aux --sort -%cpu,-rss")
data = pipe.read().strip().split('\n')
pipe.close()
@ -295,19 +295,25 @@ def get_load():
return data
def get_netstat():
"""
Get ports and applications
"""
try:
pipe = os.popen("netstat -tlnp|grep LISTEN|awk '{print $4, $5, $7}'")
pipe = os.popen("netstat -tlnp |" + "grep 'LISTEN' |" + "awk '{print $4, $5, $7}'")
data = pipe.read().strip().split('\n')
pipe.close()
data = [i.split(None, 3) for i in data]
except Exception, err:
data = str(err)
if data[0] == []:
data = [['No', 'data', 'available']]
#for i in data:
# temp = i.split()
# print temp[3] + temp[4]
data = [['No', 'data', 'available']]
return data
@login_required(login_url='/login/')
def getall(request):

2
pydash/settings.py

@ -36,7 +36,7 @@ TIME_JS_REFRESH = 30000
TIME_JS_REFRESH_LONG = 120000
TIME_JS_REFRESH_NET = 2000
VERSION = 1.2
VERSION = 1.3
ALLOWED_HOSTS = ['*']

1
templates/main.html

@ -415,7 +415,6 @@ dashboard.getNetstat = function() {
tr+='<tr><td>'+item[0]+'</td><td>'+item[1]+'</td><td>'+item[2]+'</td></tr>';
})
tr+='';
console.log(tr);
$("#get-netstat").html( tr );
});
}

6
usage/views.py

@ -38,7 +38,11 @@ def getnetstat(request):
"""
Return netstat output
"""
net_stat = get_netstat()
try:
net_stat = get_netstat()
except Exception:
net_stat = None
data = json.dumps(net_stat)
response = HttpResponse()
response['Content-Type'] = "text/javascript"

Loading…
Cancel
Save