2014-09-17
In praise of Solaris's pfiles
command
I'm sure that at one point I was introduced to pfiles
through a
description that called it the Solaris version of lsof
for a
single process. This is true as far as it goes and I'm certain that
I used pfiles
as nothing more than this for a long time, but it
understates what pfiles
can do for you. This is because pfiles
will give you a fair amount more information than lsof
will, and
much of that information is useful stuff to know.
Like lsof
, pfiles
will generally report what a file descriptor
maps to (file, device, network connection, and Solaris IPC 'doors',
often with information about what process is on the other end of
the door). Unlike on some systems, the pfiles
information is good
enough to let you track down who is on the other end of Unix domain
sockets and pipes. Sockets endpoints are usually reported directly;
pipe information generally takes cross-correlating with other
processes to see who else has an S_IFIFO
with the specific ino
open.
(You would think that getting information on the destination of Unix domain sockets would be basic information, but on some systems it can take terrible hacks.)
Pfiles will also report some socket state information for sockets,
like the socket flags and the send and receive buffers. Personally
I don't find this deeply useful and I wish that pfiles
also showed
things like the TCP window and ACK state. Fortunately you can get
this protocol information with 'netstat -f inet -P tcp
' or 'netstat
-v -f inet -P tcp
' (if you want lots of details).
Going beyond this lsof
-like information, pfiles
will also report
various fcntl()
and open()
flags for the file descriptor. This
will give you basic information like the FD's read/write status,
but it goes beyond this; for example, you can immediately see whether
or not a process has its sockets open in non-blocking mode (which
can be important). This is
often stuff that is not reported by other tools and having it handy
can save you from needing deep dives with DTrace, a debugger, or
the program source code.
(I'm sensitive to several of these issues because my recent Amanda
troubleshooting left me needing to chart out the flow of pipes and
to know whether some sockets were nonblocking or not. I could also
have done with information on TCP window sizes at the time, but I
didn't find the netstat
stuff until just now. That's how it goes
sometimes.)