ctstat - Linux


Overview

ctstat is a powerful tool for live monitoring and managing Control Groups (cgroups) in a Linux system. It provides real-time insights into resource usage, limits, and other attributes of containers and other isolated workloads.

Syntax

ctstat [-h] [-s] [-c] [-l] [-n] [-S STATS] [-Q] [-H HDRS] [-S STATS]

Options/Flags

  • -h: Display help message.
  • -s: Sort output by specified column.
  • -c: Display container groups only.
  • -l: Display lists groups only.
  • -n: Display numbers instead of titles in the header.
  • -S STATS: Select specific stats to display.
  • -Q: Suppress header in the output.
  • -H HDRS: Specify custom headers for output.

Examples

Basic usage:

ctstat

Display only container groups:

ctstat -c

Display lists groups:

ctstat -l

Show specific stats:

ctstat -s cpus_throttled -S cpu_acct.usage

Suppress header:

ctstat -Q

Common Issues

  • Permission denied: Ensure you have sufficient privileges to access cgroup information.
  • Unknown column: Check that the specified column name in -s is valid.
  • No cgroups: If no cgroups are active on the system, ctstat may not display any information.

Integration

Combine with top to monitor resource utilization:

top -c | ctstat -l

Use with awk to filter and extract specific data:

ctstat -l | awk '$2 >= 200' | sort -nr

Related Commands