From 9d4255e69efd4d9454ae723b61f5abc2a48494b6 Mon Sep 17 00:00:00 2001 From: Masayuki Igawa Date: Fri, 3 May 2019 16:44:04 -0600 Subject: [PATCH] Fix dstat graph processing This commit fixes dstat graph processing to draw a graph properly. There are two problem mainly. 1. Reading header process is not correct It looks the dstat output format was changed to remove a row of the header in the past. However, stackviz was not changed at that time. So, this commit fixes to deal with it properly. 2. The year in its logs process is not correct. With the original process which sets 1900+year after utcParse() call, it looks one hour difference occurs somehow. So, this commit sets the year to the date string directly. Change-Id: I52c321f4bd13475f3be2f1a9fbcd86a6ddd4e4be --- app/js/util/dstat-parse.js | 11 +++++------ 1 file changed, 5 insertions(+), 6 deletions(-) diff --git a/app/js/util/dstat-parse.js b/app/js/util/dstat-parse.js index 0f548cb..e13bc81 100644 --- a/app/js/util/dstat-parse.js +++ b/app/js/util/dstat-parse.js @@ -38,7 +38,7 @@ var parseDstat = function(data, year) { // assume UTC - may not necessarily be the case? // dstat doesn't include the year in its logs, so we'll need to copy it // from the subunit logs - var dateFormat = timeFormat.utcParse('%d-%m %H:%M:%S'); + var dateFormat = timeFormat.utcParse('%Y-%d-%m %H:%M:%S'); var parsed = dsv.csvParseRows(data, function(row, i) { if (i === 0) { @@ -47,13 +47,13 @@ var parseDstat = function(data, year) { !row[0].endsWith('CSV output')) { throw new Error('Invalid Dstat CSV'); } - } else if (i <= 4) { // header rows - ignore + } else if (i <= 3) { // header rows - ignore return null; - } else if (i === 5) { // primary + } else if (i === 4) { // primary primaryNames = row; fillArrayRight(primaryNames); return null; - } else if (i === 6) { // secondary + } else if (i === 5) { // secondary secondaryNames = row; names = mergeNames(primaryNames, secondaryNames); @@ -66,8 +66,7 @@ var parseDstat = function(data, year) { var value = row[col]; if (value && name) { if (name === 'system_time') { - value = dateFormat(value); - value.setFullYear(1900 + year); + value = dateFormat((1900 + year) + '-' + value); } else { value = parseFloat(value); }