Steve L. Nyemba 8 years ago
commit 056fef24c6

@ -53,9 +53,15 @@ f.close()
# #
from threading import Thread, RLock from threading import Thread, RLock
p = {'uri':'http://dev.the-phi.com:5984','dbname':'monitor','uid':'logs','filename':'logs.JSON'} p = {'uri':'http://dev.the-phi.com:5984','dbname':'monitor','uid':'logs','filename':'logs.JSON'}
p = CONFIG['store']['args']
class_read = CONFIG['store']['class']['read']
class_write= CONFIG['store']['class']['write']
factory = DataSourceFactory() factory = DataSourceFactory()
gWriter = factory.instance(type='CouchdbWriter',args=p) #gWriter = factory.instance(type='CouchdbWritera',args=p)
gReader = factory.instance(type='CouchdbReader',args=p) #gReader = factory.instance(type='CouchdbReader',args=p)
gReader = factory.instance(type=class_read,args=p)
gWriter = factory.instance(type=class_write,args=p)
mthread = monitor.Monitor(HANDLERS,gWriter,'processes',) mthread = monitor.Monitor(HANDLERS,gWriter,'processes',)
@app.route('/get/<id>') @app.route('/get/<id>')
@ -101,8 +107,8 @@ def trends ():
series = [] series = []
for row in r: for row in r:
series += [item for item in row if str(item['label'])== app] series += [item for item in row if str(item['label'])== app]
if len(series) > 24 : if len(series) > 12 :
beg = len(series) - 25 beg = len(series) - 13
series = series[beg:] series = series[beg:]
return json.dumps(series) return json.dumps(series)
else: else:

@ -38,6 +38,12 @@ monitor.processes.init = function(x){
jx.dom.get.children('menu')[0].click() jx.dom.get.children('menu')[0].click()
setTimeout(monitor.sandbox.init,3000) setTimeout(monitor.sandbox.init,3000)
} }
/**
* This function renders the grid of processes being monitored,
* @param label label the list of processes belongs to
* @param data dataset of a selected set of processes (works a bit like top)
*/
monitor.processes.render = function(label,data) { monitor.processes.render = function(label,data) {
data = jx.utils.patterns.visitor(data,function(row){ data = jx.utils.patterns.visitor(data,function(row){
@ -55,9 +61,9 @@ monitor.processes.render = function(label,data) {
width: $('#latest_processes').width(), height:'auto' width: $('#latest_processes').width(), height:'auto'
} }
options.paging = true options.paging = true
options.pageSize = 3 options.pageSize = 4
options.pageIndex = 1 options.pageIndex = 1
options.pageButtonCount = 3 options.pageButtonCount = 4
options.pagerContainer = '#latest_process_pager' options.pagerContainer = '#latest_process_pager'
options.pagerFormat= "{prev} Page {pageIndex} of {pageCount} {next}" options.pagerFormat= "{prev} Page {pageIndex} of {pageCount} {next}"
options.pagePrevText= '<i class="fa fa-chevron-left"></i>' options.pagePrevText= '<i class="fa fa-chevron-left"></i>'
@ -114,8 +120,10 @@ monitor.processes.trend.render = function (logs, key,label) {
var frame = $('#trends_chart') var frame = $('#trends_chart')
jx.dom.set.value('trends_chart','') jx.dom.set.value('trends_chart','')
var context = jx.dom.get.instance('CANVAS') var context = jx.dom.get.instance('CANVAS')
context.width = $(frame).width()
context.height= $(frame).height()
var conf = { type: 'line',responsive:true,maintainAspectRatio:true } var conf = { type: 'line',responsive:true }
conf.data = {} conf.data = {}
conf.options = { legend: { position: 'bottom' } } conf.options = { legend: { position: 'bottom' } }
conf.options.scales = {} conf.options.scales = {}
@ -268,19 +276,22 @@ monitor.sandbox.init = function () {
var httpclient = HttpClient.instance() var httpclient = HttpClient.instance()
httpclient.get('/sandbox', function (x) { httpclient.get('/sandbox', function (x) {
var r = JSON.parse(x.responseText) var r = JSON.parse(x.responseText)
if (r.length > 0){
monitor.sandbox.render(r); monitor.sandbox.render(r);
}
}) })
} }
monitor.sandbox.render = function (logs) { 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('') 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) jx.dom.set.value('sandbox_date',d)
var options = {width:$('#sandbox_status').width(),height:'auto'} var options = {width:$('#sandbox_status').width(),height:'auto'}
options.data = logs options.data = logs
options.paging = true options.paging = true
options.pageSize = 3 options.pageSize = 4
options.pageIndex = 1 options.pageIndex = 1
options.pageButtonCount = 3 options.pageButtonCount = 4
options.pagerContainer = '#latest_process_pager' options.pagerContainer = '#latest_process_pager'
options.pagerFormat= "{prev} Page {pageIndex} of {pageCount} {next}" options.pagerFormat= "{prev} Page {pageIndex} of {pageCount} {next}"
options.pagePrevText= '<i class="fa fa-chevron-left"></i>' options.pagePrevText= '<i class="fa fa-chevron-left"></i>'

@ -65,8 +65,8 @@
<div class="left menu-item small padding-2x margin-2x" onclick="monitor.processes.trend.render(null,'memory_usage',null)"><i class="fa fa-chevron-right" ></i> Mem. Used</div> <div class="left menu-item small padding-2x margin-2x" onclick="monitor.processes.trend.render(null,'memory_usage',null)"><i class="fa fa-chevron-right" ></i> Mem. Used</div>
<div class="left menu-item small padding-2x margin-2x" onclick="monitor.processes.trend.render(null,'memory_available',null)"><i class="fa fa-chevron-right"></i> Mem. Avail</div> <div class="left menu-item small padding-2x margin-2x" onclick="monitor.processes.trend.render(null,'memory_available',null)"><i class="fa fa-chevron-right"></i> Mem. Avail</div>
</div> </div>
<div style="height:255px"> <div style="height:270px">
<div id="trends_chart" class="small grid"></div> <div id="trends_chart" class="small grid" style="height:250px"></div>
</div> </div>
<div class="border-top" style="padding:4px;"> <div class="border-top" style="padding:4px;">
<div style="height:48px"> <div style="height:48px">

Loading…
Cancel
Save