サーバー情報ウィジェット
This commit is contained in:
@ -6,6 +6,9 @@ const ev = new Xev();
|
||||
|
||||
const interval = 2000;
|
||||
|
||||
const roundCpu = (num: number) => Math.round(num * 1000) / 1000;
|
||||
const round = (num: number) => Math.round(num * 10) / 10;
|
||||
|
||||
/**
|
||||
* Report server stats regularly
|
||||
*/
|
||||
@ -23,18 +26,18 @@ export default function() {
|
||||
const fsStats = await fs();
|
||||
|
||||
const stats = {
|
||||
cpu: cpu,
|
||||
cpu: roundCpu(cpu),
|
||||
mem: {
|
||||
used: memStats.used,
|
||||
active: memStats.active,
|
||||
used: round(memStats.used),
|
||||
active: round(memStats.active),
|
||||
},
|
||||
net: {
|
||||
rx: Math.max(0, netStats.rx_sec),
|
||||
tx: Math.max(0, netStats.tx_sec),
|
||||
rx: round(Math.max(0, netStats.rx_sec)),
|
||||
tx: round(Math.max(0, netStats.tx_sec)),
|
||||
},
|
||||
fs: {
|
||||
r: Math.max(0, fsStats.rIO_sec),
|
||||
w: Math.max(0, fsStats.wIO_sec),
|
||||
r: round(Math.max(0, fsStats.rIO_sec)),
|
||||
w: round(Math.max(0, fsStats.wIO_sec)),
|
||||
}
|
||||
};
|
||||
ev.emit('serverStats', stats);
|
||||
|
Reference in New Issue
Block a user