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 🙏

© 2026 – Pkg Stats / Ryan Hefner

jsm-sysinfo

v0.0.2

Published

Comprehensive system monitoring implementation using the systeminformation npm package with TypeScript.

Readme

jsm-sysinfo

npm version License: MIT

comprehensive system monitoring implementation using the systeminformation npm package with TypeScript. This will provide structured JSON output with both raw values and human-readable formats.I've created a comprehensive system monitoring implementation using the systeminformation npm package with TypeScript. Here's what the implementation provides:

Installation

npm install jsm-sysinfo

Key Features:

  1. Structured JSON Output: Every piece of data includes:

    • name: Programmatic identifier
    • label: Human-readable label
    • value: Raw value
    • humanValue: Formatted, human-readable value
    • unit: Optional unit of measurement
  2. Comprehensive Monitoring Sections:

    • System Information (manufacturer, model, OS, etc.)
    • CPU Information (brand, cores, load, temperature)
    • Memory Information (RAM, swap usage)
    • Disk Information (physical disks and filesystems)
    • Network Information (interfaces and statistics)
    • Process Information (counts and top processes)
    • System Load & Uptime
    • Battery Information (if available)
  3. Utility Methods:

    • getSystemMonitoringData(): Get all system data at once
    • getSection(sectionName): Get specific section data
    • startMonitoring(): Continuous monitoring with callback
  4. Data Formatting:

    • Bytes to human-readable format (KB, MB, GB, etc.)
    • Percentages with decimal precision
    • Temperature formatting
    • Uptime formatting (days, hours, minutes, seconds)

Installation Requirements:

npm install jsm-sysinfo

Usage Examples:

import { SystemMonitor } from "jsm-sysinfo";

// One-time monitoring
const monitor = new SystemMonitor();
const data = await monitor.getSystemMonitoringData();
console.log(JSON.stringify(data, null, 2));

// Continuous monitoring
const intervalId = monitor.startMonitoring(5000, (data) => {
  // Process monitoring data every 5 seconds
  console.log(data);
});

// Get specific section
const cpuData = await monitor.getSection("cpu");

Example usage demonstrating various features of the SystemMonitor @example

import SystemMonitor, { IMonitorConfig } from "jsm-sysinfo";

async function demonstrateSystemMonitoring() {
  // Create monitor with custom configuration
  const config: IMonitorConfig = {
    includeTemperature: true,
    includeProcesses: true,
    maxProcesses: 10,
    includeNetworkStats: true,
    includeBattery: true,
    timeoutMs: 15000,
  };

  const monitor = new SystemMonitor(config);

  try {
    // Get quick overview
    console.log("=== System Summary ===");
    const summary = await monitor.getQuickSummary();
    Object.entries(summary).forEach(([key, value]) => {
      console.log(`${key}: ${value}`);
    });

    console.log("\n=== Full System Data ===");
    // Get complete system data
    const fullData = await monitor.collectAll();
    console.log(JSON.stringify(fullData, null, 2));

    // Get specific sections
    console.log("\n=== CPU Section Only ===");
    const cpuData = await monitor.getSection("cpu");
    if (cpuData) {
      cpuData.fields.forEach((field) => {
        console.log(`${field.label}: ${field.humanValue}`);
      });
    }

    // Start continuous monitoring
    console.log("\n=== Starting Continuous Monitoring ===");
    const stopMonitoring = monitor.startContinuousMonitoring(
      10000,
      (data, error) => {
        if (error) {
          console.error("Monitoring error:", error.message);
          return;
        }

        if (data) {
          const cpuSection = data.sections.find((s) => s.section === "CPU");
          const memSection = data.sections.find((s) => s.section === "Memory");

          const cpuLoad =
            cpuSection?.fields.find((f) => f.name === "currentLoad")
              ?.humanValue || "N/A";
          const memUsage =
            memSection?.fields.find((f) => f.name === "usagePercent")
              ?.humanValue || "N/A";

          console.log(
            `[${new Date().toLocaleTimeString()}] CPU: ${cpuLoad}, Memory: ${memUsage}`
          );
        }
      }
    );

    // Stop monitoring after 30 seconds
    setTimeout(() => {
      stopMonitoring();
      console.log("Continuous monitoring stopped");
    }, 30000);
  } catch (error: any) {
    console.error("System monitoring error:", error);
  }
}

// Run the demonstration
// demonstrateSystemMonitoring();

@example

// Simple usage for basic monitoring
import SystemMonitor from "jsm-sysinfo";

async function basicMonitoring() {
  const monitor = new SystemMonitor();

  // Get all data once
  const data = await monitor.collectAll();

  // Extract key metrics
  const cpuSection = data.sections.find((s) => s.section === "CPU");
  const memSection = data.sections.find((s) => s.section === "Memory");

  const cpuBrand = cpuSection?.fields.find(
    (f) => f.name === "brand"
  )?.humanValue;
  const cpuLoad = cpuSection?.fields.find(
    (f) => f.name === "currentLoad"
  )?.humanValue;
  const memTotal = memSection?.fields.find(
    (f) => f.name === "total"
  )?.humanValue;
  const memUsage = memSection?.fields.find(
    (f) => f.name === "usagePercent"
  )?.humanValue;

  console.log(`System: ${data.hostname}`);
  console.log(`CPU: ${cpuBrand} - Load: ${cpuLoad}`);
  console.log(`Memory: ${memUsage} of ${memTotal} used`);
  console.log(`Uptime: ${formatDuration(data.uptime)}`);
  console.log(`Data collected in ${data.summary.collectionTimeMs}ms`);
}

@example

// Advanced usage with custom configuration and filtering
import SystemMonitor, {
  IMonitoringSection,
  IMonitoringField,
} from "jsm-sysinfo";

async function advancedMonitoring() {
  const monitor = new SystemMonitor({
    includeTemperature: true,
    includeProcesses: true,
    maxProcesses: 3,
    includeNetworkStats: false,
    includeBattery: false,
  });

  const data = await monitor.collectAll();

  // Filter and display only performance-related metrics
  data.sections.forEach((section) => {
    console.log(`\n=== ${section.section} ===`);

    const performanceFields = section.fields.filter(
      (field) =>
        field.metadata?.category === "performance" ||
        field.metadata?.realtime === true
    );

    performanceFields.forEach((field) => {
      console.log(`  ${field.label}: ${field.humanValue}`);
      if (field.metadata?.sensitive) {
        console.log(`    [SENSITIVE DATA]`);
      }
    });
  });

  // Find all temperature readings
  const tempFields: IMonitoringField[] = [];
  data.sections.forEach((section) => {
    section.fields.forEach((field) => {
      if (field.metadata?.category === "thermal") {
        tempFields.push(field);
      }
    });
  });

  if (tempFields.length > 0) {
    console.log("\n=== Temperature Readings ===");
    tempFields.forEach((field) => {
      console.log(`  ${field.label}: ${field.humanValue}`);
    });
  }
}

The implementation follows TypeScript best practices with proper type definitions, error handling, and modular design. Each monitoring field provides both raw data for programmatic use and formatted values for display purposes.