From 4b532db392c48ff7366baaf8a68bee9f4c27eabf Mon Sep 17 00:00:00 2001 From: Valentin Banshchikov Date: Tue, 10 Jun 2014 16:59:20 +0200 Subject: [PATCH] Replace ',' on '.' in cpu and mem. Fix #6 In my system command 'ps' returns strings in format "0,0 1,6 com.apple.WebKit.WebContent". Function "parseFloat(stats[stat].cpu / os.cpus().length);" returns NaN when 'cpu' has ',' in float, and returns correct answer with '.'. --- sensors/process.js | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/sensors/process.js b/sensors/process.js index eaa7615..63a7c28 100644 --- a/sensors/process.js +++ b/sensors/process.js @@ -60,8 +60,8 @@ var plugin = { //console.log(currentLine); var words = currentLine.split(" "); if (typeof words[0] !== 'undefined' && typeof words[1] !== 'undefined' ) { - var cpu = words[0]; - var mem = words[1]; + var cpu = words[0].replace(',', '.'); + var mem = words[1].replace(',', '.'); var offset = cpu.length + mem.length + 2; var comm = currentLine.slice(offset); // If we're on Mac then remove the path @@ -113,4 +113,4 @@ var plugin = { } }; -module.exports = exports = plugin; \ No newline at end of file +module.exports = exports = plugin;