npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

system-status

v1.0.0

Published

system-status is a NodeJS lib for statistical system data such as cpu, mem, network, disk.

Downloads

5

Readme

Language : 🇺🇸 English | 🇨🇳 简体中文

NPM Version NPM Downloads Bundle Size

GitHub Actions CI License

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

Getting Started

Prerequisites

  • Node.js (>= 10.4.0 required, LTS preferred)

Support Operating Systems

API Supported platforms (roughly ordered by completeness of support):

  1. FreeBSD
  2. Linux
  3. OpenBSD
  4. Windows
  5. macOS
  6. NetBSD
  7. 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-status

Documentation

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): FileSystem

blockDeviceStatistics (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): NetworkStats

batteryLife (Stat class instance method)

Get a battery life information object.

batteryLife(): BatteryLife

isAcPower (Stat class instance method)

Get whether AC power is plugged in.

isAcPower(): boolean

memory (Stat class instance method)

Get memory information.

memory(): Memory

swap (Stat class instance method)

Get swap memory information.

swap(): Memory

loadAverage (Stat class instance method)

Get load average.

loadAverage(): LoadAverage

uptime (Stat class instance method)

Get the system uptime.

uptime(): bigint

bootTime (Stat class instance method)

Get the system boot time.

bootTime(): Date

cpuLoadAggregate (Stat class instance method)

Get CPU load statistics, average over all CPUs (cores).

cpuLoadAggregate(): CPULoad

cpuTemp (Stat class instance method)

Get the current CPU temperature in degrees Celsius. Depending on the platform, this might be core 0, package, etc.

cpuTemp(): number

socketStats (Stat class instance method)

Get information about the number of sockets in use

socketStats(): SocketStats

format (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): ConvertResult

FileSystem (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 supported Node-API
  • Install [email protected]

Test in local

  • yarn
  • yarn build
  • yarn test

Release Notes

SEE CHANGELOG

Thanks

systemstat

napi-rs