multi-aspect system monitoring

 My own script:

#!/bin/bash


echo "Resource Usage Report"

echo "====================="


# Top 3 CPU consumers

echo "CPU:"

ps -eo pid,comm,%cpu --sort=-%cpu | head -n 4 | awk 'NR>1 {printf "- %s: %s%%\n", $2, $3}'


# Top 3 Memory consumers

echo "RAM:"

ps -eo pid,comm,%mem --sort=-%mem | head -n 4 | awk 'NR>1 {printf "- %s: %s%%\n", $2, $3}'


# Top 3 Disk IO consumers

echo "Disk:"

iotop -b -n 1 | head -n 12 | grep -E '^ *[0-9]' | awk '{printf "- %s: %s%%\n", $12, $10}' | head -n 3


1. iostat (from the sysstat package)

  • Use: Provides detailed statistics about CPU utilisation and I/O performance for devices and partitions.
  • Why Use It:
    • Focused on I/O bottlenecks.
    • Breaks down performance metrics by individual devices (e.g., disks).
    • Includes metrics like device utilisation, read/write speeds, and queue lengths.

2. iotop

  • Use: Displays real-time I/O usage by processes.
  • Why Use It:
    • Identifies processes responsible for high disk I/O.
    • Useful for pinpointing resource-heavy applications impacting storage performance.

3. dstat

  • Use: A versatile tool that combines features of iostat, vmstat, and ifstat with additional statistics.
  • Why Use It:
    • Provides a single comprehensive view of system performance metrics.
    • Customisable and can show CPU, memory, disk, network, and more in real-time.
    • Easier to read and interpret compared to individual tools.

4. sar (from the sysstat package)

  • Use: Collects, reports, and saves system activity data over time.
  • Why Use It:
    • Tracks historical performance data for CPU, memory, and I/O usage.
    • Useful for identifying trends and diagnosing intermittent issues.
    • Allows performance monitoring over longer durations.

5. smartctl (from the smartmontools package)

  • Use: Monitors the health of storage devices using S.M.A.R.T. data.
  • Why Use It:
    • Essential for assessing hardware reliability.
    • Detects impending disk failures through metrics like reallocated sectors or I/O error rates.
    • Complements resource monitoring by ensuring hardware health.

Popular posts from this blog

Automatically Fix Song Metadata and Filenames on Linux with Beets

throttle traffic on apache

script to show all files with disk usage sizes