How do I see which files my application is performing I/O Upon
Most operating systems let you list the open files a process is using. The way that this is done, if it's possible, is platform specific. Here are two tricks that you can use to see your open files on Linux systems. Begin by defining TotalView CLI Tcl procedures. One lists /proc/pid/fd and the other runs lsof:
proc procfd {} {
exec ls -l /proc/[f p TV::process get [TV::focus_processes]
syspid]/fd
}
proc lsof {} {
exec lsof -p [f p TV::process get [TV::focus_processes] syspid]
}
The procfd procedure, which should work on any Linux system, lists the
contents of /proc/pid/fd for the focus process. For example:
d1.<> procfd
total 0
lrwx------ 1 a_user totalvue 64 Jul 25 07:59 0 -> /dev/pts/6
lrwx------ 1 a_user totalvue 64 Jul 25 08:01 2 -> /dev/pts/6
lrwx------ 1 a_user totalvue 64 Jul 25 08:01 3 -> socket:[18255404]
lrwx------ 1 a_user totalvue 64 Jul 25 08:01 4 -> socket:[18255410]
lr-x------ 1 a_user totalvue 64 Jul 25 08:01 5 -> /proc/10756/maps
lr-x------ 1 a_user totalvue 64 Jul 25 08:01 6 -> /proc/10763/maps
d1.<>
The lsof procedure runs the lsof program (see http://en.wikipedia.org/wiki/Ls
of for more information). While it is portable across more operating
systems. it is not a standard utility. This means that you may need to install
(for example, yum install lsof on Red Hat systems) or build it from source.
Also, some systems may be configured so that you need to run it as root.
Here is an example of the output from the lsof Tcl procedure:
d1.<> lsof
COMMAND PID USER FD TYPE DEVICE SIZE NODE NAME
cli 10752 a_user cwd DIR 8,5 53248 10552005
/home/a_user/../totalview
/src/structures
cli 10752 a_user rtd DIR 8,2 4096 2 /
cli 10752 a_user txt REG 8,5 190104566 655922
/home/a_user/.../totalview
/src/structures/cli
cli 10752 a_user mem REG 8,2 125728 488984
/lib/ld-2.5.so
cli 10752 a_user mem REG 8,2 1585788 489013
/lib/libc-2.5.so
cli 10752 a_user mem REG 8,2 16528 489014
/lib/libdl-2.5.so
cli 10752 a_user mem REG 8,2 208344 489017
/lib/libm-2.5.so
cli 10752 a_user mem REG 8,2 125668 489019
/lib/libpthread-2.5.so
cli 10752 a_user mem REG 8,2 76396 489029
/lib/libresolv-2.5.so
cli 10752 a_user mem REG 8,2 7720 489032
/lib/libcom_err.so.2.1
cli 10752 a_user mem REG 8,2 15264 489035
/lib/libutil-2.5.so
cli 10752 a_user mem REG 8,2 297464 1661452
/usr/lib/libncurses.so.5.5
cli 10752 a_user mem REG 8,2 242880 489030
...
d1.<>
You can find tips that we've already sent out in our Tip Archive
Help us improve these tips!