Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Allow switching RAM display between % and GB #149

Open
wants to merge 4 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 17 additions & 2 deletions app.js
Original file line number Diff line number Diff line change
Expand Up @@ -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', '')
Expand Down Expand Up @@ -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) {
Expand Down Expand Up @@ -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()
Expand Down
105 changes: 105 additions & 0 deletions package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
7 changes: 4 additions & 3 deletions sensors/process.js
100644 → 100755
Original file line number Diff line number Diff line change
Expand Up @@ -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.`,
Expand All @@ -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',
Expand Down Expand Up @@ -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
})
Expand Down