summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRichard Wall <richard@largo>2010-10-04 23:59:04 +0100
committerRichard Wall <richard@largo>2010-10-04 23:59:04 +0100
commitb0d9466ca1f987775c75cdf68607a0ae19a772ca (patch)
tree07bccb9a46299b3e3fe47aae5df5e53ac9342a23
parent319abdbf06a052180b61bc8f5be5eb272690b4f2 (diff)
add caps on the start and end times in rrd query
-rw-r--r--jarmon/jarmon.js23
1 files changed, 15 insertions, 8 deletions
diff --git a/jarmon/jarmon.js b/jarmon/jarmon.js
index 06ec4c8..406c4d1 100644
--- a/jarmon/jarmon.js
+++ b/jarmon/jarmon.js
@@ -216,14 +216,21 @@ jarmon.RrdQuery.prototype.getData = function(startTimeJs, endTimeJs, dsId, cfNam
var flotData = [];
var dsIndex = ds.getIdx();
- var startRowTime = startTime - startTime%step;
- var endRowTime = endTime - endTime%step;
-
- //console.log('FRT: ', new Date(startRowTime*1000));
- //console.log('ERT: ', new Date(endRowTime*1000));
- //console.log('LRT: ', new Date(lastRowTime*1000));
- //console.log('DIFF: ', (lastRowTime - startRowTime) / step);
- //console.log('ROWS: ', rraRowCount);
+ var startRowTime = Math.max(firstRowTime, startTime - startTime%step);
+ var endRowTime = Math.min(lastRowTime, endTime - endTime%step);
+ // If RRD exists, but hasn't been updated then the start time might end up
+ // being higher than the end time (which is capped at the last row time of
+ // the chosen RRA, so cap startTime at endTime...if you see what I mean)
+ startRowTime = Math.min(startRowTime, endRowTime);
+
+ /*
+ console.log('FRT: ', new Date(firstRowTime*1000));
+ console.log('LRT: ', new Date(lastRowTime*1000));
+ console.log('SRT: ', new Date(startRowTime*1000));
+ console.log('ERT: ', new Date(endRowTime*1000));
+ console.log('DIFF: ', (lastRowTime - startRowTime) / step);
+ console.log('ROWS: ', rraRowCount);
+ */
var startRowIndex = rraRowCount - (lastRowTime - startRowTime) / step;
var endRowIndex = rraRowCount - (lastRowTime - endRowTime) / step;