System Monitoring Tools for Ubuntu Minimal
Ubuntu Minimal systems require lightweight, efficient monitoring tools that minimize resource usage while providing critical insights. Below are top choices categorized by type:
htop (install via sudo apt install htop) offers a more intuitive interface with color-coded metrics and mouse support, while top is pre-installed and suitable for quick checks.vmstat (reports virtual memory, CPU, disk I/O) and iostat (focuses on disk I/O) are part of the sysstat package (install via sudo apt install sysstat). Use vmstat 1 for 1-second interval updates or iostat -x 1 for detailed disk metrics.sudo apt install lm-sensors, then run sensors-detect to configure sensors. Use sensors to view real-time readings (e.g., CPU temperature).bash <(curl -Ss https://my-netdata.io/kickstart.sh), then access http://localhost:19999 in a browser. Provides dashboards for CPU, memory, disk, network, and processes.sudo apt install conky, then configure ~/.conkyrc to display metrics in the desktop corner. Lightweight and supports themes.sudo add-apt-repository ppa:fossfreedom/indicator-sysmonitor, install with sudo apt install indicator-sysmonitor, and run from the application menu.For minimal systems, bash scripts with cron are ideal for scheduled checks. Below is a sample script to monitor CPU, memory, and disk usage, with alerts sent via email when thresholds are exceeded:
#!/bin/bash
# System Monitoring Script with Alert
CPU_THRESHOLD=80
MEMORY_THRESHOLD=85
DISK_THRESHOLD=90
EMAIL="your_email@example.com"
# Get current usage
CPU_USAGE=$(top -bn1 | grep "Cpu(s)" | awk '{print $2 + $4}')
MEMORY_USAGE=$(free | awk '/Mem/ {printf("%.1f", ($3/$2) * 100)}')
DISK_USAGE=$(df -h / | awk '/\// {print $(NF-1)}')
DISK_USAGE=${DISK_USAGE%\%} # Remove % sign
# Alert function
send_alert() {
SUBJECT="System Alert: $1 Usage Exceeded Threshold"
BODY="Current $1 usage: ${2}% (Threshold: ${3}%)\n\n$(date)"
echo -e "$BODY" | mail -s "$SUBJECT" "$EMAIL"
}
# Check thresholds
if (( $(echo "$CPU_USAGE > $CPU_THRESHOLD" | bc -l) )); then
send_alert "CPU" "$CPU_USAGE" "$CPU_THRESHOLD"
fi
if (( $(echo "$MEMORY_USAGE > $MEMORY_THRESHOLD" | bc -l) )); then
send_alert "Memory" "$MEMORY_USAGE" "$MEMORY_THRESHOLD"
fi
if (( $DISK_USAGE > $DISK_THRESHOLD )); then
send_alert "Disk" "$DISK_USAGE" "$DISK_THRESHOLD"
fi
Setup Instructions:
~/monitor_system.sh.chmod +x ~/monitor_system.sh.mailutils for email alerts: sudo apt install mailutils.cron for hourly checks: crontab -e and append 0 * * * * ~/monitor_system.sh.This script checks CPU (threshold: 80%), memory (85%), and disk (90%) usage every hour. If any metric exceeds the threshold, it sends an email alert with the current usage and timestamp.
For larger setups or advanced needs, consider these tools (may require more resources but offer comprehensive features):
wget https://github.com/prometheus/prometheus/releases/download/v2.30.3/prometheus-2.30.3.linux-amd64.tar.gz, extract, and configure prometheus.yml to scrape system metrics. Grafana (install via sudo apt install grafana) connects to Prometheus for real-time dashboards.sudo apt install monit, configure rules in /etc/monit/conf.d/ (e.g., check process nginx with pidfile /var/run/nginx.pid), and start with sudo systemctl start monit.Each tool caters to different needs—choose based on your system’s complexity and monitoring goals. For minimal systems, command-line tools and scripts are recommended to avoid unnecessary overhead.