From d3883c8dca6bafbc4438acfe10c987769b5e2333 Mon Sep 17 00:00:00 2001 From: syuilo Date: Fri, 27 Jul 2018 18:42:58 +0900 Subject: [PATCH] Use os-utils --- package.json | 1 + src/daemons/server-stats.ts | 15 +++++++-------- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/package.json b/package.json index 7e45b02ba..ecc95d9d6 100644 --- a/package.json +++ b/package.json @@ -160,6 +160,7 @@ "nprogress": "0.2.0", "object-assign-deep": "0.4.0", "on-build-webpack": "0.1.0", + "os-utils": "0.0.14", "parse5": "5.0.0", "portscanner": "2.2.0", "progress-bar-webpack-plugin": "1.11.0", diff --git a/src/daemons/server-stats.ts b/src/daemons/server-stats.ts index de70cf40b..0c0a72f74 100644 --- a/src/daemons/server-stats.ts +++ b/src/daemons/server-stats.ts @@ -2,6 +2,7 @@ import * as os from 'os'; import * as sysUtils from 'systeminformation'; import * as diskusage from 'diskusage'; import Xev from 'xev'; +const osUtils = require('os-utils'); const ev = new Xev(); @@ -44,14 +45,12 @@ export default function() { } // CPU STAT -async function cpuUsage() { - try { - const data = await sysUtils.currentLoad(); - return Math.floor(data.currentload / 100); - } catch (error) { - console.error(error); - throw error; - } +function cpuUsage() { + return new Promise((res, rej) => { + osUtils.cpuUsage((cpuUsage: number) => { + res(cpuUsage); + }); + }); } // MEMORY(excl buffer + cache) STAT