sys-premium
v2.0.3
Published
Security-first, modular Node.js system information library. Zero CVEs. Fast Windows support. No build step.
Downloads
555
Maintainers
Readme
sys-premium
Security-first, modular system information library for Node.js. Zero CVEs. No build step. Works out of the box.
💼 Open to Work
The author is available for freelance & full-time work. 📧 [email protected] — reach out anytime!
Why sys-premium?
| | systeminformation | sys-premium |
|---|---|---|
| Security CVEs | 10+ command injection | 0 targeted |
| Windows speed | Spawns PowerShell per call (~800ms) | Single batched call (~100ms) |
| Architecture | Monolithic 20,000+ lines | Modular — require only what you need |
| Build step | No | No |
| Runtime dependencies | 0 | 0 |
| Drop-in migration | — | Adapter layer included |
Installation
npm install sys-premiumNo build step. No compiler. Just install and use.
Quick Start
const sp = require('sys-premium');
// CPU info
const cpu = await sp.getCpu();
const flags = await sp.getCpuFlags(); // "sse4_2 avx avx2 vmx ..."
console.log(cpu.brand, cpu.cores, 'cores @', cpu.speed, 'GHz');
// Memory
const mem = await sp.getMemory();
console.log('RAM:', Math.round(mem.total / 1e9), 'GB,', Math.round(mem.available / 1e9), 'GB free');
// Network interfaces
const ifaces = await sp.getNetworkInterfaces();
ifaces.filter(i => !i.internal).forEach(i => console.log(i.iface, i.ip4));
// Running processes
const procs = await sp.getProcesses();
console.log('Running processes:', procs.all);When you first require('sys-premium') you'll see:
╔══════════════════════════════════════════════════════╗
║ sys-premium v1.0.0 ║
║ Security-first system information for Node.js ║
╠══════════════════════════════════════════════════════╣
║ 💼 Author is open for freelance & full-time work ║
║ 📧 [email protected] — reach out anytime! ║
╚══════════════════════════════════════════════════════╝Modular Imports
Only require the modules you need — keeps your project lean:
const { getCpu, getCurrentLoad } = require('sys-premium/cpu');
const { getMemory, getMemoryLayout } = require('sys-premium/memory');
const { getDiskLayout, getFsSize } = require('sys-premium/disk');
const { getNetworkInterfaces } = require('sys-premium/network');
const { getProcesses, getServices } = require('sys-premium/processes');
const { getBattery } = require('sys-premium/battery');
const { getGraphics } = require('sys-premium/gpu');
const { getDockerContainers } = require('sys-premium/docker');
const { getWifiNetworks } = require('sys-premium/wifi');
const { getPrinters } = require('sys-premium/printer');
const { getAudioDevices } = require('sys-premium/audio');Full API Reference
🖥️ CPU
const sp = require('sys-premium');
const cpu = await sp.getCpu(); // brand, cores, speed, cache, flags, virtualization
const speed = await sp.getCpuCurrentSpeed(); // { min, max, avg, cores[] }
const temp = await sp.getCpuTemperature(); // { main, cores[], max, socket[] }
const load = await sp.getCurrentLoad(); // { currentLoad, cpus[], avgLoad }
const flags = await sp.getCpuFlags(); // "sse4_2 avx avx2 vmx ..."
const cache = await sp.getCpuCache(); // { l1d, l1i, l2, l3 } in bytesExample output — getCpu():
{
"brand": "Intel(R) Core(TM) i7-10750H CPU @ 2.60GHz",
"manufacturer": "Intel",
"cores": 12,
"physicalCores": 6,
"speed": 2.6,
"speedMax": 5.0,
"virtualization": true,
"cache": { "l1d": 196608, "l1i": 196608, "l2": 1572864, "l3": 12582912 }
}💾 Memory
const mem = await sp.getMemory(); // total, free, used, available, swap...
const layout = await sp.getMemoryLayout(); // per-DIMM slot detailsExample output — getMemory():
{
"total": 17179869184,
"free": 4294967296,
"used": 10737418240,
"available": 6442450944,
"swaptotal": 2147483648,
"swapused": 536870912
}🖥️ Operating System
const info = await sp.getOsInfo(); // platform, distro, kernel, hostname, arch
const users = await sp.getUsers(); // currently logged-in users
const time = sp.getTime(); // { current, uptime, timezone, timezoneName }
const uptime = sp.getUptime(); // seconds since boot
const versions = await sp.getVersions(); // node, npm, git, docker, python, go, rust...Example output — getTime():
const time = sp.getTime();
// {
// current: 1748765432000, // Unix timestamp ms
// uptime: 86400, // seconds since boot
// timezone: '+0530', // UTC offset
// timezoneName: 'Asia/Kolkata' // IANA timezone name
// }Fix 3 — getVersions() returns empty string for tools not installed:
const versions = await sp.getVersions();
// { node: '22.0.0', npm: '10.9.7', git: '2.40.1', docker: '', rust: '' }
// ^^^^^^^^^^^^^^^^^^^
// empty string if tool not found on PATHExample output — getOsInfo():
{
"platform": "linux",
"distro": "Ubuntu 22.04.3 LTS",
"kernel": "5.15.0-91-generic",
"arch": "x64",
"hostname": "my-server",
"uefi": true
}💿 Disk & Storage
const disks = await sp.getDiskLayout(); // HDD/SSD/NVMe: name, size, serial, type
const blocks = await sp.getBlockDevices(); // all block devices with mount points
const fs = await sp.getFsSize(); // filesystems: size, used, available, %
const stats = await sp.getFsStats(); // bytes read/written, rates
const io = await sp.getDisksIo(); // I/O ops, wait times, per-second rates
const smart = await sp.getSmartData('/dev/sda'); // full S.M.A.R.T. dataExample output — getFsSize():
[
{ "fs": "/dev/sda1", "type": "ext4", "size": 500107862016, "used": 120259084288, "available": 354437619712, "use": 25.3, "mount": "/" }
]🌐 Network
const ifaces = await sp.getNetworkInterfaces(); // IP4/6, MAC, speed, type, DHCP
const stats = await sp.getNetworkStats(); // RX/TX bytes, rates, errors
const conns = await sp.getNetworkConnections(); // TCP/UDP connections with PIDs
const latency = await sp.getLatency('8.8.8.8'); // ping in ms
const site = await sp.checkSite('https://example.com'); // { statusCode, ok, ms }
const defIf = await sp.getDefaultNetworkInterface(); // "eth0"
const gateway = await sp.getDefaultGateway(); // "192.168.1.1"Example output — getNetworkInterfaces():
[
{ "iface": "eth0", "ip4": "192.168.1.100", "mac": "aa:bb:cc:dd:ee:ff", "speed": 1000, "type": "wired", "default": true }
]⚙️ Processes & Services
const procs = await sp.getProcesses(); // all processes: PID, CPU%, mem%
const svcs = await sp.getServices(['nginx', 'sshd']); // service status, PID, enabled
const load = await sp.getProcessLoad('node'); // aggregated CPU/mem for a processExample output — getProcesses():
{
"all": 312, "running": 4, "sleeping": 305, "blocked": 3,
"list": [
{ "pid": 1234, "name": "node", "cpu": 2.4, "mem": 1.1, "state": "running", "user": "ubuntu" }
]
}🔋 Battery
const bat = await sp.getBattery();
// { hasBattery, percent, isCharging, timeRemaining, cycleCount, maxCapacity, manufacturer }Example output:
{
"hasBattery": true,
"percent": 87,
"isCharging": false,
"timeRemaining": 142,
"cycleCount": 214,
"manufacturer": "SMP"
}🎮 Graphics / GPU
const g = await sp.getGraphics();
// { controllers: [{ vendor, model, vram, driverVersion }], displays: [...] }🖨️ Printers
const printers = await sp.getPrinters();
// [{ name, model, uri, status, default, shared, local }]🔊 Audio Devices
const audio = await sp.getAudioDevices();
// [{ name, manufacturer, type, in, out, interfaceType, status }]🔌 USB & Bluetooth
const usb = await sp.getUsbDevices();
// [{ id, name, vendor, manufacturer, type, removable }]
const bt = await sp.getBluetoothDevices();
// [{ name, macDevice, connected, batteryPercent, type }]📶 WiFi
const networks = await sp.getWifiNetworks();
// [{ ssid, bssid, channel, frequency, signalLevel, quality, security }]
const connections = await sp.getWifiConnections();
const interfaces = await sp.getWifiInterfaces();🐳 Docker
const info = await sp.getDockerInfo();
const containers = await sp.getDockerContainers(true); // true = include stopped
const images = await sp.getDockerImages();
const stats = await sp.getDockerContainerStats(['abc123']);
// stats: { cpuPercent, memUsage, memLimit, memPercent, netIO, blockIO }⏱️ Real-time Observer
Poll values and get notified only when something changes:
const { observe, waitFor } = require('sys-premium');
const handle = observe(
{
load: () => sp.getCurrentLoad(),
mem: () => sp.getMemory(),
},
2000, // poll every 2 seconds
(changed, key) => {
console.log(`${key} changed:`, changed);
}
);
// Stop at any time
handle.stop();
// Or wait for a condition
const bat = await waitFor(
() => sp.getBattery(),
b => b.percent > 80,
{ timeout: 60000 }
);🔄 Drop-in Adapter (migrate from systeminformation)
// Before (systeminformation):
const si = require('systeminformation');
const cpu = await si.cpu();
// After (sys-premium — zero other changes needed):
const { createAdapter } = require('sys-premium/adapter');
const si = createAdapter();
const cpu = await si.cpu(); // identical return shape
const mem = await si.mem(); // identical return shapeCallback style also supported:
si.cpu(data => console.log(data.brand));
si.mem(data => console.log(data.total));Bulk APIs — get everything in one call:
// All static hardware data — one batched call (CPU, OS, GPU, network, memory slots, disks)
const staticData = await si.getStaticData();
// { cpu, os, graphics, net, memLayout, diskLayout }
// All live runtime data — processes, load, network stats, battery, services
const dynamicData = await si.getDynamicData(['nginx', 'sshd'], ['eth0']);
// { mem, currentLoad, cpuTemperature, processes, battery, services, networkStats, ... }
// Everything combined
const allData = await si.getAllData();Windows Performance: Batch API
systeminformation spawns a separate PowerShell process per call — on Windows each spawn costs ~150–200ms.
sys-premium batches all static hardware queries into one single PowerShell call, shared between getCpu(), getOsInfo(), and BIOS/baseboard/system info — then caches the result for 30 seconds.
systeminformation: getCpu() ~180ms + getOsInfo() ~150ms + ... = ~800ms total
sys-premium: all of the above = ~100ms total, then ~0ms from cacheSecurity
✅ execFile() only — arguments are arrays, never shell strings
✅ Input validation on all user-provided values (device, host, name, id)
✅ PowerShell scripts are hardcoded constants — user data never interpolated
✅ Zero runtime dependencies — no supply chain risk
✅ 0 reported CVEs
✅ Passes npm audit --audit-level=moderateEvery function that takes user input validates it against a strict allowlist before touching any subprocess:
| Function | Input validated |
|---|---|
| getSmartData(device) | Linux/macOS: /dev/[a-zA-Z0-9]+ only · Windows: \\.\PHYSICALDRIVE[0-9]+ only (digits, no wildcards) |
| getServices(names) | [a-zA-Z0-9._-], max 64 chars, no .. or path separators |
| getProcessLoad(name) | [a-zA-Z0-9._-] only |
| getLatency(host) | [a-zA-Z0-9.-] only |
| getDockerContainerStats(ids) | [a-zA-Z0-9_-] only, validated before any docker check |
Platform Support
| Feature | Linux | macOS | Windows | FreeBSD | |---|---|---|---|---| | CPU info & load | ✅ | ✅ | ✅ | ✅ | | CPU temperature | ✅ | ✅* | ✅ | ~ | | Memory info | ✅ | ✅ | ✅ | ✅ | | Memory layout | ✅ | ✅ | ✅ | ~ | | Disk layout | ✅ | ✅ | ✅ | ~ | | Block devices | ✅ | ✅ | ✅ | ~ | | SMART data | ✅ | ~ | ✅ | ✗ | | Network interfaces | ✅ | ✅ | ✅ | ✅ | | Network stats | ✅ | ✅ | ✅ | ~ | | Processes | ✅ | ✅ | ✅ | ✅ | | GPU / graphics | ✅ | ✅ | ✅ | ~ | | Battery | ✅ | ✅ | ✅ | ✗ | | Docker | ✅ | ✅ | ✅ | ✗ | | WiFi | ✅ | ✅ | ~ | ✗ | | Bluetooth | ✅ | ✅ | ~ | ✗ | | Printers | ✅ | ✅ | ✅ | ✗ | | Audio devices | ✅ | ✅ | ✅ | ✗ |
*macOS CPU temperature: tries osx-temperature-sensor first (optional peer dep, works on Intel Macs). If not installed or returns no data, automatically falls back to powermetrics via passwordless sudo. If neither is available, returns -1 — never throws.
Benchmark
Run the included benchmark to measure speed on your machine:
node benchmark/compare.jsSample results (Linux, Node 22):
| Function | Time | |---|---| | getCpu() | ~8ms (30s cache after first call) | | getMemory() | ~3ms | | getNetworkInterfaces() | ~12ms | | getProcesses() | ~28ms | | getDiskLayout() | ~15ms | | getVersions() | ~120ms |
License
MIT — free to use in personal and commercial projects.
💼 Open to Work
The author is available for freelance & full-time work. 📧 [email protected] — reach out anytime!
