From 3baf32703a404a96c445f76c769c5c0e82481b0f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Acid=20Chicken=20=28=E7=A1=AB=E9=85=B8=E9=B6=8F=29?= Date: Sun, 3 Feb 2019 23:41:27 +0900 Subject: [PATCH] Create type definition for 'os-utils' (#4050) --- src/@types/os-utils.d.ts | 30 ++++++++++++++++++++++++++++++ src/daemons/server-stats.ts | 2 +- 2 files changed, 31 insertions(+), 1 deletion(-) create mode 100644 src/@types/os-utils.d.ts diff --git a/src/@types/os-utils.d.ts b/src/@types/os-utils.d.ts new file mode 100644 index 000000000..390df17d3 --- /dev/null +++ b/src/@types/os-utils.d.ts @@ -0,0 +1,30 @@ +declare module 'os-utils' { + type FreeCommandCallback = (usedmem: number) => void; + + type HarddriveCallback = (total: number, free: number, used: number) => void; + + type GetProcessesCallback = (result: string) => void; + + type CPUCallback = (perc: number) => void; + + export function platform(): NodeJS.Platform; + export function cpuCount(): number; + export function sysUptime(): number; + export function processUptime(): number; + + export function freemem(): number; + export function totalmem(): number; + export function freememPercentage(): number; + export function freeCommand(callback: FreeCommandCallback): void; + + export function harddrive(callback: HarddriveCallback): void; + + export function getProcesses(callback: GetProcessesCallback): void; + export function getProcesses(nProcess: number, callback: GetProcessesCallback): void; + + export function allLoadavg(): string; + export function loadavg(_time?: number): number; + + export function cpuFree(callback: CPUCallback): void; + export function cpuUsage(callback: CPUCallback): void; +} diff --git a/src/daemons/server-stats.ts b/src/daemons/server-stats.ts index 6028277b2..b82f42177 100644 --- a/src/daemons/server-stats.ts +++ b/src/daemons/server-stats.ts @@ -3,7 +3,7 @@ import * as sysUtils from 'systeminformation'; import * as diskusage from 'diskusage'; import * as Deque from 'double-ended-queue'; import Xev from 'xev'; -const osUtils = require('os-utils'); +import * as osUtils from 'os-utils'; const ev = new Xev();