Add basic cpu info to processInfo global
All checks were successful
CI / CI (push) Successful in 1m23s
All checks were successful
CI / CI (push) Successful in 1m23s
This commit is contained in:
parent
aa2ab653b9
commit
a54361c571
3 changed files with 18 additions and 0 deletions
|
@ -49,6 +49,12 @@ client.whitelist = {
|
||||||
user: new Collection()
|
user: new Collection()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
client.processInfo = {
|
||||||
|
cpuPercentage: 0,
|
||||||
|
ramUsage: 0,
|
||||||
|
previousCpuUsage: process.cpuUsage()
|
||||||
|
}
|
||||||
|
|
||||||
createAndLoadWhitelistTable(client.whitelist);
|
createAndLoadWhitelistTable(client.whitelist);
|
||||||
|
|
||||||
client.settings.set("presenceType", presenceType);
|
client.settings.set("presenceType", presenceType);
|
||||||
|
|
|
@ -1,6 +1,7 @@
|
||||||
const loadServerPrefixes = require('../util/loadServerPrefixes');
|
const loadServerPrefixes = require('../util/loadServerPrefixes');
|
||||||
const checkTimer = require('../util/timer/checkTimer');
|
const checkTimer = require('../util/timer/checkTimer');
|
||||||
const updatePresence = require('../util/updatePresence');
|
const updatePresence = require('../util/updatePresence');
|
||||||
|
const updateCpuPercentage = require('../util/updateCpuPercentage')
|
||||||
|
|
||||||
module.exports = function(client, enableLoginMessage, loginChannel, loginMessage) {
|
module.exports = function(client, enableLoginMessage, loginChannel, loginMessage) {
|
||||||
updatePresence(client)
|
updatePresence(client)
|
||||||
|
@ -13,4 +14,5 @@ module.exports = function(client, enableLoginMessage, loginChannel, loginMessage
|
||||||
}
|
}
|
||||||
loadServerPrefixes(client)
|
loadServerPrefixes(client)
|
||||||
checkTimer(client);
|
checkTimer(client);
|
||||||
|
updateCpuPercentage(client.processInfo);
|
||||||
}
|
}
|
||||||
|
|
10
util/updateCpuPercentage.js
Normal file
10
util/updateCpuPercentage.js
Normal file
|
@ -0,0 +1,10 @@
|
||||||
|
const os = require('os');
|
||||||
|
const updateCpuPercentage = require('./updateCpuPercentage');
|
||||||
|
module.exports = async function (processInfo) {
|
||||||
|
const newCpuUsage = process.cpuUsage(processInfo.cpuPercentage);
|
||||||
|
processInfo.previousCpuUsage = process.cpuUsage();
|
||||||
|
processInfo.cpuPercentage = (newCpuUsage.system + newCpuUsage.user) / 60_000_000 / os.cpus().length;
|
||||||
|
|
||||||
|
setTimeout(updateCpuPercentage, 60000, processInfo);
|
||||||
|
}
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue