system-status
v1.0.0
Published
system-status is a NodeJS lib for statistical system data such as cpu, mem, network, disk.
Maintainers
Readme
Language : 🇺🇸 English | 🇨🇳 简体中文
Overview
system-status is a NodeJS lib for statistical system data such as cpu, mem, network, disk.
Features
- 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
Table of Contents
- 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
- Release Notes
- Thanks
Getting Started
Prerequisites
- Node.js (>= 10.4.0 required, LTS preferred)
Support Operating Systems
API Supported platforms (roughly ordered by completeness of support):
- FreeBSD
- Linux
- OpenBSD
- Windows
- macOS
- NetBSD
- more coming soon
NPM Package Supported platforms
| | 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 | ✓ | ✓ | ✓ | ✓ |
Installation
npm install system-status
# or
yarn add system-status
# or
pnpm i system-statusDocumentation
Create Stat class instance in first
const stat = new Stat()mounts (Stat class instance method)
Get filesystem mount information.
mounts(): Array<FileSystem>mountAt (Stat class instance method)
Get a filesystem mount information for the filesystem at a given path.
mountAt(at: string): FileSystemblockDeviceStatistics (Stat class instance method)
Get block device statistics objects.
blockDeviceStatistics(): Array<BlockDeviceStats>networks (Stat class instance method)
Get network intefrace information.
networks(): Array<Network>networkStats (Stat class instance method)
Get statistics for a given interface name (bytes/packets sent/received).
networkStats(interface: string): NetworkStatsbatteryLife (Stat class instance method)
Get a battery life information object.
batteryLife(): BatteryLifeisAcPower (Stat class instance method)
Get whether AC power is plugged in.
isAcPower(): booleanmemory (Stat class instance method)
Get memory information.
memory(): Memoryswap (Stat class instance method)
Get swap memory information.
swap(): MemoryloadAverage (Stat class instance method)
Get load average.
loadAverage(): LoadAverageuptime (Stat class instance method)
Get the system uptime.
uptime(): bigintbootTime (Stat class instance method)
Get the system boot time.
bootTime(): DatecpuLoadAggregate (Stat class instance method)
Get CPU load statistics, average over all CPUs (cores).
cpuLoadAggregate(): CPULoadcpuTemp (Stat class instance method)
Get the current CPU temperature in degrees Celsius. Depending on the platform, this might be core 0, package, etc.
cpuTemp(): numbersocketStats (Stat class instance method)
Get information about the number of sockets in use
socketStats(): SocketStatsformat (Function)
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): ConvertResultFileSystem (Type)
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
}BlockDeviceStats (Type)
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
}Network (Type)
interface Network {
name: string
addrs: Array<NetworkAddrs>
}interface NetworkAddrs {
addr: string
netmask: string
addrType: AddrType
}const enum AddrType {
Ipv4 = 0,
IPv6 = 1,
}NetworkStats (Type)
interface NetworkStats {
rxBytes: bigint
txBytes: bigint
rxPackets: bigint
txPackets: bigint
rxErrors: bigint
txErrors: bigint
}BatteryLife (Type)
interface BatteryLife {
remainingCapacity: number
remainingTime: bigint
}Memory (Type)
interface Memory {
free: bigint
total: bigint
used: bigint
}LoadAverage (Type)
interface LoadAverage {
one: number
five: number
fifteen: number
}CPULoad (Type)
interface CPULoad {
user: number
nice: number
system: number
interrupt: number
idle: number
}ConvertResult (Type)
interface ConvertResult {
value: string
unit: string
}ConvertOption (Type)
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,
}How to Develop
Development requirements
- Install the latest
Rust - Install
Node.js@10+which fully supportedNode-API - Install
[email protected]
Test in local
- yarn
- yarn build
- yarn test
Release Notes
SEE CHANGELOG
