lkml.org 
[lkml]   [1996]   [Dec]   [16]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
From
SubjectRe: linux equiv for pstat, NIS problems
Date

> > > We are currently using "ps ax | wc -l" to get
> > > the process total, but have not yet found a way to count total open files.
> >
> > Quick and dirty
> >
> > echo `find /proc/[0-9]* -path '*/fd/*' | wc -l` / \
> > `cat /proc/sys/kernel/file-max`

echo /proc/[0-9]*/fd/* | wc -w
or
set /proc/[0-9]*/fd/*
echo $#

is a bit less overhead

> ahhhh....thanks =) Found what we need in /proc/sys/kernel/file-nr and
> inode-nr, but you got me going in the right direction =) Much appreciated!

/proc/sys/kernel/file-nr doesn't seem to be the number of all open file
descriptors. why ?!

# find /proc/[0-9]* -path '*/fd/*' | wc -l
185
# echo /proc/[0-9]*/fd/* | wc -w
188
# cat /proc/sys/kernel/file-nr
192

difference between "find" and "echo" method are due to open file handles
of the interactive shell. but /proc/sys/kernel/file-nr is higher.

now I start 10 times

sleep 999 < /vmlinuz &

(you can redirect input or output to any unused/not_opened file)
and now I get

# find /proc/[0-9]* -path '*/fd/*' | wc -l
215
# echo /proc/[0-9]*/fd/* | wc -w
218
# cat /proc/sys/kernel/file-nr
192

why didn't /proc/sys/kernel/file-nr change it's value at all ??


Harald
--
All SCSI disks will from now on ___ _____
be required to send an email notice 0--,| /OOOOOOO\
24 hours prior to complete hardware failure! <_/ / /OOOOOOOOOOO\
\ \/OOOOOOOOOOOOOOO\
\ OOOOOOOOOOOOOOOOO|//
Harald Koenig, \/\/\/\/\/\/\/\/\/
Inst.f.Theoret.Astrophysik // / \\ \
koenig@tat.physik.uni-tuebingen.de ^^^^^ ^^^^^

\
 
 \ /
  Last update: 2005-03-22 13:38    [W:0.030 / U:3.692 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site