1. Why Bother with Monitoring?
If a server is like a 24/7 coffee shop, then monitoring is the barista who keeps checking the water temperature, bean stock, and who’s been sitting too long without ordering. Without the barista, the shop could burn down or quietly go bankrupt.
In FreeBSD, the best "baristas" come pre-installed: top, ps, and systat. These three tools are free, fast, lightweight, and perfect if you don’t want to install heavy monitoring packages.
2. top — Watching the System's "Heartbeat"
To run it, simply type:
top
top -S
top -o cpu
top gives you a real-time overview of processes. The header shows system load, memory usage, swap, and more. Press P to sort by CPU, or M to sort by memory.
Log Output for Analysis:
top -b -n 20 > log.txt
You can run this in a cron job for periodic snapshots:
*/5 * * * * /usr/bin/top -b -n 1 >> /var/log/top.snap
3. ps — Static Snapshot of Processes
While top is like watching a live video, ps is like taking a picture. It’s ideal for scripting and quick process checks:
ps aux
ps aux | grep nginx
Example: Show top memory hogs
ps axo pid,comm,rss | sort -k3 -n | tail
This command lists processes with the highest RAM usage, useful when diagnosing slowdowns.
4. systat — All-in-One Terminal Dashboard
systat offers various monitoring modes:
systat -vmstat 1
systat -ifstat 1
systat -iostat 1
systat -pf -tcp 1
These modes display live info about memory, CPU, disk I/O, and network stats. Use Ctrl+C to exit, Ctrl+L to refresh.
Reading -vmstat
- us, sy, id: user, system, and idle CPU percentage
- pi/po: page in/out — watch these to monitor memory pressure
- faults: track I/O and system faults
5. Daily Monitoring Workflow
- Start with
topto check for anomalies. - Use
psto investigate suspicious PIDs. - Check
systatfor disk or network impact.
6. Logging for Later Analysis
To collect logs even when you’re asleep:
* * * * * root /usr/bin/top -b -n 1 >> /var/log/top/minutely.log
*/5 * * * * root /usr/bin/systat -vmstat 1 5 >> /var/log/systat/vmstat.log
7. Handy Tips & Tricks
top -U www→ filter by userps axww→ show full command line- Press
Wintop→ save display configuration - Use
top -s 1→ refresh every 1 second - Use
top -bin scripts or cron jobs
8. Want a GUI?
Prefer visuals? Try:
- htop — colorful, interactive, needs to be installed
- gkrellm — system monitor widget
- netdata — modern web-based dashboard
Monitoring is a form of preventive care. With top, ps, and systat, you have powerful tools to track down performance issues and keep your FreeBSD server healthy.
Get into the habit of checking these tools daily. When your server is happy, you’ll be happy too. Happy monitoring!

0 Comments:
Posting Komentar