diff --git a/app.js b/app.js index d39ed08..78faa9f 100644 --- a/app.js +++ b/app.js @@ -13,7 +13,10 @@ const App = ((() => { const path = require('path') let themes = '' let program = blessed.program() - + + // Total memory of the system in GB + const mem_2 = os.totalmem()/(Math.pow(10, 9)) + const files = glob.sync(path.join(__dirname, 'themes', '*.json')) for (var i = 0; i < files.length; i++) { let themeName = files[i].replace(path.join(__dirname, 'themes') + path.sep, '').replace('.json', '') @@ -154,7 +157,9 @@ const App = ((() => { 'g': 'Jump to top', 'G': 'Jump to bottom', 'c': 'Sort by CPU', - 'm': 'Sort by Mem' + 'm': 'Sort by Mem', + 'p': 'Memory usage in percentage', + 'b': 'Memory usage in GB' } let text = '' for (const c in commands) { @@ -457,6 +462,16 @@ const App = ((() => { childProcess.exec(`killall "${selectedProcess}"`, () => {}) } + // Key to display memory usage in GB + if(key.name === 'b'){ + charts[2].plugin.mem1 = mem_2/100 + } + + // Key to display memory usage in percentage + if(key.name === 'p'){ + charts[2].plugin.mem1 = 1 + } + if (key.name === 'c' && charts[2].plugin.sort !== 'cpu') { charts[2].plugin.sort = 'cpu' charts[2].plugin.poll() diff --git a/package-lock.json b/package-lock.json new file mode 100644 index 0000000..aea9ba4 --- /dev/null +++ b/package-lock.json @@ -0,0 +1,105 @@ +{ + "name": "vtop", + "version": "0.6.1", + "lockfileVersion": 1, + "requires": true, + "dependencies": { + "balanced-match": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/balanced-match/-/balanced-match-1.0.0.tgz", + "integrity": "sha1-ibTRmasr7kneFk6gK4nORi1xt2c=" + }, + "blessed": { + "version": "0.1.81", + "resolved": "https://registry.npmjs.org/blessed/-/blessed-0.1.81.tgz", + "integrity": "sha1-+WLWh+wsNpVwrnGvhDJW5tDKESk=" + }, + "brace-expansion": { + "version": "1.1.11", + "resolved": "https://registry.npmjs.org/brace-expansion/-/brace-expansion-1.1.11.tgz", + "integrity": "sha512-iCuPHDFgrHX7H2vEI/5xpz07zSHB00TpugqhmYtVmMO6518mCuRMoOYFldEBl0g187ufozdaHgWKcYFb61qGiA==", + "requires": { + "balanced-match": "^1.0.0", + "concat-map": "0.0.1" + } + }, + "commander": { + "version": "2.11.0", + "resolved": "https://registry.npmjs.org/commander/-/commander-2.11.0.tgz", + "integrity": "sha512-b0553uYA5YAEGgyYIGYROzKQ7X5RAqedkfjiZxwi0kL1g3bOaBNNZfYkzt/CL0umgD5wc9Jec2FbB98CjkMRvQ==" + }, + "concat-map": { + "version": "0.0.1", + "resolved": "https://registry.npmjs.org/concat-map/-/concat-map-0.0.1.tgz", + "integrity": "sha1-2Klr13/Wjfd5OnMDajug1UBdR3s=" + }, + "drawille": { + "version": "1.1.0", + "resolved": "https://registry.npmjs.org/drawille/-/drawille-1.1.0.tgz", + "integrity": "sha1-X3zsJG0xtaEARL6Ezt2aSG+jHO0=" + }, + "fs.realpath": { + "version": "1.0.0", + "resolved": "https://registry.npmjs.org/fs.realpath/-/fs.realpath-1.0.0.tgz", + "integrity": "sha1-FQStJSMVjKpA20onh8sBQRmU6k8=" + }, + "glob": { + "version": "7.1.2", + "resolved": "https://registry.npmjs.org/glob/-/glob-7.1.2.tgz", + "integrity": "sha512-MJTUg1kjuLeQCJ+ccE4Vpa6kKVXkPYJ2mOCQyUuKLcLQsdrMCpBPUi8qVE6+YuaJkozeA9NusTAw3hLr8Xe5EQ==", + "requires": { + "fs.realpath": "^1.0.0", + "inflight": "^1.0.4", + "inherits": "2", + "minimatch": "^3.0.4", + "once": "^1.3.0", + "path-is-absolute": "^1.0.0" + } + }, + "inflight": { + "version": "1.0.6", + "resolved": "https://registry.npmjs.org/inflight/-/inflight-1.0.6.tgz", + "integrity": "sha1-Sb1jMdfQLQwJvJEKEHW6gWW1bfk=", + "requires": { + "once": "^1.3.0", + "wrappy": "1" + } + }, + "inherits": { + "version": "2.0.4", + "resolved": "https://registry.npmjs.org/inherits/-/inherits-2.0.4.tgz", + "integrity": "sha512-k/vGaX4/Yla3WzyMCvTQOXYeIHvqOKtnqBduzTHpzpQZzAskKMhZ2K+EnBiSM9zGSoIFeMpXKxa4dYeZIQqewQ==" + }, + "minimatch": { + "version": "3.0.4", + "resolved": "https://registry.npmjs.org/minimatch/-/minimatch-3.0.4.tgz", + "integrity": "sha512-yJHVQEhyqPLUTgt9B83PXu6W3rx4MvvHvSUvToogpwoGDOUQ+yDrR0HRot+yOCdCO7u4hX3pWft6kWBBcqh0UA==", + "requires": { + "brace-expansion": "^1.1.7" + } + }, + "once": { + "version": "1.4.0", + "resolved": "https://registry.npmjs.org/once/-/once-1.4.0.tgz", + "integrity": "sha1-WDsap3WWHUsROsF9nFC6753Xa9E=", + "requires": { + "wrappy": "1" + } + }, + "os-utils": { + "version": "0.0.14", + "resolved": "https://registry.npmjs.org/os-utils/-/os-utils-0.0.14.tgz", + "integrity": "sha1-KeURaXsZgrjGJ3Ihdf45eX72QVY=" + }, + "path-is-absolute": { + "version": "1.0.1", + "resolved": "https://registry.npmjs.org/path-is-absolute/-/path-is-absolute-1.0.1.tgz", + "integrity": "sha1-F0uSaHNVNP+8es5r9TpanhtcX18=" + }, + "wrappy": { + "version": "1.0.2", + "resolved": "https://registry.npmjs.org/wrappy/-/wrappy-1.0.2.tgz", + "integrity": "sha1-tSQ9jz7BqjXxNkYFvA0QNuMKtp8=" + } + } +} diff --git a/package.json b/package.json index 096cd86..39b93e0 100644 --- a/package.json +++ b/package.json @@ -31,10 +31,10 @@ "license": "MIT", "readmeFilename": "README.md", "dependencies": { - "blessed": "0.1.81", - "commander": "2.11.0", - "drawille": "1.1.0", - "glob": "7.1.2", + "blessed": "^0.1.81", + "commander": "^2.11.0", + "drawille": "^1.1.0", + "glob": "^7.1.2", "husky": "^0.14.3", "os-utils": "0.0.14", "read": "1.0.7", diff --git a/sensors/process.js b/sensors/process.js old mode 100644 new mode 100755 index 8576bdd..21cd829 --- a/sensors/process.js +++ b/sensors/process.js @@ -14,6 +14,7 @@ const plugin = { * * This appears in the title of the graph */ title: 'Process List', + mem1: 1, description: ` This returns a process list, grouped by executable name. CPU % is divided by the number of cores. 100% CPU Usage is all cores being maxed out. Unlike other tools that define the maximum as 800% for 8 cores for example.`, @@ -32,12 +33,12 @@ const plugin = { sort: 'cpu', - columns: ['Command', 'CPU %', 'Count', 'Memory %'], + columns: ['Command', 'CPU %', 'Count', 'Memory'], currentValue: [{ 'Command': 'Google Chrome', 'Count': '4', 'CPU %': '0.4', - 'Memory %': '1' + 'Memory': '1' }, { 'Command': 'Sublime Text 2', 'Count': '1', @@ -105,7 +106,7 @@ const plugin = { 'Command': stats[stat].comm, 'Count': stats[stat].count, 'CPU %': cpuRounded, - 'Memory %': memRounded, + 'Memory': memRounded*plugin.mem1, 'cpu': stats[stat].cpu, 'mem': stats[stat].mem // exact cpu for comparison })