温馨提示×

Debian Swapper监控工具推荐

小樊
39
2025-11-02 14:01:44
栏目: 智能运维

Command-Line Tools for Monitoring Swap in Debian

  • free: The most basic tool to view memory and swap usage. Use free -h to display totals in a human-readable format (e.g., GB/MB). It shows swap capacity, used space, and free space alongside memory stats.
  • top/htop: top is a real-time system monitor that includes a “Swap” line with total, used, and free swap values. htop (install via sudo apt install htop) offers a more intuitive interface with color-coded metrics and keyboard navigation for detailed swap insights.
  • vmstat: Generates virtual memory statistics, including swap activity. Use vmstat -s | grep swap to extract swap-specific data (total, used, free) or vmstat 1 to refresh stats every second for live monitoring.
  • swapon --show: Lists all enabled swap partitions/files with details (name, type, size, used space, priority). Run as sudo swapon --show for accurate, up-to-date information.
  • sar: Part of the sysstat package (install via sudo apt install sysstat), it collects historical and real-time system activity data. Use sar -r 1 to view swap usage every second (replace 1 with your desired interval).

Graphical Tools for Swap Monitoring in Debian

  • gnome-system-monitor/kde-system-monitor: Built-in GUI tools for monitoring system resources. They provide a visual representation of swap usage (similar to top) and are suitable for users preferring a graphical interface. Install via sudo apt install gnome-system-monitor (Debian default) or sudo apt install kde-system-monitor (KDE users).
  • conky: A lightweight, customizable desktop widget that displays system stats (including swap) on the desktop. Configure it by editing the ~/.conkyrc file to show swap usage (e.g., ${swap}M for used swap in MB). Install via sudo apt install conky.
  • Grafana + Sampler: For advanced, visual monitoring, use Sampler (a Docker-based collector) to gather swap metrics and Grafana (a visualization platform) to create dashboards. Install Sampler with docker pull sqshq/sampler, configure it to query swap data (via free -m), and set up Grafana to visualize trends over time.
  • netdata: An open-source, real-time monitoring tool with a web interface. Install via sudo apt install netdata and access it at http://your-server-ip:19999. It provides live swap usage charts and alerts for abnormal activity.

0