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 🙏

© 2025 – Pkg Stats / Ryan Hefner

@peaseernest/system-info

v2.0.0

Published

Professional Node.js library for retrieving system information with actual usable data. Features beautiful console output powered by ernest-logger v2.0, TypeScript support, caching, monitoring, and health checks.

Downloads

19

Readme

🚀 System Info Pro

npm version MIT License Node.js Powered by ernest-logger

A professional Node.js library for retrieving and working with system information. Unlike other libraries that only log data, System Info Pro gives you actual usable data you can programmatically work with. Features beautiful console output powered by ernest-logger v2.0 🎨

🎯 Why This Library?

  • Returns actual data - not just console logs
  • TypeScript support - full type definitions
  • Real-time monitoring - watch system metrics change
  • Health checks - built-in health summary for APIs
  • Caching - performance optimization built-in
  • Plugins - extend with custom functionality
  • Zero config - works out of the box

📦 Installation

npm install @peaseernest/system-info

Optional dependencies (install for full functionality):

npm install ping systeminformation ernest-logger

🚀 Quick Start

const systemInfo = require('@peaseernest/system-info');

// Get memory info and USE it
const memory = await systemInfo.getMemory();
console.log(`Using ${memory.usedPercent}% of RAM`);

if (memory.usedPercent > 80) {
  console.log('⚠️ High memory usage!');
}

// Get everything at once
const all = await systemInfo.getAll();
console.log(all);

💡 Real-World Examples

1️⃣ Health Check API Endpoint

app.get('/health', async (req, res) => {
  const health = await systemInfo.getHealthSummary();
  
  res.status(health.status === 'healthy' ? 200 : 503).json({
    status: health.status,
    memory: health.memory.usedPercent,
    cpu: health.cpu.usage,
    issues: health.issues,
    warnings: health.warnings
  });
});

2️⃣ Adaptive Task Scheduler

async function scheduleTask() {
  const memory = await systemInfo.getMemory();
  const cpu = await systemInfo.getCpu();
  
  // Adjust concurrency based on system load
  const maxConcurrent = 
    (memory.usedPercent > 80 || cpu.usage > 80) ? 2 :
    (memory.usedPercent > 60 || cpu.usage > 60) ? 5 : 10;
  
  await runTasks(maxConcurrent);
}

3️⃣ Real-Time Monitoring Dashboard

const stop = await systemInfo.monitor((err, data) => {
  const dashboard = {
    cpu: `${data.cpu.usage}%`,
    memory: `${data.memory.usedPercent}%`,
    uptime: data.basic.uptime.formatted
  };
  
  io.emit('system-update', dashboard);
}, 1000);

4️⃣ Export System Report

const report = await systemInfo.getAll();
fs.writeFileSync('report.json', JSON.stringify(report, null, 2));

5️⃣ Send Metrics to Monitoring Service

const data = await systemInfo.getAll();

await axios.post('https://monitoring.service/metrics', {
  host: data.basic.hostname,
  metrics: {
    'cpu.usage': data.cpu.usage,
    'memory.used': data.memory.usedPercent,
    'uptime': data.basic.uptimeSeconds
  }
});

📚 API Reference

Data Retrieval Methods

All methods return actual data objects you can work with:

| Method | Returns | Description | |--------|---------|-------------| | getBasic() | Promise<BasicInfo> | Platform, arch, hostname, uptime, CPU count | | getMemory() | Promise<MemoryInfo> | Total, used, free memory with percentages | | getCpu() | Promise<CpuInfo> | CPU model, cores, speed, usage, load avg | | getLatency(host?) | Promise<LatencyInfo> | Network latency to specified host | | getDisk() | Promise<DiskInfo> | Disk usage information | | getBattery() | Promise<BatteryInfo> | Battery level and charging status | | getNetwork() | Promise<NetworkInfo> | Network interfaces and addresses | | getUser() | Promise<UserInfo> | Current user information | | getAll(options?) | Promise<AllInfo> | All system info in one call | | getAllCached(options?) | Promise<AllInfo> | Cached version for performance |

Utility Methods

| Method | Description | |--------|-------------| | monitor(callback, interval?) | Monitor system changes in real-time | | getHealthSummary() | Get health status with warnings | | use(pluginFn) | Add custom plugin |

Legacy Logging Methods

For backward compatibility, logging methods are still available:

await systemInfo.logBasic();
await systemInfo.logMemory();
await systemInfo.logCpu();
await systemInfo.logAll();

📊 Data Structures

MemoryInfo

{
  total: { value: 16, unit: 'GB', formatted: '16.00 GB' },
  used: { value: 8.5, unit: 'GB', formatted: '8.50 GB' },
  free: { value: 7.5, unit: 'GB', formatted: '7.50 GB' },
  usedPercent: 53.12,
  freePercent: 46.88,
  totalBytes: 17179869184,
  usedBytes: 9126805504,
  freeBytes: 8053063680
}

