top, iotop, iostat and many other commands are used on daily basis to help sysadmins keep the system up and running at all times. It seemed appropriate to bring up the…

top, iotop, iostat and many other commands are used on daily basis to help sysadmins keep the system up and running at all times. It seemed appropriate to bring up the top command overview closer for it to serve as a cheat sheet for most juniors in this industry. Top is used to show the system health, in a way, by displaying key metrics like CPU load, Memory usage, processes, etc. Going from top to bottom I wanted to describe each line in top response and how to interpret each parameter.

Breaking down the logical segments we see General, Tasks, CPU, Memory and Processes and below are details for each:
This line shows:
  • Current time
  • uptime for this machine/system
  • Logged in users
  • Load average showing three values – one minute load, 5 minute load and 15 minute load

Tasks segment is showing numbers for currently processed tasks/processes on the system:

  • Total number of tasks including all states (running, sleeping, stopped and zombie processes) – in this case 102 total
  • Number of running tasks – in this case 2 running
  • Number of sleeping tasks – in this case 100 sleeping
  • Number of stopped tasks – in this case 0 stopped
  • Number of inactive or zombie tasks – in this case 0 zombie

CPU segment describes the CPU “health” with following details:

  • Percentage showing CPU usage for user processes – in this case 0.0 us
  • Percentage showing CPU usage for system processes – in this case 0.3 sy
  • This value is showing percentage for processes with upgraded priority (this value is called nice) – in this case 0.0 ni
  • Percentage showing CPU availability – in this case 99.7 id
  • Percentage of CPU processes waiting for I/O tasks to complete – in this case 0.0 wa
  • Percentage of CPU processes serving hardware interrupts – in this case 0.0 hi
  • Percentage of CPU time used by processes serving software interrupts – in this case 0.0 si
  • Last one is total amount of CPU percentage taken (or stolen – “st”) by hypervisor for another process or processes outside this virtual machine. If there is no virtualization (bare metal server) this amount will always be 0. On virtualized environments we can see either 0 or amount of CPU actually delegated to some other tasks in this case 0.0 st

Memory segment prints out basic information in regards to RAM usage:

  • Total RAM size – in this case 1017220KB (or 1GB)
  • KB of RAM available (out of total size) – in this case 69376
  • Amount of RAM used (out of total size) – in this case 678044
  • Amount of RAM used for buffers and cache (page cache) – in this case 269800

Swap segment displays obvious swap usage details such as:

  • Total amount of swap memory available – in this case 0 total
  • Total free swap memory out of total size – in this case 0 free
  • Used swap memory by tasks or processes – in this case 0 used
  • Since on this server we don’t have swap enabled (obviously) there is only number that signifies allocation size for swap we could choose to use if we enabled swap – in this case 144672 avail Mem

Processes segment lists processes by CPU usage (unless changed to another order parameter) with columns as follows:

  • PID is the process ID assigned to it after the fork – in this case 27013
  • USER represents user scope under which this processes was created – in this case root
  • PR represents the process priority – in this case 20
  • NI is the nice value of the process in question – in this case 0 (range goes from -20 to 19)
  • VIRT represents the amount of virtual memory used by process – in this case 157692KB
  • RES represents the amount of physical memory used by this process – in this case 2256KB
  • SHR represent amount of shared memory used by the process in question – in this case 1576KB
  • S represents process status where flags available are S for Sleep, Z for Zombie and R for Running – in this case R
  • %CPU represents percentage CPU has been engaged on this process – in this case 0.3
  • %MEM represents percentage of RAM used by this process – in this case 0.2
  • TIME+ represents time this process has been active for (and this is the time process spent in R – running – status) – in this case 0:00.02 (2 seconds)
  • COMMAND represents the command ran for this process to be created or, it can be looked at as the name of the process