Skip to content

Commit

Permalink
Add more details about swap usage
Browse files Browse the repository at this point in the history
In addition to the used swap, display total and free swap as well as the percentage of used swap.
  • Loading branch information
City-busz authored Mar 28, 2024
1 parent c2348f1 commit 9a49363
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion sensors.js
Original file line number Diff line number Diff line change
Expand Up @@ -140,6 +140,8 @@ export const Sensors = GObject.registerClass({

let used = total - avail
let utilized = used / total;
let swapUsed = swapTotal - swapFree
let swapUtilized = swapUsed / swapTotal;

this._returnValue(callback, 'Usage', utilized, 'memory', 'percent');
this._returnValue(callback, 'memory', utilized, 'memory-group', 'percent');
Expand All @@ -148,7 +150,10 @@ export const Sensors = GObject.registerClass({
this._returnValue(callback, 'Allocated', used, 'memory', 'memory');
this._returnValue(callback, 'Cached', cached, 'memory', 'memory');
this._returnValue(callback, 'Free', memFree, 'memory', 'memory');
this._returnValue(callback, 'Swap', swapTotal - swapFree, 'memory', 'memory');
this._returnValue(callback, 'Swap Total', swapTotal, 'memory', 'memory');
this._returnValue(callback, 'Swap Free', swapFree, 'memory', 'memory');
this._returnValue(callback, 'Swap Used', swapUsed, 'memory', 'memory');
this._returnValue(callback, 'Swap Usage', swapUtilized, 'memory', 'percent');
}).catch(err => { });
}

Expand Down

0 comments on commit 9a49363

Please sign in to comment.