Language : 🇺🇸 English | 🇨🇳 简体ä¸ć–‡
system-status
is a NodeJS lib for statistical system data such as cpu, mem, network, disk.
- CPU load
- load average
- memory usage
- uptime / boot time
- battery life
- filesystem mounts (and disk usage)
- disk I/O statistics
- network interfaces
- network traffic statistics
- CPU temperature
- Overview
- Features
- Table of Contents
- Getting Started
- Documentation
mounts
(Stat class instance method)mountAt
(Stat class instance method)blockDeviceStatistics
(Stat class instance method)networks
(Stat class instance method)networkStats
(Stat class instance method)batteryLife
(Stat class instance method)isAcPower
(Stat class instance method)memory
(Stat class instance method)swap
(Stat class instance method)loadAverage
(Stat class instance method)uptime
(Stat class instance method)bootTime
(Stat class instance method)cpuLoadAggregate
(Stat class instance method)cpuTemp
(Stat class instance method)socketStats
(Stat class instance method)format
(Function)FileSystem
(Type)BlockDeviceStats
(Type)Network
(Type)NetworkStats
(Type)BatteryLife
(Type)Memory
(Type)LoadAverage
(Type)CPULoad
(Type)ConvertResult
(Type)ConvertOption
(Type)
- How to Develop
- Found an issue or have a proposal
- Release Notes
- Thanks
- Node.js (>= 10.4.0 required, LTS preferred)
- FreeBSD
- Linux
- OpenBSD
- Windows
- macOS
- NetBSD
- more coming soon
node12 | node14 | node16 | node18 | |
---|---|---|---|---|
Windows x64 | âś“ | âś“ | âś“ | âś“ |
Windows x86 | âś“ | âś“ | âś“ | âś“ |
Windows arm64 | âś“ | âś“ | âś“ | âś“ |
macOS x64 | âś“ | âś“ | âś“ | âś“ |
macOS aarch64 | âś“ | âś“ | âś“ | âś“ |
Linux x64 gnu | âś“ | âś“ | âś“ | âś“ |
Linux x64 musl | âś“ | âś“ | âś“ | âś“ |
Linux aarch64 gnu | âś“ | âś“ | âś“ | âś“ |
Linux aarch64 musl | âś“ | âś“ | âś“ | âś“ |
FreeBSD x64 | âś“ | âś“ | âś“ | âś“ |
npm install system-status
# or
yarn add system-status
# or
pnpm i system-status
Create Stat
class instance in first
const stat = new Stat()
Get filesystem mount information.
mounts(): Array<FileSystem>
Get a filesystem mount information for the filesystem at a given path.
mountAt(at: string): FileSystem
Get block device statistics objects.
blockDeviceStatistics(): Array<BlockDeviceStats>
Get network intefrace information.
networks(): Array<Network>
Get statistics for a given interface name (bytes/packets sent/received).
networkStats(interface: string): NetworkStats
Get a battery life information object.
batteryLife(): BatteryLife
Get whether AC power is plugged in.
isAcPower(): boolean
Get memory information.
memory(): Memory
Get swap memory information.
swap(): Memory
Get load average.
loadAverage(): LoadAverage
Get the system uptime.
uptime(): bigint
Get the system boot time.
bootTime(): Date
Get CPU load statistics, average over all CPUs (cores).
cpuLoadAggregate(): CPULoad
Get the current CPU temperature in degrees Celsius. Depending on the platform, this might be core 0, package, etc.
cpuTemp(): number
Get information about the number of sockets in use
socketStats(): SocketStats
Format the source by ConvertOption
The default of ConvertOption is taking 1024 as the advancement, retain one decimal place
function format(source: bigint, option?: ConvertOption | undefined | null): ConvertResult
interface FileSystem {
/** Used file nodes in filesystem */
files: bigint
/** Total file nodes in filesystem */
filesTotal: bigint
/** Free nodes available to non-superuser */
filesAvail: bigint
/** Free bytes in filesystem */
free: bigint
/** Free bytes available to non-superuser */
avail: bigint
/** Total bytes in filesystem */
total: bigint
/** Maximum filename length */
nameMax: bigint
fsType: string
fsMountedFrom: string
fsMountedOn: string
}
interface BlockDeviceStats {
name: string
readIos: bigint
readMerges: bigint
readSectors: bigint
readTicks: bigint
writeIos: bigint
writeMerges: bigint
writeSectors: bigint
writeTicks: bigint
inFlight: bigint
ioTicks: bigint
timeInQueue: bigint
}
interface Network {
name: string
addrs: Array<NetworkAddrs>
}
interface NetworkAddrs {
addr: string
netmask: string
addrType: AddrType
}
const enum AddrType {
Ipv4 = 0,
IPv6 = 1,
}
interface NetworkStats {
rxBytes: bigint
txBytes: bigint
rxPackets: bigint
txPackets: bigint
rxErrors: bigint
txErrors: bigint
}
interface BatteryLife {
remainingCapacity: number
remainingTime: bigint
}
interface Memory {
free: bigint
total: bigint
used: bigint
}
interface LoadAverage {
one: number
five: number
fifteen: number
}
interface CPULoad {
user: number
nice: number
system: number
interrupt: number
idle: number
}
interface ConvertResult {
value: string
unit: string
}
interface ConvertOption {
advance: Advance
/** Decimal point */
precision: number
}
/**
* unit enum for stat option
* B -> KB, 1000 bytes
* B -> KIB, 1024 bytes
*/
export const enum Advance {
/** 1000 */
Kilobase = 1000,
/** 1024 */
Binary = 1024,
}
- Install the latest
Rust
- Install
Node.js@10+
which fully supportedNode-API
- Install
yarn@1.x
- yarn
- yarn build
- yarn test
SEE CHANGELOG