Best of Linux

Tools for Monitoring Disk Activity in Linux

Disk activity refers to the percentage of time the currently running disk is busy performing various activities. Activity includes disk read, and disk writes activity, etc. There are various parameters on which Disk activities are being monitored. Some of them are listed below:

  • Disk space (Usage): This parameter shows the amount of space occupied by the currently selected disk.
  • Disk space (free): This parameter shows the amount of unoccupied space by the currently selected disk.
  • Disk Read Activity: This shows the percentage of time elapsed by the disk in performing read requests.
  • Disk Write Activity: This shows the percentage of time elapsed by the disk in performing write requests.

These are only some of the parameters on which the activity of the disk is being measured. There are still more parameters, which we need not discuss at this stage.

To measure how our system’s hard disks perform, we need to have some tools to perform quantitative analysis of disk activities.

Tools for Monitoring Disk Activity in Linux

Following are some of the tools which we are going to discuss in detail about their usage, installation step by step:

IOSTAT

IOSTAT stands for Input-Output Statistics. It is one of the most popular tools among developers and geeks. They use it to check all the i/o activities which are being done by a specific disk that is connected with our system. This tool also tracks the disk’s average running time to process the input and output reads connected to peripheral devices.

Commands used by IOSTAT are capable of generating a detailed report which can further be used to amend the system configuration. It may be helpful to the users to optimize the system disk usage and its performance. This tool usually gives CPU and Device utilization analysis separately.

How to Install IOSTAT on Linux

Sysstat is the package that contains the IOSTAT tool. So, we can directly install this tool from this package. On Ubuntu, we can run the following command to proceed with the installation:

Running IOSTAT Commands to Analyze Disk Performance

There are plenty of commands which are specific to trigger various functionality of the IOSTAT tool. Following are the majorly used commands:

  • iostat: Using this command, we can get the list of all the parameters and the current readings of various parameters discussed above.
  • iostat -d: This command shows the statistics related to all the input/output devices.
  • iostat -p: This command shows the statistics related to all the input/output devices and parameter readings.
  • iostat -x: This command returns the detailed analysis of input/output activities done by all the devices.
  • iostat -d: This command shows the statistics related to a particular device.
  • iostat -m: This command shows the MB statistics of all the hard disks in the system.
  • Nfsiostat: This command enables the users to analyze NFS’s disk utilization (network file sys.).

IOTOP

IOTOP is a disk activity monitoring Linux OS-based tool. It gives real-time analysis and disk usage by the operating system. It accesses all the information related to disk utilization from the Linux kernel directly. It makes the system more reliable in terms of accuracy since all the fetched data will be real-time.

It is based on a multi-thread model. It gives information about every thread involved in the i/o activity along with their bandwidth utilization.

How to install IOTOP on Linux

We can use the Linux distribution packages to install this tool in our system. The following command helps us to do the same in Linux operating system:

Running IOTOP Commands to Analyze Disk Performance

There are several commands present in the IOTOP tool to analyze the disk activities based on a different perspective. Following are the few majorly used commands:

  • iotop: This command shows the reading of all the disks along with all the parameters discussed above.
  • iotop –only: This command allows us to check only those consuming disk input-output operations.

DSTAT

DSTAT is an efficient, flexible, and robust tool for producing Linux OS resource statistics that can be used in place of all of the previous tools. Following are some of the common features offered by the Dstat tool:

  • It generates the cumulative results after combining iostat, vmstat, mpstat, and netstat tools.
  • It generates the statistics on a real-time basis.
  • It is highly scalable.
  • It shows interrupts generated from each device.
  • Gives accurate results even when the system is highly overloaded from processes.
  • It enables users to export the generated results in a .csv file format.

How to Install DSTAT on Linux

You can install it by following the same process. It is available on the Linux distro. Packages. So, the following command can be executed from the command line to proceed with the installation:

$ sudo apt-get install dstat

Running DSTAT Commands to Analyze Disk Performance

There are several commands present in the DSTAT tool to analyze the disk activities based on a different perspective. Following are the few majorly used commands:

dstat: This command shows the reading of all the disks and all the parameters discussed above, such as total bytes sent, received, waiting time, idle time, read/write time, Disk statistics, etc.

