Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
exports.systemInfo = async function (cb) {
try {
cb({
cpu: await si.cpu(),
time: si.time(),
memory: await si.mem(),
system: await si.osInfo(),
versions: await si.versions(),
fs: await si.fsSize(),
load: await si.currentLoad(),
processes: await si.processes(),
network: {
interfaces: await si.networkInterfaces(),
stats: await si.networkStats(),
connections: await si.networkConnections()
},
process: {
uptime: process.uptime(),
version: process.version,
memoryUsage: process.memoryUsage(),
cpuUsage: process.cpuUsage()
}
});
} catch (e) {
console.error(e);
}
}
const poll = async () => {
cpuLoad = await SI.currentLoad();
mem = await SI.mem();
disk = await SI.fsSize();
processes = await SI.processes();
network = await SI.networkStats();
try {
cpuTemp = await SI.cpuTemperature();
if (!cpuTemp.cores.length) {
throw new Error('Cannot monitor CPU temperature');
}
} catch (e) {
cpuTemp = {
main: 0,
cores: Array(cpu.cores).fill(0),
max: 0
};
if (!tempFlag) {
console.warn(
'Cannot pull temperature data. On Linux, make sure `sensors` is available (package: lm-sensors). For OS X, install osx-temperature-sensor. Some CPUs are not supported on Windows.'
);
var updater = function() {
si.processes(data => {
that.updateData(data);
})
}
updater();