Server Monitor
Server Monitor is a lightweight VS Code status bar extension for Linux servers. It is designed for remote development sessions where you want a quick read on CPU, memory, swap, disk usage, load, and uptime without opening a terminal.
Each metric is rendered as its own status bar item, so every section has its own hover tooltip.
Features
- CPU usage from
/proc/stat
- Memory usage from
/proc/meminfo
- Swap usage from
/proc/meminfo
- Active swap files from
/proc/swaps
- Load average from
/proc/loadavg
- Uptime from
/proc/uptime
- Mounted-volume discovery from
/proc/self/mountinfo
- Disk usage using Node's
fs.statfs()
- One status item per distinct filesystem volume
- One hover tooltip per metric
- Configurable refresh interval and displayed metrics
- No privileged commands
- No recursive disk scans in the live polling loop
Default Status Items
The default status bar shows:
CPU Memory Swap one item per mounted volume Load
The default configuration is:
{
"serverMonitor.intervalMs": 2000,
"serverMonitor.items": [
"cpu",
"mem",
"swap",
"disk",
"load"
],
"serverMonitor.tooltipDiskPaths": []
}
Settings
serverMonitor.intervalMs
Refresh interval in milliseconds.
Default:
2000
Minimum:
1000
serverMonitor.items
Status bar items to show.
Supported values:
cpu
mem
swap
load
uptime
disk (automatically discovers mounted volumes)
disk:/path
Example:
[
"cpu",
"mem",
"swap",
"disk",
"uptime"
]
Optional preferred disk paths. If a preferred path belongs to a discovered volume,
it is used as that volume's label. Volumes are still deduplicated by device.
Example:
[
"/mnt/data"
]
Commands
Server Monitor: Refresh
Refreshes the metrics immediately.
Install From VSIX
Build the package:
npm install
npm run compile
npm run package
Install it into the current VS Code server:
code --install-extension server-monitor-<version>.vsix --force
After installing, reload the VS Code window.
Development
Install dependencies:
npm install
Compile once:
npm run compile
Watch TypeScript:
npm run watch
Package a VSIX:
npm run package
Project Structure
server-monitor/
package.json
tsconfig.json
src/
config.ts
extension.ts
format.ts
linux.ts
monitor.ts
types.ts
extension.ts
VS Code entrypoint.
- Creates one status bar item per configured metric.
- Starts and restarts the polling timer.
- Watches configuration changes.
- Registers
Server Monitor: Refresh.
monitor.ts
Coordinates metric collection.
- Caches the previous CPU sample.
- Collects Linux metrics in parallel where practical.
- Produces one normalized metric snapshot.
linux.ts
Linux metric readers.
Sources:
/proc/stat
/proc/meminfo
/proc/swaps
/proc/loadavg
/proc/uptime
/proc/self/mountinfo
fs.statfs(path)
Formats status bar text and per-item tooltip text.
Uses VS Code Codicons such as:
$(chip)
$(server)
$(archive)
$(database)
$(pulse)
$(watch)
Codicon browser:
https://microsoft.github.io/vscode-codicons/dist/codicon.html
Disk Usage Notes
Server Monitor discovers mounts from /proc/self/mountinfo, ignores virtual filesystems
such as proc, sysfs, and tmpfs, and deduplicates mount paths that point to the
same underlying device. It then uses fs.statfs() for disk usage. This is equivalent
to asking the filesystem for already-maintained block counts, like df.
This is cheap:
df -h /
df -h /home/django
This is intentionally not used in the live loop:
du -sh /home
du recursively walks files and directories. It can be expensive on large repositories, node_modules, build caches, .git directories, and mounted volumes.
CPU Calculation
CPU usage is calculated from two /proc/stat samples.
For each sample:
idle = idle + iowait
total = sum(all cpu columns)
Between samples:
cpuPercent = 100 * (1 - idleDelta / totalDelta)
The first sample shows a warming-up state because there is no previous sample yet.
Future Ideas
- Configurable icons
- Configurable alignment and priority
- Warning colors for high memory/swap/disk usage
- Optional process list command
- Optional manual folder-size command using
du
- Detail webview with short history charts
- Port/service status checks