2.3. Diskdevstat and netdevstat
2.3. Diskdevstat and netdevstat Diskdevstat and netdevstat are SystemTap tools that collect detailed information about the disk activity and network activity of all applications running on a system. These tools were inspired by PowerTOP , which shows the number of CPU wakeups by every application per second (refer to Section 2.2, "PowerTOP" ). The statistics that these tools collect allow you to identify applications that waste power with many small I/O operations rather than fewer, larger operations. Other monitoring tools that measure only transfer speeds do not help to identify this type of usage. Install these tools with SystemTap with the following command as root : Run the tools with the command: or the command: Both commands can take up to three parameters, as follows: diskdevstat update_interval total_duration display_histogram netdevstat update_interval total_duration display_histogram update_interval The time in seconds between updates of the display. Default: 5 total_duration The time in seconds for the whole run. Default: 86400 (1 day) display_histogram Flag whether to histogram for all the collected data at the end of the run. The output resembles that of PowerTOP . Here is sample output from a longer diskdevstat run: The columns are: PID the process ID of the application UID the user ID under which the applications is running DEV the device on which the I/O took place WRITE_CNT the total number of write operations WRITE_MIN the lowest time taken for two consecutive writes (in seconds) WRITE_MAX the greatest time taken for two consecutive writes (in seconds) WRITE_AVG the average time taken for two consecutive writes (in seconds) READ_CNT the total number of read operations READ_MIN the lowest time taken for two consecutive reads (in seconds) READ_MAX the greatest time taken for two consecutive reads (in seconds) READ_AVG the average time taken for two consecutive reads (in seconds) COMMAND the name of the process In this example, three very obvious applications stand out: These three applications have a WRITE_CNT greater than 0 , which means that they performed some form of write during the measurement. Of those, plasma was the worst offender by a large degree: it performed the most write operations, and of course the average time between writes was the lowest. Plasma would therefore be the best candidate to investigate if you were concerned about power-inefficient applications. Use the strace and ltrace commands to examine applications more closely by tracing all system calls of the given process ID. In the present example, you could run: In this example, the output of the strace contained a repeating pattern every 45 seconds that opened the KDE icon cache file of the user for writing followed by an immediate close of the file again. This led to a necessary physical write to the hard disk as the file metadata (specifically, the modification time) had changed. The final fix was to prevent those unnecessary calls when no updates to the icons had occurred.
~]# yum install tuned-utils-systemtap kernel-debuginfo ~]# diskdevstat ~]# netdevstat PID UID DEV WRITE_CNT WRITE_MIN WRITE_MAX WRITE_AVG READ_CNT READ_MIN READ_MAX READ_AVG COMMAND 2789 2903 sda1 854 0.000 120.000 39.836 0 0.000 0.000 0.000 plasma 5494 0 sda1 0 0.000 0.000 0.000 758 0.000 0.012 0.000 0logwatch 5520 0 sda1 0 0.000 0.000 0.000 140 0.000 0.009 0.000 perl 5549 0 sda1 0 0.000 0.000 0.000 140 0.000 0.009 0.000 perl 5585 0 sda1 0 0.000 0.000 0.000 108 0.001 0.002 0.000 perl 2573 0 sda1 63 0.033 3600.015 515.226 0 0.000 0.000 0.000 auditd 5429 0 sda1 0 0.000 0.000 0.000 62 0.009 0.009 0.000 crond 5379 0 sda1 0 0.000 0.000 0.000 62 0.008 0.008 0.000 crond 5473 0 sda1 0 0.000 0.000 0.000 62 0.008 0.008 0.000 crond 5415 0 sda1 0 0.000 0.000 0.000 62 0.008 0.008 0.000 crond 5433 0 sda1 0 0.000 0.000 0.000 62 0.008 0.008 0.000 crond 5425 0 sda1 0 0.000 0.000 0.000 62 0.007 0.007 0.000 crond 5375 0 sda1 0 0.000 0.000 0.000 62 0.008 0.008 0.000 crond 5477 0 sda1 0 0.000 0.000 0.000 62 0.007 0.007 0.000 crond 5469 0 sda1 0 0.000 0.000 0.000 62 0.007 0.007 0.000 crond 5419 0 sda1 0 0.000 0.000 0.000 62 0.008 0.008 0.000 crond 5481 0 sda1 0 0.000 0.000 0.000 61 0.000 0.001 0.000 crond 5355 0 sda1 0 0.000 0.000 0.000 37 0.000 0.014 0.001 laptop_mode 2153 0 sda1 26 0.003 3600.029 1290.730 0 0.000 0.000 0.000 rsyslogd 5575 0 sda1 0 0.000 0.000 0.000 16 0.000 0.000 0.000 cat 5581 0 sda1 0 0.000 0.000 0.000 12 0.001 0.002 0.000 perl 5582 0 sda1 0 0.000 0.000 0.000 12 0.001 0.002 0.000 perl 5579 0 sda1 0 0.000 0.000 0.000 12 0.000 0.001 0.000 perl 5580 0 sda1 0 0.000 0.000 0.000 12 0.001 0.001 0.000 perl 5354 0 sda1 0 0.000 0.000 0.000 12 0.000 0.170 0.014 s h 5584 0 sda1 0 0.000 0.000 0.000 12 0.001 0.002 0.000 perl 5548 0 sda1 0 0.000 0.000 0.000 12 0.001 0.014 0.001 perl 5577 0 sda1 0 0.000 0.000 0.000 12 0.001 0.003 0.000 perl 5519 0 sda1 0 0.000 0.000 0.000 12 0.001 0.005 0.000 perl 5578 0 sda1 0 0.000 0.000 0.000 12 0.001 0.001 0.000 perl 5583 0 sda1 0 0.000 0.000 0.000 12 0.001 0.001 0.000 perl 5547 0 sda1 0 0.000 0.000 0.000 11 0.000 0.002 0.000 perl 5576 0 sda1 0 0.000 0.000 0.000 11 0.001 0.001 0.000 perl 5518 0 sda1 0 0.000 0.000 0.000 11 0.000 0.001 0.000 perl 5354 0 sda1 0 0.000 0.000 0.000 10 0.053 0.053 0.005 lm_lid.sh PID UID DEV WRITE_CNT WRITE_MIN WRITE_MAX WRITE_AVG READ_CNT READ_MIN READ_MAX READ_AVG COMMAND 2789 2903 sda1 854 0.000 120.000 39.836 0 0.000 0.000 0.000 plasma 2573 0 sda1 63 0.033 3600.015 515.226 0 0.000 0.000 0.000 auditd 2153 0 sda1 26 0.003 3600.029 1290.730 0 0.000 0.000 0.000 rsyslogd ~]# strace -p 2789