var datum = null;
// the timestamp comes first
- var timestamp = match[1].replace('_','T');
+ var timestamp = match[1].replace('_','T') + 'Z';
// we are interested in "-- interval" recordings
var intervalMatch = match[6].match(/(.*) -- interval (.*)/);
// special calculation for cpus
if( /-cpu$/.test(series) ) {
- // divide the stat by the number of cpus
- var cpuCountMatch = intervalMatch[1].match(/(\d+) cpus/);
- if( cpuCountMatch ) {
- datum = datum / cpuCountMatch[1];
+ // divide the stat by the number of cpus unless the time count is less than the interval length
+ if( dsum.toFixed(1) > dt.toFixed(1) ) {
+ var cpuCountMatch = intervalMatch[1].match(/(\d+) cpus/);
+ if( cpuCountMatch ) {
+ datum = datum / cpuCountMatch[1];
+ }
}
}
var shifted = [];
// now let's see about "scrolling" the graph, dropping entries that are too old (>10 minutes)
while( jobGraphData.length > 0
- && (Date.parse( jobGraphData[0]['t'] ).valueOf() + 10*60000 < Date.parse( jobGraphData[jobGraphData.length-1]['t'] ).valueOf()) ) {
+ && (Date.parse( jobGraphData[0]['t'] ) + 10*60000 < Date.parse( jobGraphData[jobGraphData.length-1]['t'] )) ) {
shifted.push(jobGraphData.shift());
}
if( shifted.length > 0 ) {
- // from those that we dropped, are any of them maxima? if so we need to rescale
+ // from those that we dropped, were any of them maxima? if so we need to rescale
jobGraphSeries.forEach( function(series) {
// test that every shifted entry in this series was either not a number (in which case we don't care)
// or else approximately (to 2 decimal places) smaller than the scaled maximum (i.e. 1),
});
}
// add a 10 minute old null data point to keep the chart honest if the oldest point is less than 9.9 minutes old
- if( jobGraphData.length > 0
- && (Date.parse( jobGraphData[0]['t'] ).valueOf() + 9.9*60000 > Date.parse( jobGraphData[jobGraphData.length-1]['t'] ).valueOf()) ) {
- var tenMinutesBefore = (new Date(Date.parse( jobGraphData[jobGraphData.length-1]['t'] ).valueOf() - 600*1000)).toISOString().replace('Z','');
- jobGraphData.unshift( { 't': tenMinutesBefore } );
+ if( jobGraphData.length > 0 ) {
+ var earliestTimestamp = jobGraphData[0]['t'];
+ var mostRecentTimestamp = jobGraphData[jobGraphData.length-1]['t'];
+ if( (Date.parse( earliestTimestamp ) + 9.9*60000 > Date.parse( mostRecentTimestamp )) ) {
+ var tenMinutesBefore = (new Date(Date.parse( mostRecentTimestamp ) - 600*1000)).toISOString();
+ jobGraphData.unshift( { 't': tenMinutesBefore } );
+ }
}
}
var datum = options.data[index][series];
var point = ''
point += "<div class='morris-hover-point' style='color: ";
- point += options.lineColors[sortedIndex];
+ point += options.lineColors[sortedIndex % options.lineColors.length];
point += "'>";
var labelMatch = options.labels[sortedIndex].match(/^T(\d+)-(.*)/);
point += 'Task ' + labelMatch[1] + ' ' + labelMatch[2];
$(document).on('arv-log-event', '#log_graph_div', function(event, eventData) {
if( eventData.properties.text ) {
- processLogLineForChart( eventData.properties.text );
+ eventData.properties.text.split('\n').forEach( function( logLine ) {
+ processLogLineForChart( logLine );
+ } );
}
} );
window.redraw = false;
createJobGraph($(graph_div).attr('id'));
+ var object_uuid = $(graph_div).data('object-uuid');
+ // if there are any listeners for this object uuid or "all", we will trigger the event
+ var matches = ".arv-log-event-listener[data-object-uuid=\"" + object_uuid + "\"],.arv-log-event-listener[data-object-uuids~=\"" + object_uuid + "\"]";
$(document).trigger('ajax:send');
- $.get('/jobs/' + $(graph_div).data('object-uuid') + '/push_logs.js');
+ $.get('/jobs/' + $(graph_div).data('object-uuid') + '/logs.json', function(data) {
+ data.forEach( function( entry ) {
+ $(matches).trigger('arv-log-event', entry);
+ });
+ });
setInterval( function() {
if( recreate ) {