Skip to content

Commit 7e3f75b

Browse files
author
XiaoBao
committed
upgrade to 1.3.8beta
1 parent 22c3ad4 commit 7e3f75b

File tree

3 files changed

+23
-14
lines changed

3 files changed

+23
-14
lines changed

README.md

+1
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
- OSCHINA - http://www.oschina.net/p/nginx-balancer
1313

1414
## 更新(2024-01-23)
15+
* 新增 Dashboard 页面 5 秒自动刷新所有数据
1516
* 新增 [nginx-module-vts](https://github.com/vozlt/nginx-module-vts) 模块,实现更完善的流量监测能力
1617
* 新增 Dashboard 页面 Nginx 启动时间显示
1718
> API 中同步增加字段,单位为 ms,可以自行转换

dashboard/views.py

+3-3
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,11 @@
99

1010
@login_required(login_url="/login/")
1111
def view(request):
12-
sysinfo = get_sys_info()
1312
user = {
1413
'name':request.user,
1514
'date':time.time()
1615
}
17-
return render_to_response('dashboard/view.html',{'sysinfo' : sysinfo, 'user' : user})
16+
return render_to_response('dashboard/view.html',{'user' : user})
1817

1918
@is_auth
2019
def get_status_info(request):
@@ -23,7 +22,8 @@ def get_status_info(request):
2322
'flag':"Success",
2423
'context':{
2524
"sysstatus" : get_sys_status(),
26-
"reqstatus" : req_status
25+
"reqstatus" : get_req_status(),
26+
"sysinfo": get_sys_info()
2727
}
2828
}
2929
return HttpResponse(json.dumps(context))

templates/dashboard/view.html

+19-11
Original file line numberDiff line numberDiff line change
@@ -12,25 +12,23 @@ <h3 class="box-title">系统状态</h3>
1212
<tbody>
1313
<tr>
1414
<td class="pull-right"><strong>Nginx 版本</strong></td>
15-
<td>{{ sysinfo.nginx }} <span id="sp_nginx_status"></span> <span id="sp_nginx_config_status"></span><span id="sp_uptime"></span></td>
15+
<td><span id="sp_info_nginx"></span> <span id="sp_nginx_status"></span> <span id="sp_nginx_config_status"></span><span id="sp_uptime"></span></td>
1616
</tr>
1717
<tr>
1818
<td class="pull-right"><strong>主机名</strong></td>
19-
<td>{{ sysinfo.platform.node }}</td>
19+
<td><span id="sp_info_node"></span></td>
2020
</tr>
2121
<tr>
2222
<td class="pull-right"><strong>操作系统</strong></td>
23-
<td>{{ sysinfo.platform.system }} {{ sysinfo.platform.release }}</td>
23+
<td><span id="sp_info_system"></span> <span id="sp_info_release"></span></td>
2424
</tr>
2525
<tr>
2626
<td class="pull-right"><strong>系统架构</strong></td>
27-
<td>{{ sysinfo.platform.processor }} </td>
27+
<td><spam id="sp_info_processor"></span></td>
2828
</tr>
2929
<tr>
3030
<td class="pull-right"><strong>网络信息</strong></td>
31-
<td>
32-
{% for nic in sysinfo.nic %}
33-
<small>{{ nic.nic }}</small> {{ nic.address }} {% endfor %}
31+
<td id="td_info_nic">
3432
</td>
3533
</tr>
3634
</tbody>
@@ -292,8 +290,8 @@ <h3 class="box-title">请求统计</h3>
292290
}
293291
}
294292

295-
function get_uptime() {
296-
var uptime_ms = {{ sysinfo.platform.uptime }};
293+
function get_uptime(uptime_ms) {
294+
var uptime_ms = uptime_ms;
297295
if (uptime_ms != 0 ) {
298296
var seconds = Math.floor(uptime_ms/ 1000);
299297
var minutes = Math.floor(seconds / 60);
@@ -342,6 +340,17 @@ <h3 class="box-title">请求统计</h3>
342340
$('#sp_nginx_status').text('已停止')
343341
}
344342

343+
get_uptime(p.context.sysinfo.platform.uptime)
344+
345+
$('#sp_info_nginx').text(p.context.sysinfo.nginx)
346+
$('#sp_info_node').text(p.context.sysinfo.platform.node)
347+
$('#sp_info_system').text(p.context.sysinfo.platform.system)
348+
$('#sp_info_release').text(p.context.sysinfo.platform.release)
349+
$('#sp_info_processor').text(p.context.sysinfo.platform.processor)
350+
$('#td_info_nic').empty()
351+
for (var f in p.context.sysinfo.nic) {
352+
$('#td_info_nic').append("<small>" + p.context.sysinfo.nic[f].nic + "</small> " + p.context.sysinfo.nic[f].address + " ")
353+
}
345354

346355
if (!p.context.sysstatus.nginx_config_status) {
347356
$('#sp_nginx_config_status').removeClass()
@@ -394,7 +403,6 @@ <h3 class="box-title">请求统计</h3>
394403
add_data(true, 0, 0, 0);
395404
}
396405
get_status_info()
397-
get_uptime()
398-
window.setInterval(get_status_info, 10000);
406+
window.setInterval(get_status_info, 5000);
399407
</script>
400408
{% endblock %}

0 commit comments

Comments
 (0)