diff --git a/src/api/index.py b/src/api/index.py index 5986b4d..f60679b 100644 --- a/src/api/index.py +++ b/src/api/index.py @@ -137,7 +137,7 @@ def trends (): series += [item for item in row if str(item['label'])== app] if len(series) > 12 : - beg = len(series) - 13 + beg = len(series) - 8 series = series[beg:] return json.dumps(series) else: diff --git a/src/api/static/js/dashboard.js b/src/api/static/js/dashboard.js index ec45de9..84148bb 100644 --- a/src/api/static/js/dashboard.js +++ b/src/api/static/js/dashboard.js @@ -1,5 +1,21 @@ var MONTHS = { 1: 'Jan', 2: 'Feb', 3: 'Mar', 4: 'Apr', 5: 'May', 6: 'Jun', 7: 'Jul', 8: 'Aug', 9: 'Sep', 10: 'Oct', 11: 'Nov', 12: 'Dec' } var monitor = {} +monitor.utils = {} +monitor.utils.get = {} +monitor.utils.get.time = function (item) { + // date = ([item.day + '-' + MONTHS[item.month] + '-' + item.year, hour + ':' + item.minute]).join(' ') + var hour = item.hour > 9 ? item.hour : ('0' + item.hour) + if (hour > 12) { + var units = 'PM' + } else { + var units = 'AM' + } + return ([hour+':'+item.minute,units]).join(' ') +} +monitor.utils.get.dateTime = function (item) { + var time = monitor.utils.get.time(item) + return ([item.day+'-'+MONTHS[item.month]+'-'+item.year,time]).join(' ') +} monitor.processes = {} monitor.processes.fetch = function(){ var httpclient = HttpClient.instance() @@ -66,7 +82,8 @@ monitor.processes.render = function(label,data) { return row }) jx.dom.set.value('latest_processes','') ; - jx.dom.set.value('latest_processes_label',label) + jx.dom.set.value('latest_processes_label', label) + var options = { width: $('#latest_processes').width(), height:'auto' } @@ -95,6 +112,11 @@ monitor.processes.render = function(label,data) { } else { jx.dom.hide('has_anomaly') } + // var hour = item.hour < 10? ('0'+item.hour): item.hour + // date = ([item.day + '-' + MONTHS[item.month] + '-' + item.year, hour + ':' + item.minute]).join(' ') + + jx.dom.set.value('node_last_lookup',monitor.utils.get.dateTime(item)) + } options.autoload = true @@ -144,7 +166,7 @@ monitor.processes.trend.render = function (logs, key,label) { conf.options = { legend: { position: 'bottom' } } conf.options.scales = {} conf.options.scales.yAxes = [ - {id:'0',scaleLabel:{display:true,labelString:' % CPU & MEMORY USAGE'},ticks:{min:0,max:100,beginAtZero:true},gridLines: {display:false}} + {id:'0',scaleLabel:{display:true,labelString:'CPU & MEMORY %'},ticks:{min:0,max:100,beginAtZero:true},gridLines: {display:false}} // {id:'1',position:'right',scaleLabel:{display:true,labelString:'PROCESS COUNT'},ticks:{min:0,stepSize:1,beginAtZero:true},gridLines: {display:false}} ] conf.options.scales.xAxes = [ @@ -153,7 +175,7 @@ monitor.processes.trend.render = function (logs, key,label) { gridLines: {display:false}, time: { - format:'DD-MMM HH:mm' + format:'HH:mm' } } @@ -166,12 +188,13 @@ monitor.processes.trend.render = function (logs, key,label) { var cpu = {label: 'CPU Usage (%)', data: [] ,backgroundColor:'transparent',borderColor:COLORS[187],fill:false,borderWidth:1} var mem = {label : 'Memory Usage(%)',data:[],backgroundColor:'transparent',borderColor:COLORS[32],fill:false,borderWidth:1} // var proc= {yAxisID:'1',label : 'Proc Count',data:[],backgroundColor:'transparent',borderColor:COLORS[542],fill:false,borderWidth:1} - var months={1:"Jan",2:"Feb",3:"Mar",4:"Apr",5:"May",6:"Jun",7:"Jul",8:"Aug",9:"Sep",10:"Oct",11:"Nov",12:"Dec"} + // var months={1:"Jan",2:"Feb",3:"Mar",4:"Apr",5:"May",6:"Jun",7:"Jul",8:"Aug",9:"Sep",10:"Oct",11:"Nov",12:"Dec"} jx.utils.patterns.visitor(logs,function(item){ //x = new Date(item.year,item.month-1,item.day,item.hour,item.minute) - day = item.day.length > 1? (['0',item.day]).join(''): item.day - month = months[item.month] - x = ([month,day,item.hour+':'+item.minute]).join(' ') + // day = item.day.length > 1? (['0',item.day]).join(''): item.day + // month = months[item.month] + // x = ([month, day, item.hour + ':' + item.minute]).join(' ') + x = monitor.utils.get.time(item).replace(/AM|PM/g,'') y = item[key] if (_x[x] == null ){//||(_x[x] == null && _y[y] == null)) { _x[x] = 1 @@ -186,7 +209,8 @@ monitor.processes.trend.render = function (logs, key,label) { }) - + var item = logs[logs.length - 1] + jx.dom.set.value('trend_last_lookup',monitor.utils.get.dateTime(item)) conf.data.datasets = [cpu,mem] x_axis = jx.utils.unique(x_axis) @@ -217,7 +241,8 @@ monitor.processes.summary.init = function(logs){ if (date == null) { // date = new Date(item.year,item.month-1,item.day,item.hour,item.minute) - date = ([item.day+'-'+MONTHS[item.month]+'-'+item.year,item.hour+':'+item.minute]).join(' ') + // date = ([item.day + '-' + MONTHS[item.month] + '-' + item.year, item.hour + ':' + item.minute]).join(' ') + date = monitor.utils.get.dateTime(item) } if (item.status == 'running'){ xr += 1 @@ -329,10 +354,11 @@ monitor.sandbox.init = function () { }) } monitor.sandbox.render = function (logs) { - months = { 1: 'Jan', 2: 'Feb', 3: 'Mar', 4: 'Apr', 5: 'May', 6: 'Jun', 7: 'Jul', 8: 'Aug', 9: 'Sep', 10: 'Oct', 11: 'Nov', 12: 'Dec' } + // months = { 1: 'Jan', 2: 'Feb', 3: 'Mar', 4: 'Apr', 5: 'May', 6: 'Jun', 7: 'Jul', 8: 'Aug', 9: 'Sep', 10: 'Oct', 11: 'Nov', 12: 'Dec' } - var d = ([logs[0].day, '-', MONTHS[logs[0].month], '-', logs[0].year, ' ', logs[0].hour, ':', logs[0].minute]).join('') - jx.dom.set.value('sandbox_date', d) + // var d = ([logs[0].day, '-', MONTHS[logs[0].month], '-', logs[0].year, ' ', logs[0].hour, ':', logs[0].minute]).join('') + var item = logs[logs.length -1] + jx.dom.set.value('sandbox_date', monitor.utils.get.datetime(item)) var options = { width: $('#sandbox_status').width()-8, height: 'auto' } options.data = jx.utils.patterns.visitor(logs, function (item) { diff --git a/src/api/templates/dashboard.html b/src/api/templates/dashboard.html index 43b9ea7..c032d48 100644 --- a/src/api/templates/dashboard.html +++ b/src/api/templates/dashboard.html @@ -37,11 +37,12 @@
-
+
-
Monitoring - +
Monitoring +
+
Last Lookup
@@ -87,7 +88,8 @@
CPU & Memory Usage Trend for
-
Anomaly Detected
+
Last Lookup
+