이 콘텐츠는 선택한 언어로 제공되지 않습니다.
4.2. Disk
4.2.1. Summarizing Disk Read/Write Traffic 링크 복사링크가 클립보드에 복사되었습니다!
Example 4.9. disktop.stp
UID
— user ID. A user ID of0
refers to the root user.PID
— the ID of the listed process.PPID
— the process ID of the listed process's parent process.CMD
— the name of the listed process.DEVICE
— which storage device the listed process is reading from or writing to.T
— the type of action performed by the listed process;W
refers to write, andR
refers to read.BYTES
— the amount of data read to or written from disk.
ctime()
and gettimeofday_s()
. ctime()
derives calendar time in terms of seconds passed since the start of the Unix time (January 1, 1970). gettimeofday_s()
counts the actual number of seconds since the start of the Unix time, which gives a fairly accurate human-readable timestamp for the output.
$return
is a local variable that stores the actual number of bytes each process reads or writes from the virtual file system. $return
can only be used in return probes (for example, vfs.read.return
and vfs.read.return
).
Example 4.10. Example 4.9, “disktop.stp” Sample Output
4.2.2. Tracking I/O Time For Each File Read or Write 링크 복사링크가 클립보드에 복사되었습니다!
Example 4.11. iotime.stp
$count
to track the amount of data (in bytes) that any system call attempts to read or write. Note that $return
(as used in Example 4.9, “disktop.stp” from Section 4.2.1, “Summarizing Disk Read/Write Traffic”) stores the actual amount of data read/written. $count
can only be used on probes that track data reads or writes (e.g. syscall.read
and syscall.write
).
Example 4.12. Example 4.11, “iotime.stp” Sample Output
- A timestamp, in microseconds.
- Process ID and process name.
- An
access
oriotime
flag. - The file accessed.
access
and iotime
lines should appear together. The access
line's timestamp refers to the time that a given process started accessing a file; at the end of the line, it will show the amount of data read/written (in bytes). The iotime
line will show the amount of time (in microseconds) that the process took in order to perform the read or write.
access
line is not followed by an iotime
line, it simply means that the process did not read or write any data.
4.2.3. Track Cumulative IO 링크 복사링크가 클립보드에 복사되었습니다!
Example 4.13. traceio.stp
$return
, which is also used by Example 4.9, “disktop.stp” from Section 4.2.1, “Summarizing Disk Read/Write Traffic”.
Example 4.14. Example 4.13, “traceio.stp” Sample Output
4.2.4. I/O Monitoring (By Device) 링크 복사링크가 클립보드에 복사되었습니다!
Example 4.15. traceio2.stp
stat -c "0x%D" directory
, where directory is located on the device you wish to monitor.
usrdev2kerndev()
function converts the whole device number into the format understood by the kernel. The output produced by usrdev2kerndev()
is used in conjunction with the MKDEV()
, MINOR()
, and MAJOR()
functions to determine the major and minor numbers of a specific device.
vfs_read
or vfs_write
), and the kernel device number.
stap traceio2.stp 0x805
, where 0x805
is the whole device number of /home
. /home
resides in /dev/sda5
, which is the device we wish to monitor.
Example 4.16. Example 4.15, “traceio2.stp” Sample Output
4.2.5. Monitoring Reads and Writes to a File 링크 복사링크가 클립보드에 복사되었습니다!
Example 4.17. inodewatch.stp
- The file's major device number.
- The file's minor device number.
- The file's
inode
number.
stat -c '%D %i' filename
, where filename is an absolute path.
/etc/crontab
file, run stat -c '%D %i' /etc/crontab
first. This outputs the following output:
805 1078319
805 1078319
805
is the base-16 (hexadecimal) device number. The lower two digits are the minor device number, and the upper digits are the major number. 1078319
is the inode
number. To start monitoring /etc/crontab
, run stap inodewatch.stp 0x8 0x05 1078319
(The 0x
prefixes indicate base-16 values).
vfs_read
or vfs_write
), the device number (in hex format), and the inode
number. Example 4.18, “Example 4.17, “inodewatch.stp” Sample Output” contains the output of stap inodewatch.stp 0x8 0x05 1078319
(when cat /etc/crontab
is executed while the script is running):
Example 4.18. Example 4.17, “inodewatch.stp” Sample Output
cat(16437) vfs_read 0x800005/1078319 cat(16437) vfs_read 0x800005/1078319
cat(16437) vfs_read 0x800005/1078319
cat(16437) vfs_read 0x800005/1078319
4.2.6. Monitoring Changes to File Attributes 링크 복사링크가 클립보드에 복사되었습니다!
Example 4.19. inodewatch2-simple.stp
inode
number as arguments. For more information on how to retrieve this information, see Section 4.2.5, “Monitoring Reads and Writes to a File”.
uid()
). Example 4.20, “Example 4.19, “inodewatch2-simple.stp” Sample Output” shows the output of Example 4.19, “inodewatch2-simple.stp” while monitoring /home/joe/bigfile
when user joe
executes chmod 777 /home/joe/bigfile
and chmod 666 /home/joe/bigfile
.
Example 4.20. Example 4.19, “inodewatch2-simple.stp” Sample Output
chmod(17448) inode_setattr 0x800005/6011835 100777 500 chmod(17449) inode_setattr 0x800005/6011835 100666 500
chmod(17448) inode_setattr 0x800005/6011835 100777 500
chmod(17449) inode_setattr 0x800005/6011835 100666 500