Merge branch 'community' of http://dev.the-phi.com/git/steve/monitor into community

community
Steve L. Nyemba 8 years ago
commit 43ba8fe1ac

@ -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:

@ -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) {

@ -37,11 +37,12 @@
</div>
<div class="left info ">
<div class="shadow border-right" style="; margin:4px; margin-top:2%">
<div class="shadow border-right" style="margin:4px; margin-top:2%">
<div class="" style="height:28px; ">
<div class="left bold">Monitoring
<span id="latest_processes_label" class="default bold"></span>
<div class=" bold">Monitoring
<span id="latest_processes_label" class="default bold"></span>
</div>
<div class="small">Last Lookup <span id="node_last_lookup"></span></div>
</div>
@ -87,7 +88,8 @@
<div class="shadow simple-gradient" style="padding:4px; margin-top:2%">
<div class="" style="height:28px">
<div class="small bold">CPU & Memory Usage Trend for <i class="fa fa-quote-left"></i> <span id="trend_info" class="default bold"></span> <i class="fa fa-quote-right"></i></div>
<div class="smal" style="float:none"><div id="has_anomaly" class="small"><i class="fa fa-warning" ></i> Anomaly Detected</div></div>
<div class="small">Last Lookup <span id="trend_last_lookup"></span> <i id="has_anomaly" class="fa fa-warning right" ></i></div>
</div>

Loading…
Cancel
Save