Remember to maintain security and privacy. Do not share sensitive information. Procedimento.com.br may make mistakes. Verify important information. Termo de Responsabilidade

How to Monitor CPU Usage in Linux

Monitoring CPU usage is crucial for maintaining the performance and stability of a Linux system. By keeping an eye on CPU metrics, system administrators can identify resource bottlenecks, optimize processes, and ensure efficient operation. This article will guide you through various tools and methods to monitor CPU usage in a Linux environment.

Examples:

  1. Using top Command: The top command provides a dynamic real-time view of the system's CPU usage. It displays a list of processes and their CPU consumption.

    top

    Once you run the command, you'll see an interface displaying the tasks, CPU states, memory usage, and a list of processes. The %CPU column shows the CPU usage for each process.

  2. Using htop Command: htop is an interactive process viewer for Unix systems. It is a more user-friendly alternative to top.

    sudo apt-get install htop
    htop

    Similar to top, htop provides a real-time view of the system's CPU usage, but with a more intuitive interface.

  3. Using mpstat Command: The mpstat command is part of the sysstat package and provides detailed CPU usage statistics.

    sudo apt-get install sysstat
    mpstat

    To monitor CPU usage at regular intervals, you can use:

    mpstat 1

    This command will display CPU usage every second.

  4. Using sar Command: The sar command, also part of the sysstat package, collects, reports, and saves system activity information.

    sudo apt-get install sysstat
    sar -u 1 3

    This command will report CPU usage every second for three intervals.

  5. Using iostat Command: The iostat command is used for monitoring system input/output device loading by observing the time the devices are active in relation to their average transfer rates.

    sudo apt-get install sysstat
    iostat -c 1

    This command will display CPU statistics every second.

  6. Using vmstat Command: The vmstat command reports information about processes, memory, paging, block IO, traps, and CPU activity.

    vmstat 1

    This command will display a summary of system performance every second.

  7. Using nmon Command: nmon (Nigel's Monitor) is a system administrator's tool for performance monitoring.

    sudo apt-get install nmon
    nmon

    After running nmon, press c to display CPU usage.

To share Download PDF

Gostou do artigo? Deixe sua avaliação!
Sua opinião é muito importante para nós. Clique em um dos botões abaixo para nos dizer o que achou deste conteúdo.