Operating System - HP-UX
1832870 Members
5103 Online
110048 Solutions
New Discussion

Report number of open files per process

 
SOLVED
Go to solution
Florin_6
Occasional Contributor

Report number of open files per process

Hello,

The number of open files in my system is pretty high and I do not understand why.
I would like to get a report with all processes and the total number of opened files for each process. Like this I can see in the top of the list the processes that are having the higher number of opened files.

I used glance to check the total number of opened files and to see the processes that take most of the CPU time. However the process having most of CPU does not necessarily has the highest number of files open. So glance is not solving my problem.... unless there is a screen/option I did not discover.

Probably a better option would be to use lsof but I could not manage to make it work the way I want it.

Thanks for any hint you can give me!
Florin
Knowledge speaks, but wisdom listens. (Jimi Hendrix)
6 REPLIES 6
Christian Gebhardt
Honored Contributor

Re: Report number of open files per process

Hi

you can use lsof to list open files of a process

http://hpux.asknet.de/hppd/hpux/Sysadmin/lsof-4.64/

Chris

John Poff
Honored Contributor

Re: Report number of open files per process

Hi Florin,

As you mentioned, the lsof utility is the best tool for what you need. Here is a recent thread about the question of matching the nfile parameter in the kernel to the number of open files reported by lsof:

http://forums.itrc.hp.com/cm/QuestionAnswer/1,,0x973f28c64656d71190080090279cd0f9,00.html

JP
U.SivaKumar_2
Honored Contributor

Re: Report number of open files per process

Hi,

Why not...

Here iam finding out the number of open files by httpd process.

#lsof | grep httpd | grep -vi listen | wc -l
192

regards,

U.SivaKumar





Innovations are made when conventions are broken
steven Burgess_2
Honored Contributor

Re: Report number of open files per process

Hi Florin

yes lsof is the best tool as mentioned. For open files per single process within glance look at -F option

glance -F
enter PID (3476)

HTH

Steve
take your time and think things through
Ramkumar Devanathan
Honored Contributor
Solution

Re: Report number of open files per process

Florin,

this would help to get the number of files open per process with lsof's output -

lsof | awk '{procct[$1]++;procname[$1]=$1;}END{for (i in procname) {printf ("%s, %d\n",procname[i],procct[i]);}}'

- ramd.
HPE Software Rocks!
Christian Gebhardt
Honored Contributor

Re: Report number of open files per process

Hi

Here's a script to better use lsof

lsof | awk '{line[NR]=$1}
END {
count=0
for (i=2 ; i <=NR ; i++)
{
if (line[i] != line [i-1])
{printf("%s %s\n",count, line[i-1])
count=1}
else
{count++
}
}
}' | sort -n


Chris