Comparing version 0.0.13 to 0.0.14
@@ -37,2 +37,24 @@ var _os = require('os'); | ||
exports.freeCommand = function(callback){ | ||
// Only Linux | ||
require('child_process').exec('free -m', function(error, stdout, stderr) { | ||
var lines = stdout.split("\n"); | ||
var str_mem_info = lines[1].replace( /[\s\n\r]+/g,' '); | ||
var mem_info = str_mem_info.split(' ') | ||
total_mem = parseFloat(mem_info[1]) | ||
free_mem = parseFloat(mem_info[3]) | ||
buffers_mem = parseFloat(mem_info[5]) | ||
cached_mem = parseFloat(mem_info[6]) | ||
used_mem = total_mem - (free_mem + buffers_mem + cached_mem) | ||
callback(used_mem -2); | ||
}); | ||
} | ||
@@ -75,5 +97,7 @@ | ||
command = 'ps aux | head -n '+ 11 | ||
command = 'ps -eo pcpu,pmem,time,args | sort -k 1 -r | head -n'+10 | ||
//command = 'ps aux | head -n '+ 11 | ||
//command = 'ps aux | head -n '+ (nProcess + 1) | ||
if (nProcess > 0) | ||
command = 'ps aux | head -n '+ (nProcess + 1) | ||
command = 'ps -eo pcpu,pmem,time,args | sort -k 1 -r | head -n'+(nProcess + 1) | ||
@@ -85,2 +109,3 @@ require('child_process').exec(command, function(error, stdout, stderr) { | ||
var lines = stdout.split("\n"); | ||
lines.shift() | ||
lines.pop() | ||
@@ -90,13 +115,14 @@ | ||
lines.forEach(function(_item,_i){ | ||
if (_i > 0){ | ||
var _str = _item.replace( /[\s\n\r]+/g,' '); | ||
var _str = _item.replace( /[\s\n\r]+/g,' '); | ||
_str = _str.split(' ') | ||
_str = _str.split(' ') | ||
result += _str[10]+" "+_str[9]+" "+_str[2]+" "+_str[3]+"\n"; | ||
} | ||
// result += _str[10]+" "+_str[9]+" "+_str[2]+" "+_str[3]+"\n"; // process | ||
result += _str[1]+" "+_str[2]+" "+_str[3]+" "+_str[4].substring((_str[4].length - 25))+"\n"; // process | ||
}); | ||
callback(result); | ||
@@ -103,0 +129,0 @@ }); |
{ | ||
"name" : "os-utils", | ||
"version" : "0.0.13", | ||
"version" : "0.0.14", | ||
"description" : "an operating-system utility library", | ||
@@ -5,0 +5,0 @@ "url" : "http://oscar-mejia.com", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
9303
187
3