resource-monitor
Comprehensive development toolkit: 52 professional skills for Claude Code across development, code quality, API, database, security, DevOps, data analytics, and collaboration
19 stars4 forksUpdated Oct 20, 2025
npx skills add https://github.com/curiouslearner/devkit --skill resource-monitorSKILL.md
Resource Monitor Skill
Monitor system resources (CPU, memory, disk, network) during development and production.
Instructions
You are a system resource monitoring expert. When invoked:
-
Monitor Resources:
- CPU usage and load average
- Memory usage (RAM and swap)
- Disk usage and I/O
- Network traffic and connections
- Process-level metrics
-
Analyze Patterns:
- Identify resource-intensive processes
- Detect memory leaks
- Find CPU bottlenecks
- Monitor disk space trends
- Track network bandwidth usage
-
Set Alerts:
- CPU usage thresholds
- Memory limits
- Disk space warnings
- Unusual network activity
-
Provide Recommendations:
- Resource optimization strategies
- Scaling recommendations
- Configuration improvements
- Performance tuning
Resource Metrics
CPU Monitoring
# Current CPU usage
top -bn1 | grep "Cpu(s)"
# Per-core usage
mpstat -P ALL 1
# Process CPU usage
ps aux --sort=-%cpu | head -10
# Load average
uptime
# Node.js CPU profiling
node --prof app.js
node --prof-process isolate-*.log
Memory Monitoring
# Memory usage
free -h
# Detailed memory info
cat /proc/meminfo
# Process memory usage
ps aux --sort=-%mem | head -10
# Memory map for specific process
pmap -x <PID>
# Node.js memory usage
node --inspect app.js
# Chrome DevTools -> Memory
Disk Monitoring
# Disk space
df -h
# Disk I/O
iostat -x 1
# Large files/directories
du -h --max-depth=1 / | sort -hr | head -20
# Disk usage by directory
ncdu /
# Monitor disk writes
iotop
Network Monitoring
# Network connections
netstat -tunapl
# Active connections
ss -s
# Bandwidth usage
iftop
# Network traffic
nload
# Connection states
netstat -ant | awk '{print $6}' | sort | uniq -c | sort -n
Monitoring Scripts
Node.js Resource Monitor
// resource-monitor.js
const os = require('os');
class ResourceMonitor {
constructor(interval = 5000) {
this.interval = interval;
this.startTime = Date.now();
}
start() {
console.log('🔍 Resource Monitor Started\n');
this.logResources();
setInterval(() => this.logResources(), this.interval);
}
logResources() {
const uptime = Math.floor((Date.now() - this.startTime) / 1000);
const cpu = this.getCPUUsage();
const memory = this.getMemoryUsage();
const load = os.loadavg();
console.clear();
console.log('📊 System Resources');
console.log('='.repeat(50));
console.log(`Uptime: ${this.formatUptime(uptime)}`);
console.log('');
console.log('CPU:');
console.log(` Usage: ${cpu.toFixed(2)}%`);
console.log(` Load Average: ${load[0].toFixed(2)}, ${load[1].toFixed(2)}, ${load[2].toFixed(2)}`);
console.log(` Cores: ${os.cpus().length}`);
console.log('');
console.log('Memory:');
console.log(` Total: ${this.formatBytes(memory.total)}`);
console.log(` Used: ${this.formatBytes(memory.used)} (${memory.percentage.toFixed(2)}%)`);
console.log(` Free: ${this.formatBytes(memory.free)}`);
this.printProgressBar('Memory', memory.percentage);
console.log('');
const processMemory = process.memoryUsage();
console.log('Process Memory:');
console.log(` RSS: ${this.formatBytes(processMemory.rss)}`);
console.log(` Heap Total: ${this.formatBytes(processMemory.heapTotal)}`);
console.log(` Heap Used: ${this.formatBytes(processMemory.heapUsed)}`);
console.log(` External: ${this.formatBytes(processMemory.external)}`);
console.log('');
this.checkThresholds(cpu, memory);
}
getCPUUsage() {
const cpus = os.cpus();
let totalIdle = 0;
let totalTick = 0;
cpus.forEach(cpu => {
for (const type in cpu.times) {
totalTick += cpu.times[type];
}
totalIdle += cpu.times.idle;
});
const idle = totalIdle / cpus.length;
const total = totalTick / cpus.length;
const usage = 100 - ~~(100 * idle / total);
return usage;
}
getMemoryUsage() {
const total = os.totalmem();
const free = os.freemem();
const used = total - free;
const percentage = (used / total) * 100;
return { total, free, used, percentage };
}
formatBytes(bytes) {
const units = ['B', 'KB', 'MB', 'GB', 'TB'];
let size = bytes;
let unitIndex = 0;
while (size >= 1024 && unitIndex < units.length - 1) {
size /= 1024;
unitIndex++;
}
return `${size.toFixed(2)} ${units[unitIndex]}`;
}
formatUptime(seconds) {
const hours = Math.floor(seconds / 3600);
const minutes = Math.floor((seconds % 3600) / 60);
const secs = seconds % 60;
return `${hours}h ${minutes}m ${secs}s`;
}
printProgressBar(label, percentage) {
const width = 40;
const filled = Math.floor(width * percentage / 100);
const empty = width - filled;
const bar = '█'.repeat(filled) + '░'.repeat(empty);
let color = '\x1b[32m'; // Green
if (percentage >
...
Repository
curiouslearner/devkitParent repository
Repository Stats
Stars19
Forks4
LicenseMIT License