Browse Source

add all data to urls

windows
Florian N 12 years ago
parent
commit
6660c595ba
  1. 6
      main/views.py
  2. 2
      pydash/urls.py
  3. 15
      static/js/dashboard.js
  4. 13
      templates/main.html
  5. 61
      usage/views.py

6
main/views.py

@ -317,11 +317,7 @@ def get_netstat():
@login_required(login_url='/login/')
def getall(request):
return render_to_response('main.html', {'gethostname': get_platform()['hostname'],
'getplatform': get_platform()['osname'],
'getkernel': get_platform()['kernel'],
'getcpus': get_cpus(),
'time_refresh': time_refresh,
return render_to_response('main.html', {'time_refresh': time_refresh,
'time_refresh_long': time_refresh_long,
'time_refresh_net': time_refresh_net,
'version': version

2
pydash/urls.py

@ -24,6 +24,8 @@ urlpatterns = patterns('',
url(r'^info/proc/$', 'usage.views.getproc', name='getproc'),
url(r'^info/getdiskio/$', 'usage.views.getdiskio', name='getdiskio'),
url(r'^info/loadaverage/$', 'usage.views.loadaverage', name='loadaverage'),
url(r'^info/platform/([\w\-\.]+)/$', 'usage.views.platform', name='platform'),
url(r'^info/getcpus/([\w\-\.]+)/$', 'usage.views.getcpus', name='getcpus'),
url(r'^info/getnetstat/$', 'usage.views.getnetstat', name='getnetstat')
)

15
static/js/dashboard.js

@ -103,6 +103,21 @@ var dashboard = {};
dashboard.getUptime = function() {
get_os_data('/info/uptime/', "#get-uptime");
}
dashboard.getOSname = function() {
get_os_data('/info/platform/osname/', "#get-osname");
}
dashboard.getHostname = function() {
get_os_data('/info/platform/hostname/', "#get-hostname");
}
dashboard.getKernel = function() {
get_os_data('/info/platform/kernel/', "#get-kernel");
}
dashboard.getCPUcount = function() {
get_os_data('/info/getcpus/count/', "#get-cpucount");
}
dashboard.getCPUtype = function() {
get_os_data('/info/getcpus/type/', "#get-cputype");
}
dashboard.getDisk = function() {
$.getJSON('/info/getdisk/', function(data) {
destroy_dataTable("get_disk");

13
templates/main.html

@ -72,11 +72,11 @@
<div class="widget-content">
<br>
<div style="text-align:center;">
<b>OS:</b> <span class=""></span>{{ getplatform }}<br>
<b>OS:</b> <span class="" id="get-osname"></span><br>
<b>Uptime:</b> <span class="" id="get-uptime"></span> Hours<br>
<b>Hostname:</b> <span class=""></span>{{ gethostname }}<br>
<b>Kernel:</b> <span class=""></span>{{ getkernel }}<br>
<b>CPU(s):</b> <span class=""></span>{{ getcpus.cpus }} x {{ getcpus.type }}
<b>Hostname:</b> <span class="" id="get-hostname"></span><br>
<b>Kernel:</b> <span class="" id="get-kernel"></span><br>
<b>CPU(s):</b> <span class="" id="get-cpucount"></span> x <span class="" id="get-cputype"></span>
<br><br>
</div>
</div>
@ -407,7 +407,12 @@ $(function pageLoad() {
cpuu_usage();
traffic_usage();
disk_io();
dashboard.getOSname();
dashboard.getUptime();
dashboard.getHostname();
dashboard.getKernel();
dashboard.getCPUcount();
dashboard.getCPUtype();
dashboard.getDisk();
dashboard.getUsers();
dashboard.getNetstat();

61
usage/views.py

@ -49,6 +49,67 @@ def getnetstat(request):
response['Content-Type'] = "text/javascript"
response.write(data)
return response
@login_required(login_url='/login/')
def platform(request, name):
"""
Return the hostname
"""
getplatform = get_platform()
hostname = getplatform['hostname']
osname = getplatform['osname']
kernel = getplatform['kernel']
if name == 'hostname':
try:
data = hostname
except Exception:
data = None
if name == 'osname':
try:
data = osname
except Exception:
data = None
if name == 'kernel':
try:
data = kernel
except Exception:
data = None
data = json.dumps(data)
response = HttpResponse()
response['Content-Type'] = "text/javascript"
response.write(data)
return response
@login_required(login_url='/login/')
def getcpus(request, name):
"""
Return the CPU number and type/model
"""
getcpus = get_cpus()
cputype = getcpus['type']
cpucount = getcpus['cpus']
if name == 'type':
try:
data = cputype
except Exception:
data = None
if name == 'count':
try:
data = cpucount
except Exception:
data = None
data = json.dumps(data)
response = HttpResponse()
response['Content-Type'] = "text/javascript"
response.write(data)
return response
@login_required(login_url='/login/')

Loading…
Cancel
Save