Skip to content

Commit

Permalink
Replace ',' on '.' in cpu and mem. Fix #6
Browse files Browse the repository at this point in the history
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 '.'.
  • Loading branch information
Valentin Banshchikov committed Jun 10, 2014
1 parent e308024 commit 4b532db
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions sensors/process.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -113,4 +113,4 @@ var plugin = {
}
};

module.exports = exports = plugin;
module.exports = exports = plugin;

0 comments on commit 4b532db

Please sign in to comment.