pfiles versus lsof
On a great number of internal systems and especially at customer sites I see the lsof utility used over and over again. Whilst predominately used in the Linux world, lsof is also available on the Solaris platform.
However, for a quick check for open files you don't need to utilise the lsof within the Solaris operating environment. There is an useful little tool in the p*tools collection of tools called pfiles. pfiles prints all open files of a process by taking the PID of the process to specify the process.
For example:
# pfiles 214
214: /usr/lib/inet/in.iked
Current rlimit: 256 file descriptors
0: S_IFDIR mode:0755 dev:102 ,0 ino:2 uid:0 gid:0 size:512 O_RDONLY | O_LARGEFILE
/
1: S_IFDIR mode:0755 dev:102 ,0 ino:2 uid:0 gid:0 size:512 O_RDONLY | O_LARGEFILE
/
2: S_IFDIR mode:0755 dev:102 ,0 ino:2 uid:0 gid:0 size:512 O_RDONLY | O_LARGEFILE
/
3: S_IFREG mode:0600 dev:102 ,0 ino:28994 uid:0 gid:0 size:47372 O_RDWR | O_APPEND | O_CREAT | O_LARGEFILE
/var/log/in.iked.log
4: S_IFSOCK mode:0666 dev:304 ,0 ino:48934 uid:0 gid:0 size:0 O_RDWR | O_NONBLOCK
SOCK_RAW
SO_SNDBUF (8192) , SO_RCVBUF (8192)
sockname: AF_INET 10.10.1.201 port: 4500
peername: AF_INET 10.10.1.201 port: 4500
[..]
10: S_IFDOOR mode:0777 dev:306 ,0 ino:0 uid:0 gid:0 size:0 O_RDWR FD_CLOEXEC door to in.iked [214]
Used with the xargs tool an even easier method to print out all open files on a given Solaris system:
# ps -ef -o pid | sort | xargs pfiles | more 0:sched [ system process ] /sbin/init Current rlimit: 256 file descriptors 0: S_IFIFO mode:0600 dev:301 ,3 ino:448255748 uid:0 gid:0 size:0 O_RDWR | O_NDELAY /var/run/initpipe 253: S_IFREG mode:0444 dev:298 ,1 ino:65538 uid:0 gid:0 size:0 O_RDONLY | O_LARGEFILE FD_CLOEXEC /system/contract/process/pbundle 254: S_IFREG mode:0666 dev:298 ,1 ino:65539 uid:0 gid:0 size:0 O_RDWR | O_LARGEFILE FD_CLOEXEC /system/contract/process/template 255: S_IFREG mode:0666 dev:298 ,1 ino:65539 uid:0 gid:0 size:0 O_RDWR | O_LARGEFILE FD_CLOEXEC /system/contract/process/template [...]
Note:This is not a tutorial, just a hint that I picked up somewhere from the net (if I find the original post I'll attribute the credit accordingly) from my toolbox.