CpuInfo

{
  model: 'Intel(R) Core(TM) i7-9750H CPU @ 2.60GHz',
  speed: 2600,
  cores: 12,
  usage: 23.5,
  loadAvg: { '1min': 1.2, '5min': 1.5, '15min': 1.8 },
  details: [/* per-core info */]
}

BasicInfo

{
  platform: 'linux',
  architecture: 'x64',
  hostname: 'server-01',
  uptime: { days: 5, hours: 12, minutes: 30, seconds: 45, formatted: '5d 12h 30m 45s' },
  uptimeSeconds: 476445,
  cpuCount: 12,
  nodeVersion: 'v18.17.0',
  processUptime: { /* same format as uptime */ },
  timestamp: 1699200000000
}

🔌 Plugin System

Extend functionality with custom plugins:

systemInfo.use(async function customMetrics() {
  return {
    appVersion: require('./package.json').version,
    environment: process.env.NODE_ENV,
    activeConnections: await getActiveConnections()
  };
});

const data = await systemInfo.getAll();
console.log(data.plugins.customMetrics);

⚡ Performance & Caching

Use getAllCached() for better performance:

// First call: fetches fresh data (~50ms)
const data1 = await systemInfo.getAllCached();

// Second call: returns cached data (~1ms)
const data2 = await systemInfo.getAllCached();

// Cache expires after 5 seconds

🏥 Health Monitoring

const health = await systemInfo.getHealthSummary();

// Returns:
{
  status: 'healthy' | 'warning' | 'critical',
  issues: ['Memory usage critical: 95%'],
  warnings: ['CPU usage high: 78%'],
  memory: { /* MemoryInfo */ },
  cpu: { /* CpuInfo */ }
}

🔄 Real-Time Monitoring

const stopMonitoring = await systemInfo.monitor((err, data) => {
  if (err) {
    console.error('Monitor error:', err);
    return;
  }
  
  console.log(`CPU: ${data.cpu.usage}%`);
  console.log(`Memory: ${data.memory.usedPercent}%`);
}, 1000); // Update every second

// Stop monitoring when done
stopMonitoring();

🎨 TypeScript Support

Full TypeScript definitions included:

import systemInfo, { MemoryInfo, CpuInfo, AllInfo } from '@peaseernest/system-info';

const memory: MemoryInfo = await systemInfo.getMemory();
const cpu: CpuInfo = await systemInfo.getCpu();

🆚 Comparison with Original

| Feature | Original | Revamped | |---------|----------|----------| | Returns usable data | ❌ No | ✅ Yes | | TypeScript types | ⚠️ Basic | ✅ Complete | | Real-time monitoring | ❌ No | ✅ Yes | | Health checks | ❌ No | ✅ Yes | | Caching | ❌ No | ✅ Yes | | Plugin system | ⚠️ Basic | ✅ Enhanced | | Data structures | ⚠️ Strings only | ✅ Rich objects | | Async/await | ⚠️ Inconsistent | ✅ All async |

📝 Migration Guide

Old Way (v1.0)

// Could only log, no data access
systemInfo.logMemoryInfo();
// No way to get the actual values!

New Way (v2.0)

// Get actual data
const memory = await systemInfo.getMemory();
console.log(memory.usedPercent); // 53.12

// Still supports logging if you want it
await systemInfo.logMemory();

🛠️ Advanced Usage

Custom Formatting

const memory = await systemInfo.getMemory();
const formatted = `${memory.used.value.toFixed(1)}${memory.used.unit} / ${memory.total.formatted}`;
// "8.5GB / 16.00 GB"

Conditional Logic

const data = await systemInfo.getAll();

if (data.memory.usedPercent > 90) {
  await scaleUpServers();
} else if (data.memory.usedPercent < 30) {
  await scaleDownServers();
}

Integration with Express

const express = require('express');
const systemInfo = require('@peaseernest/system-info');

const app = express();

app.get('/api/system', async (req, res) => {
  const data = await systemInfo.getAllCached();
  res.json(data);
});

app.get('/api/health', async (req, res) => {
  const health = await systemInfo.getHealthSummary();
  res.status(health.status === 'healthy' ? 200 : 503).json(health);
});

🤝 Contributing

Contributions welcome! Please open an issue before submitting PRs for new features.

Bug Fixes

Always welcome via PR.

New Features

Please open an issue first to discuss the feature.

📄 License

MIT © Ernest Tech House

🙏 Acknowledgments

Built with:

  • Node.js core modules (os, child_process)
  • systeminformation - Enhanced system info
  • ping - Network latency
  • ernest-logger - Styled logging

Made with ❤️ by Pease Ernest