From 4e5545af384f610a56b3d19ea73c3b801b0be6c6 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 9 Jun 2017 01:03:54 +0900 Subject: nanka iroiro --- src/utils/stats.ts | 25 +++++++++++++++++++++++++ 1 file changed, 25 insertions(+) create mode 100644 src/utils/stats.ts (limited to 'src/utils') diff --git a/src/utils/stats.ts b/src/utils/stats.ts new file mode 100644 index 0000000000..1615268310 --- /dev/null +++ b/src/utils/stats.ts @@ -0,0 +1,25 @@ +import * as os from 'os'; +const osUtils = require('os-utils'); +import * as diskusage from 'diskusage'; +import Xev from 'xev'; + +const ev = new Xev(); + +/** + * Report stats regularly + */ +export default function() { + setInterval(() => { + osUtils.cpuUsage(cpuUsage => { + const disk = diskusage.checkSync(os.platform() == 'win32' ? 'c:' : '/'); + ev.emit('stats', { + cpu_usage: cpuUsage, + mem: { + total: os.totalmem(), + free: os.freemem() + }, + disk + }); + }); + }, 1000); +} -- cgit v1.2.3-freya