summaryrefslogtreecommitdiff
path: root/src/daemons/server-stats.ts
diff options
context:
space:
mode:
authorsyuilo <syuilotan@yahoo.co.jp>2021-01-03 22:38:32 +0900
committersyuilo <syuilotan@yahoo.co.jp>2021-01-03 22:38:32 +0900
commitc6fe79809286ca4a886a2a8e01efb4201bb5a2c1 (patch)
tree1c8bf0d7749e453e1113afead08fe6e433e9abb9 /src/daemons/server-stats.ts
parentFix CSS injection at MFM speed (#7051) (diff)
downloadsharkey-c6fe79809286ca4a886a2a8e01efb4201bb5a2c1.tar.gz
sharkey-c6fe79809286ca4a886a2a8e01efb4201bb5a2c1.tar.bz2
sharkey-c6fe79809286ca4a886a2a8e01efb4201bb5a2c1.zip
サーバー情報ウィジェット
Diffstat (limited to 'src/daemons/server-stats.ts')
-rw-r--r--src/daemons/server-stats.ts17
1 files changed, 10 insertions, 7 deletions
diff --git a/src/daemons/server-stats.ts b/src/daemons/server-stats.ts
index 88df421ba0..57691fbc00 100644
--- a/src/daemons/server-stats.ts
+++ b/src/daemons/server-stats.ts
@@ -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);