dstat –vmstat: This command produces output containing data related to Processes and memory statistics.

dstat -c –top-cpu -dn –top-mem: This command consists of various sub-commands. They are as follows:

  • -c : gives detail about CPU utilization.
  • –top-cpu: This shows the name of the process consuming the highest percentage of CPU.
  • -dn: This shows the status of the network and disks of the system.
  • –top-mem: This shows the name of the process consuming the highest percentage of memory.

In this way, DSTAT offers many other commands that can be executed for extracting data related to disk and network performances and analyze them in detail.

ATOP

ATOP is specifically useful when there is a need to analyze changes at the system level. It performs a fantastic job of briefing improvements over time. It can tabulate all the processes that induced any system-level changes (such as performing disc input-output) during the specific period, unlike the others – this function is only provided by ATOP.

It is an alternative tool that can be used to analyze disk resources. It can also analyze Linux-based servers, network-related parameters, etc. There are few advantages for using this tool apart from the one we discussed above, and the following are a few of them:

  • We can view the resource utilization done by the processes which were closed long before.
  • It keeps track of all the active threads in multi-threaded applications and leaves the rest, which is in-active ones.
  • It highlights those resources which use the resources at a critical level, thus producing a high user experience.

How to Install ATOP on Linux

Atop can be installed in Ubuntu-based operating systems by executing the following command. This command fetches the package from the default Linux repository.

$ sudo apt-get install atop

Running ATOP Commands to Analyze Disk Performance

Listed below are some of the commands offered by atop tool, using which users can perform different sets of activities to analyze their system’s disk utilization and network bandwidth related to it:

  • atop -m: This command shows the memory consumption done by all the live processes.
  • atop -V: Displays installed atop version.
  • atop -a: This command shows the live status of all live processes.
  • atop -s: This command displays all information related to task scheduling.
  • atop -d: Displays information related to data consumption during disk input/output activities.
  • atop -v: Displays information such as userId, rgid, processId, etc.
  • atop -y: Displays information of all the live thread in the active processes.
  • atop -C: Lists all the processes in sorted order of the consumption CPU level.

IOPING

IOPING is a kind of tool which offers different features. This tool is specially used to analyze the latency of the disk, i.e., how long a specific disk takes time to respond to a particular read-write request.

How to Install IOPING on Linux

To install IOPING on Linux operating systems, we can execute the following terminal command:

$ sudo apt-get install ioping

Running IOPING Commands to Analyze Disk Performance

Listed below are some of the IOPING tool’s commands, using which users can check the latency-related issues and troubleshoot them with ease.

  • ioping -c count: Represents the number of counts after which the tool gets halted.
  • ioping -i interval: Constraints time between interval to that of requested timestamp.
  • ioping -l speed: Limits the speed of data transfer in bytes/sec.
  • ioping -t time: Some processes get ignored due to they have very little request time. So, to avoid this, we can set the request time.
  • ioping -w deadline: Tool gets stopped after the time interval set through this command.
  • ioping -D: Instructs the system to do read/write requests.
  • ioping -R: This tests the rate at which the disk seeks the data.
  • ioping -c 20 -s 1M /temp1: This command gives a quantitative report on /temp1 by transferring 21 requests each of 1MB.
  • ioping -RL /dev/sda: Displays sequential disk speed.
  • ioping -RLB. | awk ‘{print $4}’: Displays sequential disk speed in bytes/sec.

Conclusion

Throughout this article, we discussed various tools that can be used to monitor Disk Activities in Linux-based operating systems. Every tool delivers its own set of features, which helps the user analyze how their system behaves from the inside.

By detailed analysis, system admins can make the desired changes in their system configurations to make their system work faster and smoother. These tools produce results that show the system’s current state, disk health, network bandwidth utilization, and a lot more.

Using these tools can make system admins troubleshoot issues related to disk and operating systems in a go. It will allow them to save time while troubleshooting and keep their system in a proper state while performing heavy resource utilization tasks.

About the author

Prateek Jangid

A passionate Linux user for personal and professional reasons, always exploring what is new in the world of Linux and sharing with my readers.