From 7e3f75b157ae742e0ddd3b778da3bbba6a69384e Mon Sep 17 00:00:00 2001 From: XiaoBao Date: Thu, 25 Jan 2024 17:29:51 +0800 Subject: [PATCH] upgrade to 1.3.8beta --- README.md | 1 + dashboard/views.py | 6 +++--- templates/dashboard/view.html | 30 +++++++++++++++++++----------- 3 files changed, 23 insertions(+), 14 deletions(-) diff --git a/README.md b/README.md index 4c9111d..4bde43d 100644 --- a/README.md +++ b/README.md @@ -12,6 +12,7 @@ - OSCHINA - http://www.oschina.net/p/nginx-balancer ## 更新(2024-01-23) +* 新增 Dashboard 页面 5 秒自动刷新所有数据 * 新增 [nginx-module-vts](https://github.com/vozlt/nginx-module-vts) 模块,实现更完善的流量监测能力 * 新增 Dashboard 页面 Nginx 启动时间显示 > API 中同步增加字段,单位为 ms,可以自行转换 diff --git a/dashboard/views.py b/dashboard/views.py index 15eebe6..5d58840 100644 --- a/dashboard/views.py +++ b/dashboard/views.py @@ -9,12 +9,11 @@ @login_required(login_url="/login/") def view(request): - sysinfo = get_sys_info() user = { 'name':request.user, 'date':time.time() } - return render_to_response('dashboard/view.html',{'sysinfo' : sysinfo, 'user' : user}) + return render_to_response('dashboard/view.html',{'user' : user}) @is_auth def get_status_info(request): @@ -23,7 +22,8 @@ def get_status_info(request): 'flag':"Success", 'context':{ "sysstatus" : get_sys_status(), - "reqstatus" : req_status + "reqstatus" : get_req_status(), + "sysinfo": get_sys_info() } } return HttpResponse(json.dumps(context)) diff --git a/templates/dashboard/view.html b/templates/dashboard/view.html index 79b4573..baf88af 100644 --- a/templates/dashboard/view.html +++ b/templates/dashboard/view.html @@ -12,25 +12,23 @@

系统状态

Nginx 版本 - {{ sysinfo.nginx }} + 主机名 - {{ sysinfo.platform.node }} + 操作系统 - {{ sysinfo.platform.system }} {{ sysinfo.platform.release }} + 系统架构 - {{ sysinfo.platform.processor }} + 网络信息 - - {% for nic in sysinfo.nic %} - {{ nic.nic }} {{ nic.address }} {% endfor %} + @@ -292,8 +290,8 @@

请求统计

} } -function get_uptime() { - var uptime_ms = {{ sysinfo.platform.uptime }}; +function get_uptime(uptime_ms) { + var uptime_ms = uptime_ms; if (uptime_ms != 0 ) { var seconds = Math.floor(uptime_ms/ 1000); var minutes = Math.floor(seconds / 60); @@ -342,6 +340,17 @@

请求统计

$('#sp_nginx_status').text('已停止') } + get_uptime(p.context.sysinfo.platform.uptime) + + $('#sp_info_nginx').text(p.context.sysinfo.nginx) + $('#sp_info_node').text(p.context.sysinfo.platform.node) + $('#sp_info_system').text(p.context.sysinfo.platform.system) + $('#sp_info_release').text(p.context.sysinfo.platform.release) + $('#sp_info_processor').text(p.context.sysinfo.platform.processor) + $('#td_info_nic').empty() + for (var f in p.context.sysinfo.nic) { + $('#td_info_nic').append("" + p.context.sysinfo.nic[f].nic + " " + p.context.sysinfo.nic[f].address + " ") + } if (!p.context.sysstatus.nginx_config_status) { $('#sp_nginx_config_status').removeClass() @@ -394,7 +403,6 @@

请求统计

add_data(true, 0, 0, 0); } get_status_info() -get_uptime() -window.setInterval(get_status_info, 10000); +window.setInterval(get_status_info, 5000); {% endblock %}