Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
api.get('/fs/:id/total', function(req, res) { // Total GB in File System (fs/[id]/used)
si.fsSize()
.then(data => res.send((data[parseInt(req.params.id)].size/(1024*1024*1024)).toString()))
.catch(error => res.status(404).send(siError))
})
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.'
function diskInfo ()
{
si.fsSize( ( disk ) => {
dUsed = helpers.prettyDiskSize( disk[0].used )
dTotal = helpers.prettyDiskSize( disk[0].size )
diskBar.animate( disk[0].use / 100 )
})
}
diskInfo()
this.gauge = this.grid.set(0, 0, 1, 1, contrib.gauge, {
label: this.labelTop,
stroke: 'red',
fill: 'white'
});
this.table = this.grid.set(1, 0, 1, 1, contrib.table, {
label: this.labelBottom,
width: '100%',
height: '100%',
columnWidth: [10, 15],
fg: 'white',
selectedBg: 'black'
});
si.fsSize(data => {
let disk = _.find(data, {fs: config.monitoredDisk});
this.gauge.setPercent(disk.use);
this.table.setData({
headers: ['Type', 'Space'],
data: [
['taken', (disk.used/(1024 * 1024 * 1024)).toFixed(2) + ' GB'],
['free', ((disk.size - disk.used)/(1024 * 1024 * 1024)).toFixed(2) + ' GB'],
['total', (disk.size/(1024 * 1024 * 1024)).toFixed(2) + ' GB']
]
});
this.draw();
});
}
function Disk(donut) {
this.donut = donut;
si.fsSize(data => {
this.updateData(data);
})
this.interval = setInterval(() => {
si.fsSize(data => {
this.updateData(data);
})
}, 10000);
}
export const UpdateFSInfo = () => {
var fssize = si.fsSize(function(fssize) {
var ioinfo = si.disksIO(function(ioinfo) {
var rwinfo = si.fsStats(function(rwinfo) {
SYSINFO.fs = {
fssize,
ioinfo,
rwinfo
}
})
})
})
}
export async function dynamicInfo(): Promise {
const osData = {
hostname: os.hostname(),
uptime: os.uptime(),
freemem: os.freemem(),
totalmem: os.totalmem(),
cpus: os.cpus(),
loadavg: os.loadavg()
}
const promises = [
si.battery(),
si.graphics(),
si.osInfo(),
si.fsSize(),
si.cpuTemperature()
];
const [battery, graphics, osInfo, fsSize, cpuTemp] = await Promise.all(promises);
return {
...osData,
battery,
graphics,
osInfo,
fsSize,
cpuTemp
};
}