home *** CD-ROM | disk | FTP | other *** search
- pff (process-file-file, with emphasis on the ff) shows running processes
- and their open files.
-
- Examples are worth a million words, so here's a sampling of how I've
- used pff (updated to reflect the latest option set). -swhatever can be
- abbreviated as -sw.
-
- pff -asfull > ~/log
- Full report on everything pff can see. Useful when the
- system is dying and you want to know what's going on.
- pff -astiny One line per process that has anything open, with each
- open file noted but not explained.
- pff #221 #17484 All files those processes have open. (# is redundant.)
- pff -aspids All active pids. (This isn't as fast as it could be.)
- pff -a | more All open files, in my favorite format.
- pff /etc/passwd Who's snooping?
- pff /etc/telnetd.old
- Who's running the telnetd.old program? (Useful after
- you've installed a new telnetd and want to make sure
- nobody's using the old one. Might not work on Sun 4s,
- where processes don't have their programs open except
- possibly as mmaps.)
- pff -d/nfs.vlsi1
- Who's keeping that filesystem busy? (-d is redundant.)
- If this doesn't show anything, and the filesystem in
- question doesn't contain another mounted filesystem,
- then you should always be able to unmount it.
- pff -f/usr/dead Who's in that directory? (-f redundant.)
- pff -stiny /acf5.h
- Short report on who's using my filesystem.
- pff /dev/ttyp7 All open files---including cttys---giving access to my tty.
- pff -sbrief -ujoe
- All files open by user joe. (This does not show
- files *opened* by user joe, or files *owned* by user
- joe, or processes with a different effective uid, though
- I suppose pff could be adapted to handle those cases.)
- You can use uids, like pff -u195.
- pff -slong /tmp/. /tmp/*
- How are people using /tmp? (Somewhat detailed report.)
- pff -i0 Who's using the Internet?
- pff -ismtp Who has the SMTP port open? (Compare to fstat.) You can
- use numeric port ids, like pff -i25.
- pff -sbrief `pff -spids ./data`
- All files open by all processes accessing ./data.
- pff -snames All files open, with pathnames. (Only works if you have
- findinode installed.)
-
- Although pff can handle any number of options at once---e.g., ``show me
- every open file on /acf5.h, or on /usr, or on Internet port 25, not to
- mention /dev/null''---I rarely want to see a combined view.
-
- And now, the options:
-
- -u uid tells pff to show all processes running with a given effective uid.
- -p pid tells pff to show the processes with that pid.
-
- If pff is not given any -u or -p options, it shows all processes. (This
- doesn't mean it will actually print anything, since by default it only
- shows open files, which are controlled by the following options.)
-
- Note that pff can be compiled with a security option (-DSECURITY) which
- currently restricts the report to processes with the same real uid as
- the invoker of pff. This restriction is not applied if the real uid is
- root or if pff is not setgid. (If you only want to see root processes as
- root, use -x.)
-
- -f foo tells pff to show every open file referring to file foo.
- Note that all devices with the same remote device are
- considered to be the same file, even when they are not.
- -d fs tells pff to show every open file on the given filesystem.
- -i port tells pff to show every inet connection to the given local port.
- Port 0 refers to all inet connections.
-
- -a tells pff to show all open files for the selected processes.
- This option is automatically turned on under -p and -u.
- It is ignored under -f, -d, and -i. In other words, the only
- time it makes a difference is when you have no other options
- (except maybe -s), and I hate having a program spew mounds of
- garbage at me just because I forgot to specify which particular
- mound to spew.
-
- -s style tells pff to use a particular output style. Only the first
- letter of the style matters. Style brief is close to fstat and
- the Abell ofiles; style uidlong includes file flags, offset,
- credentials, etc., and style long prints users by name if possible.
- Style default, in the middle, is my favorite. Style full has the
- most information (including per-process information) but is
- relatively unstructured. Style tiny is close to the Dupuy ofiles.
- Style pids prints pids only. Style names includes filenames.
- -shelp shows all styles available; -sHelp shows all styles
- available and gives descriptions.
-
- Any further arguments are interpreted as follows: any that start with /
- or . are taken to be files; any that start with # are taken to be pids;
- any that are entirely numeric are taken to be pids; and the rest are
- taken to be files. ``Files'' means -f *and* -d here; ``pids'' means -p.
-
-
- Notes on #ifdefs (possibly out of date):
-
- STAT_TIMEOUT in mntops.c, fine.
- *_H in *.h to handle repeated inclusion.
-
- IPPROTO_* in printprotoinet.c to handle different IP protocol support.
- RLIMIT_* in printrlimits.c to handle different rlimit support.
- DTYPE_* in printftype.c to handle different descriptor type support.
- AF_* in printfamily.c to handle different address family support.
- S* in printpstat.c to handle different process status support.
-
- UTMP_FILE used in load.c. Hmm.
- SIDL used for a bit of SIDL-specific stuff in pff.c. Hmm.
- S_IFIFO enables some FIFO-specific stuff in various files. Hmm.
-
- REMOTESIZE, NETSTAT* in netinp.c for various internal purposes. Ungood.
- NOSTAT_* in getmnt.c for various internal purposes. Ungood.
-
- FILE, IPPROTO_TCP, FHLOCAL, MSIZE, MNTMAXSTR, NFS_RETRIES, SOCK_STREAM,
- RTF_UP, SS_ISCONNECTED, RLIM_NLIMITS, bool_t: wrappers around #include
- files. It is disgusting that any of these are necessary.
-
-
- TODO:
-
- DO ERROR CHECKING! pff.c, getnode.c, and getvmseg.c are ridiculously
- fragile.
-
- Move printbuf and printsbuf into getnode.c and getsocket.c...
-
- security: what about reporting on files owned by user?
-
- give better reports on pipes on Ultrix? other file types?
-
- fix up include files in Makefile! aargh, should've used mick
-
- Allow more socket selection options?
-
- Automatically put in names when they're known from multiple -f?
-
- Make sure all characters are printable? Option? Don't print sock name?
-
- :port arg? nah
-
- deal with mount points to catch non-unmountable /usr/spool because
- /usr/spool/mail is mounted? nah
-
- put back numeric styles as undocumented/deprecated? nah
-
- do something about scandev slowness? cache info?
-
- do something about stat'ing downed filesystems? cache info?
-
- cache usernames, portnames, etc.?
-
-
-
- Some notes on typical execution profile on a Sun:
-
- 57% of the time is in read(), most of that from kmemcpy(), an
- obnoxiously large amount from Sun's kvm library. Of the kmemcpys, 40%
- are from getsocket, 40% are from getvmseg, 15% are from getnode, and 5%
- are from getpcred.
-
- 18% goes to stat()s from scandev(). Hmmm. There are 243 entries in /dev,
- but only 38 unique devices in the pf output, and only 7 of those are
- anything but pseudo-ttys. (On another machine, there are 800 entries in
- /dev. Ugh!)
-
- 11% of the time is in _doprnt(). It would be worthwhile to replace all
- printf's in pff.c with calls to a simpler string/number format package.
- stdio and printf really are too complex for typical output programs.
-
- 7% goes to nlist(), half of that from Sun's kvm library.
-