Operating System - HP-UX
1833228 Members
2424 Online
110051 Solutions
New Discussion

Re: open files per process

 
SOLVED
Go to solution
Quin Hammes
Valued Contributor

open files per process

I know with glance (-F function) you can get a list of all open files for a specifi process. Does anyone have an idea to get a list of the number of open files for all processes? We are reaching our limit in nfiles and would like to see if a runaway process or something silimar is opening more files than normal. So we would like to get something like this

process ID # of open files
==============================
123 100
44356 50
etc...

Any help would be appreciated. Thanks!!!

Quin
6 REPLIES 6
harry d brown jr
Honored Contributor
Solution

Re: open files per process

Download "lsof" from

http://hpux.connect.org.uk/

Live Free or Die
Sridhar Bhaskarla
Honored Contributor

Re: open files per process

Quin,

You can get lsof from this following site.
http://hpux.cs.utah.edu/hppd/hpux/Sysadmin/lsof-4.55/

I don't know whether there is a depot for 11.0 but you can compile it from the source code.

-Sri
You may be disappointed if you fail, but you are doomed if you don't try
James R. Ferguson
Acclaimed Contributor

Re: open files per process

Hi Quin:

You can use 'sar -v 10 5' to report the process, inode and file table sizes as defined along with their high-water mark and the number of times they have overflowed.

In the example above, 5-samples will be taken, one every 10-seconds. See 'man sar' for more details.

...JRF...
nancy rippey
Trusted Contributor

Re: open files per process

LSOF should do the trick. In the absence of any options, lsof lists all open files belonging to all active processes. I have found it to be invaluable.

nrip
Bill Hassell
Honored Contributor

Re: open files per process

You might want to limit most users to a small number of files per process with ulimit. This can be set in /etc/profile as a limit for all users except certain ones that will run processes that truly require a lot of files.

nfile is usually too small out of the box, but the correct value might be 500 in a small system, 5000 in a medium system and 60000 on a large system.

Note: ulimit is documented in sh-posix, the preferred shell for all users including root.


Bill Hassell, sysadmin
Magdi KAMAL
Respected Contributor

Re: open files per process

Hi Quin,

Consider the glance with -F and PID giving the following result ( in your example ) :

123 100

The script would be :

for i in `ps -ef ? awk '{print $2}'`
do
#will give you the process ( command )name
ps -ef ? grep $i ? grep -v grep ? awk '{print $8}'`
#will report the open files
glance -F $i
done

Magdi
Will give you a list of all process and their