|
|
@ -1,34 +1,33 @@ |
|
|
#The MIT License (MIT) |
|
|
|
|
|
|
|
|
# The MIT License (MIT) |
|
|
# |
|
|
# |
|
|
#Copyright (c) 2014 Florian Neagu - michaelneagu@gmail.com - https://github.com/k3oni/ |
|
|
|
|
|
|
|
|
# Copyright (c) 2014 Florian Neagu - michaelneagu@gmail.com - https://github.com/k3oni/ |
|
|
# |
|
|
# |
|
|
#Permission is hereby granted, free of charge, to any person obtaining a copy |
|
|
|
|
|
#of this software and associated documentation files (the "Software"), to deal |
|
|
|
|
|
#in the Software without restriction, including without limitation the rights |
|
|
|
|
|
#to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
|
|
|
|
#copies of the Software, and to permit persons to whom the Software is |
|
|
|
|
|
#furnished to do so, subject to the following conditions: |
|
|
|
|
|
|
|
|
# Permission is hereby granted, free of charge, to any person obtaining a copy |
|
|
|
|
|
# of this software and associated documentation files (the "Software"), to deal |
|
|
|
|
|
# in the Software without restriction, including without limitation the rights |
|
|
|
|
|
# to use, copy, modify, merge, publish, distribute, sublicense, and/or sell |
|
|
|
|
|
# copies of the Software, and to permit persons to whom the Software is |
|
|
|
|
|
# furnished to do so, subject to the following conditions: |
|
|
# |
|
|
# |
|
|
#The above copyright notice and this permission notice shall be included in all |
|
|
|
|
|
#copies or substantial portions of the Software. |
|
|
|
|
|
|
|
|
# The above copyright notice and this permission notice shall be included in all |
|
|
|
|
|
# copies or substantial portions of the Software. |
|
|
# |
|
|
# |
|
|
#THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
|
|
|
|
#IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
|
|
|
|
#FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
|
|
|
|
#AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
|
|
|
|
#LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
|
|
|
|
#OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
|
|
|
|
#SOFTWARE. |
|
|
|
|
|
|
|
|
# THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR |
|
|
|
|
|
# IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, |
|
|
|
|
|
# FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE |
|
|
|
|
|
# AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER |
|
|
|
|
|
# LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, |
|
|
|
|
|
# OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE |
|
|
|
|
|
# SOFTWARE. |
|
|
|
|
|
|
|
|
import json |
|
|
import json |
|
|
from django.shortcuts import render_to_response |
|
|
|
|
|
from django.http import HttpResponse, HttpResponseRedirect |
|
|
|
|
|
from django.template import RequestContext |
|
|
|
|
|
from django.contrib.auth.decorators import login_required |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
from django.http import HttpResponse |
|
|
|
|
|
|
|
|
from main.views import * |
|
|
from main.views import * |
|
|
from pydash.settings import TIME_JS_REFRESH, TIME_JS_REFRESH_LONG, TIME_JS_REFRESH_NET |
|
|
from pydash.settings import TIME_JS_REFRESH, TIME_JS_REFRESH_LONG, TIME_JS_REFRESH_NET |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
time_refresh = TIME_JS_REFRESH |
|
|
time_refresh = TIME_JS_REFRESH |
|
|
time_refresh_long = TIME_JS_REFRESH_LONG |
|
|
time_refresh_long = TIME_JS_REFRESH_LONG |
|
|
time_refresh_net = TIME_JS_REFRESH_NET |
|
|
time_refresh_net = TIME_JS_REFRESH_NET |
|
|
@ -40,16 +39,17 @@ def getnetstat(request): |
|
|
Return netstat output |
|
|
Return netstat output |
|
|
""" |
|
|
""" |
|
|
try: |
|
|
try: |
|
|
net_stat = get_netstat() |
|
|
|
|
|
|
|
|
net_stat = get_netstat() |
|
|
except Exception: |
|
|
except Exception: |
|
|
net_stat = None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
net_stat = None |
|
|
|
|
|
|
|
|
data = json.dumps(net_stat) |
|
|
data = json.dumps(net_stat) |
|
|
response = HttpResponse() |
|
|
response = HttpResponse() |
|
|
response['Content-Type'] = "text/javascript" |
|
|
response['Content-Type'] = "text/javascript" |
|
|
response.write(data) |
|
|
response.write(data) |
|
|
return response |
|
|
return response |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@login_required(login_url='/login/') |
|
|
@login_required(login_url='/login/') |
|
|
def platform(request, name): |
|
|
def platform(request, name): |
|
|
""" |
|
|
""" |
|
|
@ -59,52 +59,56 @@ def platform(request, name): |
|
|
hostname = getplatform['hostname'] |
|
|
hostname = getplatform['hostname'] |
|
|
osname = getplatform['osname'] |
|
|
osname = getplatform['osname'] |
|
|
kernel = getplatform['kernel'] |
|
|
kernel = getplatform['kernel'] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data = {} |
|
|
|
|
|
|
|
|
if name == 'hostname': |
|
|
if name == 'hostname': |
|
|
try: |
|
|
|
|
|
data = hostname |
|
|
|
|
|
except Exception: |
|
|
|
|
|
data = None |
|
|
|
|
|
|
|
|
try: |
|
|
|
|
|
data = hostname |
|
|
|
|
|
except Exception: |
|
|
|
|
|
data = None |
|
|
|
|
|
|
|
|
if name == 'osname': |
|
|
if name == 'osname': |
|
|
try: |
|
|
|
|
|
data = osname |
|
|
|
|
|
except Exception: |
|
|
|
|
|
data = None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
|
data = osname |
|
|
|
|
|
except Exception: |
|
|
|
|
|
data = None |
|
|
|
|
|
|
|
|
if name == 'kernel': |
|
|
if name == 'kernel': |
|
|
try: |
|
|
|
|
|
data = kernel |
|
|
|
|
|
except Exception: |
|
|
|
|
|
data = None |
|
|
|
|
|
|
|
|
try: |
|
|
|
|
|
data = kernel |
|
|
|
|
|
except Exception: |
|
|
|
|
|
data = None |
|
|
|
|
|
|
|
|
data = json.dumps(data) |
|
|
|
|
|
|
|
|
data = json.dumps(data) |
|
|
response = HttpResponse() |
|
|
response = HttpResponse() |
|
|
response['Content-Type'] = "text/javascript" |
|
|
response['Content-Type'] = "text/javascript" |
|
|
response.write(data) |
|
|
response.write(data) |
|
|
return response |
|
|
return response |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@login_required(login_url='/login/') |
|
|
@login_required(login_url='/login/') |
|
|
def getcpus(request, name): |
|
|
def getcpus(request, name): |
|
|
""" |
|
|
""" |
|
|
Return the CPU number and type/model |
|
|
Return the CPU number and type/model |
|
|
""" |
|
|
""" |
|
|
getcpus = get_cpus() |
|
|
|
|
|
cputype = getcpus['type'] |
|
|
|
|
|
cpucount = getcpus['cpus'] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cpus = get_cpus() |
|
|
|
|
|
cputype = cpus['type'] |
|
|
|
|
|
cpucount = cpus['cpus'] |
|
|
|
|
|
data = {} |
|
|
|
|
|
|
|
|
if name == 'type': |
|
|
if name == 'type': |
|
|
try: |
|
|
|
|
|
data = cputype |
|
|
|
|
|
except Exception: |
|
|
|
|
|
data = None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
|
data = cputype |
|
|
|
|
|
except Exception: |
|
|
|
|
|
data = None |
|
|
|
|
|
|
|
|
if name == 'count': |
|
|
if name == 'count': |
|
|
try: |
|
|
|
|
|
data = cpucount |
|
|
|
|
|
except Exception: |
|
|
|
|
|
data = None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
|
|
|
data = cpucount |
|
|
|
|
|
except Exception: |
|
|
|
|
|
data = None |
|
|
|
|
|
|
|
|
data = json.dumps(data) |
|
|
data = json.dumps(data) |
|
|
response = HttpResponse() |
|
|
response = HttpResponse() |
|
|
response['Content-Type'] = "text/javascript" |
|
|
response['Content-Type'] = "text/javascript" |
|
|
@ -118,10 +122,10 @@ def uptime(request): |
|
|
Return uptime |
|
|
Return uptime |
|
|
""" |
|
|
""" |
|
|
try: |
|
|
try: |
|
|
up_time = get_uptime() |
|
|
|
|
|
|
|
|
up_time = get_uptime() |
|
|
except Exception: |
|
|
except Exception: |
|
|
up_time = None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
up_time = None |
|
|
|
|
|
|
|
|
data = json.dumps(up_time) |
|
|
data = json.dumps(up_time) |
|
|
response = HttpResponse() |
|
|
response = HttpResponse() |
|
|
response['Content-Type'] = "text/javascript" |
|
|
response['Content-Type'] = "text/javascript" |
|
|
@ -135,26 +139,27 @@ def getdisk(request): |
|
|
Return the disk usage |
|
|
Return the disk usage |
|
|
""" |
|
|
""" |
|
|
try: |
|
|
try: |
|
|
getdisk = get_disk() |
|
|
|
|
|
|
|
|
diskusage = get_disk() |
|
|
except Exception: |
|
|
except Exception: |
|
|
getdisk = None |
|
|
|
|
|
|
|
|
|
|
|
data = json.dumps(getdisk) |
|
|
|
|
|
|
|
|
diskusage = None |
|
|
|
|
|
|
|
|
|
|
|
data = json.dumps(diskusage) |
|
|
response = HttpResponse() |
|
|
response = HttpResponse() |
|
|
response['Content-Type'] = "text/javascript" |
|
|
response['Content-Type'] = "text/javascript" |
|
|
response.write(data) |
|
|
response.write(data) |
|
|
return response |
|
|
return response |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@login_required(login_url='/login/') |
|
|
@login_required(login_url='/login/') |
|
|
def getips(request): |
|
|
def getips(request): |
|
|
""" |
|
|
""" |
|
|
Return the IPs and interfaces |
|
|
Return the IPs and interfaces |
|
|
""" |
|
|
""" |
|
|
try: |
|
|
try: |
|
|
get_ips = get_ipaddress() |
|
|
|
|
|
|
|
|
get_ips = get_ipaddress() |
|
|
except Exception: |
|
|
except Exception: |
|
|
get_ips = None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
get_ips = None |
|
|
|
|
|
|
|
|
data = json.dumps(get_ips['itfip']) |
|
|
data = json.dumps(get_ips['itfip']) |
|
|
response = HttpResponse() |
|
|
response = HttpResponse() |
|
|
response['Content-Type'] = "text/javascript" |
|
|
response['Content-Type'] = "text/javascript" |
|
|
@ -168,10 +173,10 @@ def getusers(request): |
|
|
Return online users |
|
|
Return online users |
|
|
""" |
|
|
""" |
|
|
try: |
|
|
try: |
|
|
online_users = get_users() |
|
|
|
|
|
|
|
|
online_users = get_users() |
|
|
except Exception: |
|
|
except Exception: |
|
|
online_users = None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
online_users = None |
|
|
|
|
|
|
|
|
data = json.dumps(online_users) |
|
|
data = json.dumps(online_users) |
|
|
response = HttpResponse() |
|
|
response = HttpResponse() |
|
|
response['Content-Type'] = "text/javascript" |
|
|
response['Content-Type'] = "text/javascript" |
|
|
@ -179,23 +184,24 @@ def getusers(request): |
|
|
return response |
|
|
return response |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@login_required(login_url='/login/') |
|
|
|
|
|
|
|
|
@login_required(login_url='/login/') |
|
|
def getproc(request): |
|
|
def getproc(request): |
|
|
""" |
|
|
""" |
|
|
Return the running processes |
|
|
Return the running processes |
|
|
""" |
|
|
""" |
|
|
try: |
|
|
try: |
|
|
processes = get_cpu_usage() |
|
|
|
|
|
processes = processes['all'] |
|
|
|
|
|
|
|
|
processes = get_cpu_usage() |
|
|
|
|
|
processes = processes['all'] |
|
|
except Exception: |
|
|
except Exception: |
|
|
processes = None |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
processes = None |
|
|
|
|
|
|
|
|
data = json.dumps(processes) |
|
|
data = json.dumps(processes) |
|
|
response = HttpResponse() |
|
|
response = HttpResponse() |
|
|
response['Content-Type'] = "text/javascript" |
|
|
response['Content-Type'] = "text/javascript" |
|
|
response.write(data) |
|
|
response.write(data) |
|
|
return response |
|
|
return response |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@login_required(login_url='/login/') |
|
|
@login_required(login_url='/login/') |
|
|
def cpuusage(request): |
|
|
def cpuusage(request): |
|
|
""" |
|
|
""" |
|
|
@ -203,20 +209,20 @@ def cpuusage(request): |
|
|
""" |
|
|
""" |
|
|
try: |
|
|
try: |
|
|
cpu_usage = get_cpu_usage() |
|
|
cpu_usage = get_cpu_usage() |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
except Exception: |
|
|
except Exception: |
|
|
cpu_usage = 0 |
|
|
cpu_usage = 0 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cpu = [ |
|
|
cpu = [ |
|
|
{ |
|
|
|
|
|
"value": cpu_usage['free'], |
|
|
|
|
|
"color": "#0AD11B" |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
"value": cpu_usage['used'], |
|
|
|
|
|
"color": "#F7464A" |
|
|
|
|
|
} |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
{ |
|
|
|
|
|
"value": cpu_usage['free'], |
|
|
|
|
|
"color": "#0AD11B" |
|
|
|
|
|
}, |
|
|
|
|
|
{ |
|
|
|
|
|
"value": cpu_usage['used'], |
|
|
|
|
|
"color": "#F7464A" |
|
|
|
|
|
} |
|
|
|
|
|
] |
|
|
|
|
|
|
|
|
data = json.dumps(cpu) |
|
|
data = json.dumps(cpu) |
|
|
response = HttpResponse() |
|
|
response = HttpResponse() |
|
|
@ -224,6 +230,7 @@ def cpuusage(request): |
|
|
response.write(data) |
|
|
response.write(data) |
|
|
return response |
|
|
return response |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@login_required(login_url='/login/') |
|
|
@login_required(login_url='/login/') |
|
|
def memusage(request): |
|
|
def memusage(request): |
|
|
""" |
|
|
""" |
|
|
@ -231,7 +238,6 @@ def memusage(request): |
|
|
""" |
|
|
""" |
|
|
datasets_free = [] |
|
|
datasets_free = [] |
|
|
datasets_used = [] |
|
|
datasets_used = [] |
|
|
cookie_memory = {} |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
try: |
|
|
mem_usage = get_mem() |
|
|
mem_usage = get_mem() |
|
|
@ -250,7 +256,7 @@ def memusage(request): |
|
|
datasets = json.loads(cookies) |
|
|
datasets = json.loads(cookies) |
|
|
datasets_free = datasets[0] |
|
|
datasets_free = datasets[0] |
|
|
datasets_used = datasets[1] |
|
|
datasets_used = datasets[1] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
if len(datasets_free) > 10: |
|
|
if len(datasets_free) > 10: |
|
|
while datasets_free: |
|
|
while datasets_free: |
|
|
del datasets_free[0] |
|
|
del datasets_free[0] |
|
|
@ -298,7 +304,7 @@ def memusage(request): |
|
|
} |
|
|
} |
|
|
] |
|
|
] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cookie_memory = [datasets_free, datasets_used] |
|
|
cookie_memory = [datasets_free, datasets_used] |
|
|
data = json.dumps(memory) |
|
|
data = json.dumps(memory) |
|
|
response = HttpResponse() |
|
|
response = HttpResponse() |
|
|
@ -307,7 +313,8 @@ def memusage(request): |
|
|
response.write(data) |
|
|
response.write(data) |
|
|
return response |
|
|
return response |
|
|
|
|
|
|
|
|
@login_required(login_url='/login/') |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
@login_required(login_url='/login/') |
|
|
def loadaverage(request): |
|
|
def loadaverage(request): |
|
|
""" |
|
|
""" |
|
|
Return Load Average numeric |
|
|
Return Load Average numeric |
|
|
@ -350,15 +357,15 @@ def loadaverage(request): |
|
|
'labels': [""] * 10, |
|
|
'labels': [""] * 10, |
|
|
'datasets': [ |
|
|
'datasets': [ |
|
|
{ |
|
|
{ |
|
|
"fillColor" : "rgba(151,187,205,0.5)", |
|
|
|
|
|
"strokeColor" : "rgba(151,187,205,1)", |
|
|
|
|
|
"pointColor" : "rgba(151,187,205,1)", |
|
|
|
|
|
|
|
|
"fillColor": "rgba(151,187,205,0.5)", |
|
|
|
|
|
"strokeColor": "rgba(151,187,205,1)", |
|
|
|
|
|
"pointColor": "rgba(151,187,205,1)", |
|
|
"pointStrokeColor": "#fff", |
|
|
"pointStrokeColor": "#fff", |
|
|
"data": datasets |
|
|
"data": datasets |
|
|
} |
|
|
} |
|
|
] |
|
|
] |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
data = json.dumps(load) |
|
|
data = json.dumps(load) |
|
|
response = HttpResponse() |
|
|
response = HttpResponse() |
|
|
response['Content-Type'] = "text/javascript" |
|
|
response['Content-Type'] = "text/javascript" |
|
|
@ -376,14 +383,12 @@ def gettraffic(request): |
|
|
datasets_in_i = [] |
|
|
datasets_in_i = [] |
|
|
datasets_out = [] |
|
|
datasets_out = [] |
|
|
datasets_out_o = [] |
|
|
datasets_out_o = [] |
|
|
json_traffic = [] |
|
|
|
|
|
cookie_traffic = {} |
|
|
|
|
|
label = "KBps" |
|
|
label = "KBps" |
|
|
|
|
|
|
|
|
try: |
|
|
try: |
|
|
intf = get_ipaddress() |
|
|
|
|
|
intf = intf['interface'][0] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
intf = get_ipaddress() |
|
|
|
|
|
intf = intf['interface'][0] |
|
|
|
|
|
|
|
|
traffic = get_traffic(intf) |
|
|
traffic = get_traffic(intf) |
|
|
except Exception: |
|
|
except Exception: |
|
|
traffic = 0 |
|
|
traffic = 0 |
|
|
@ -402,8 +407,8 @@ def gettraffic(request): |
|
|
datasets = json.loads(cookies) |
|
|
datasets = json.loads(cookies) |
|
|
datasets_in = datasets[0] |
|
|
datasets_in = datasets[0] |
|
|
datasets_out = datasets[1] |
|
|
datasets_out = datasets[1] |
|
|
datasets_in_i = datasets[2] |
|
|
|
|
|
datasets_out_o = datasets[3] |
|
|
|
|
|
|
|
|
datasets_in_i = datasets[2] |
|
|
|
|
|
datasets_out_o = datasets[3] |
|
|
|
|
|
|
|
|
if len(datasets_in) > 10: |
|
|
if len(datasets_in) > 10: |
|
|
while datasets_in: |
|
|
while datasets_in: |
|
|
@ -437,14 +442,14 @@ def gettraffic(request): |
|
|
datasets_out_o.append(float(traffic['traffic_out'])) |
|
|
datasets_out_o.append(float(traffic['traffic_out'])) |
|
|
del datasets_out_o[0] |
|
|
del datasets_out_o[0] |
|
|
|
|
|
|
|
|
dataset_in = (float(((datasets_in_i[1] - datasets_in_i[0]) / 1024 ) / ( time_refresh_net / 1000 ))) |
|
|
|
|
|
dataset_out = (float(((datasets_out_o[1] - datasets_out_o[0]) / 1024 ) / ( time_refresh_net / 1000 ))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dataset_in = (float(((datasets_in_i[1] - datasets_in_i[0]) / 1024) / (time_refresh_net / 1000))) |
|
|
|
|
|
dataset_out = (float(((datasets_out_o[1] - datasets_out_o[0]) / 1024) / (time_refresh_net / 1000))) |
|
|
|
|
|
|
|
|
if dataset_in > 1024 or dataset_out > 1024: |
|
|
if dataset_in > 1024 or dataset_out > 1024: |
|
|
dataset_in = (float(dataset_in / 1024 )) |
|
|
|
|
|
dataset_out = (float(dataset_out / 1024 )) |
|
|
|
|
|
label = "MBps" |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dataset_in = (float(dataset_in / 1024)) |
|
|
|
|
|
dataset_out = (float(dataset_out / 1024)) |
|
|
|
|
|
label = "MBps" |
|
|
|
|
|
|
|
|
if len(datasets_in) <= 9: |
|
|
if len(datasets_in) <= 9: |
|
|
datasets_in.append(dataset_in) |
|
|
datasets_in.append(dataset_in) |
|
|
if len(datasets_in) == 10: |
|
|
if len(datasets_in) == 10: |
|
|
@ -501,13 +506,10 @@ def getdiskio(request): |
|
|
datasets_in_i = [] |
|
|
datasets_in_i = [] |
|
|
datasets_out = [] |
|
|
datasets_out = [] |
|
|
datasets_out_o = [] |
|
|
datasets_out_o = [] |
|
|
json_diskrw = [] |
|
|
|
|
|
cookie_diskrw = {} |
|
|
|
|
|
|
|
|
|
|
|
try: |
|
|
try: |
|
|
diskrw = get_disk_rw() |
|
|
|
|
|
diskrw = diskrw[0] |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
diskrw = get_disk_rw() |
|
|
|
|
|
diskrw = diskrw[0] |
|
|
except Exception: |
|
|
except Exception: |
|
|
diskrw = 0 |
|
|
diskrw = 0 |
|
|
|
|
|
|
|
|
@ -525,8 +527,8 @@ def getdiskio(request): |
|
|
datasets = json.loads(cookies) |
|
|
datasets = json.loads(cookies) |
|
|
datasets_in = datasets[0] |
|
|
datasets_in = datasets[0] |
|
|
datasets_out = datasets[1] |
|
|
datasets_out = datasets[1] |
|
|
datasets_in_i = datasets[2] |
|
|
|
|
|
datasets_out_o = datasets[3] |
|
|
|
|
|
|
|
|
datasets_in_i = datasets[2] |
|
|
|
|
|
datasets_out_o = datasets[3] |
|
|
|
|
|
|
|
|
if len(datasets_in) > 10: |
|
|
if len(datasets_in) > 10: |
|
|
while datasets_in: |
|
|
while datasets_in: |
|
|
@ -560,9 +562,9 @@ def getdiskio(request): |
|
|
datasets_out_o.append(int(diskrw[2])) |
|
|
datasets_out_o.append(int(diskrw[2])) |
|
|
del datasets_out_o[0] |
|
|
del datasets_out_o[0] |
|
|
|
|
|
|
|
|
dataset_in = (int((datasets_in_i[1] - datasets_in_i[0]) / ( time_refresh_net / 1000 ))) |
|
|
|
|
|
dataset_out = (int((datasets_out_o[1] - datasets_out_o[0]) / ( time_refresh_net / 1000 ))) |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
dataset_in = (int((datasets_in_i[1] - datasets_in_i[0]) / (time_refresh_net / 1000))) |
|
|
|
|
|
dataset_out = (int((datasets_out_o[1] - datasets_out_o[0]) / (time_refresh_net / 1000))) |
|
|
|
|
|
|
|
|
if len(datasets_in) <= 9: |
|
|
if len(datasets_in) <= 9: |
|
|
datasets_in.append(dataset_in) |
|
|
datasets_in.append(dataset_in) |
|
|
if len(datasets_in) == 10: |
|
|
if len(datasets_in) == 10: |
|
|
|