From 5289b2946c7064ce99bd439120350d32aaf105ea Mon Sep 17 00:00:00 2001 From: guohongze Date: Sun, 18 Jun 2017 00:15:16 +0800 Subject: [PATCH] =?UTF-8?q?monitor=20=E7=B3=BB=E7=BB=9F=E7=9B=91=E6=8E=A7?= =?UTF-8?q?=E6=A8=A1=E5=9D=97echeats=20Y=E8=BD=B4=E5=BA=A7=E6=A0=87?= =?UTF-8?q?=E9=A2=9C=E8=89=B2=E5=8F=8A=E6=97=B6=E9=97=B4=E8=B0=83=E6=95=B4?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- monitor/urls.py | 4 ++-- monitor/views.py | 2 +- templates/monitor/host_info.html | 23 ++++++++++++++++------- 3 files changed, 19 insertions(+), 10 deletions(-) diff --git a/monitor/urls.py b/monitor/urls.py index c0fcde54..18a1995c 100644 --- a/monitor/urls.py +++ b/monitor/urls.py @@ -6,6 +6,6 @@ urlpatterns = [ url(r'^system/$', views.index, name='monitor'), - url(r'^system/(?P\w+)/$', views.host_info, name='host_info'), - url(r'^get/data/(?P\w+)/$', views.get_sys_data, name='get_sys_data'), + url(r'^system/(?P.+)/$', views.host_info, name='host_info'), + url(r'^get/data/(?P.+)/$', views.get_sys_data, name='get_sys_data'), ] \ No newline at end of file diff --git a/monitor/views.py b/monitor/views.py index b1ff7f6e..1d296a2d 100644 --- a/monitor/views.py +++ b/monitor/views.py @@ -39,7 +39,7 @@ def get_sys_data(request, hostname): unix_time = doc['timestamp'] if unix_time >= now-3600: times = time.localtime(unix_time) - dt = time.strftime("%m%d-%H:%M:%S", times) + dt = time.strftime("%m%d-%H:%M", times) # get cpu data c_percent = doc['cpu']['percent'] cpu_percent.append(c_percent) diff --git a/templates/monitor/host_info.html b/templates/monitor/host_info.html index 5203ef6b..9cea1314 100644 --- a/templates/monitor/host_info.html +++ b/templates/monitor/host_info.html @@ -24,8 +24,8 @@

{{ hostname }} 监控信息

-
-
+
+
@@ -70,7 +70,8 @@

{{ hostname }} 监控信息

type : 'value', axisLabel : { formatter : '{value} %' - } + }, + max: 100, }], series: [{ boundaryGap: false, @@ -83,7 +84,6 @@

{{ hostname }} 监控信息

normal: { } }, - max: 100, data: data.cpu_percent } ] @@ -103,7 +103,9 @@

{{ hostname }} 监控信息

title: { text: '内存使用率' }, - tooltip: {}, + tooltip: { + trigger: 'axis' + }, toolbox: { feature: { dataZoom: { @@ -124,15 +126,22 @@

{{ hostname }} 监控信息

type : 'value', axisLabel : { formatter : '{value} %' - } + }, + max: 100 }], series: [{ boundaryGap: [0, '0%'], name: 'Memory', smooth:true, type: 'line', + areaStyle: { + normal: { + color: '#00a65a' + } + }, data: data.memory_percent - }] + } + ] }); }); }, 2000);