Monitoring number of file descriptors

On a sun based system, I am running an expect script that after running for some number of iterations, crashes with a "sync byte read" error. We have found this to be that the limit number of file descriptors was too low (shown by "limit -n"), and upon increasing this limit the problem was solved.

I would like to monitor the number of file descriptors that are actually in use at any given time in order to determine how much we actually need to increase this limit by in order to be safe for the size job that we are running. I can not seem to find the right command.

Thanks,
Justin
LVL 1
justinsaneAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

sheetbirdCommented:
/usr/bin/pfiles <pid>  

Will list all the file descriptors, you'll have to do some fancy grep | wc to just get a number.



0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
NukfrorCommented:
bash-3.00# pfiles $$
670:    bash -o vi
  Current rlimit: 256 file descriptors
   0: S_IFCHR mode:0620 dev:270,0 ino:12582918 uid:0 gid:7 rdev:24,1
      O_RDWR|O_NOCTTY|O_LARGEFILE
      /devices/pseudo/pts@0:1
   1: S_IFCHR mode:0620 dev:270,0 ino:12582918 uid:0 gid:7 rdev:24,1
      O_RDWR|O_NOCTTY|O_LARGEFILE
      /devices/pseudo/pts@0:1
   2: S_IFCHR mode:0620 dev:270,0 ino:12582918 uid:0 gid:7 rdev:24,1
      O_RDWR|O_NOCTTY|O_LARGEFILE
      /devices/pseudo/pts@0:1
   3: S_IFDOOR mode:0444 dev:279,0 ino:57 uid:0 gid:0 size:0
      O_RDONLY|O_LARGEFILE FD_CLOEXEC  door to nscd[108]
      /var/run/name_service_door
 255: S_IFCHR mode:0620 dev:270,0 ino:12582918 uid:0 gid:7 rdev:24,1
      O_RDWR|O_NOCTTY|O_LARGEFILE FD_CLOEXEC
      /devices/pseudo/pts@0:1
bash-3.00# pfiles $$ | egrep "^ +[0-9]"
   0: S_IFCHR mode:0620 dev:270,0 ino:12582918 uid:0 gid:7 rdev:24,1
   1: S_IFCHR mode:0620 dev:270,0 ino:12582918 uid:0 gid:7 rdev:24,1
   2: S_IFCHR mode:0620 dev:270,0 ino:12582918 uid:0 gid:7 rdev:24,1
   3: S_IFDOOR mode:0444 dev:279,0 ino:57 uid:0 gid:0 size:0
 255: S_IFCHR mode:0620 dev:270,0 ino:12582918 uid:0 gid:7 rdev:24,1
bash-3.00# pfiles $$ | egrep "^ +[0-9]" | wc -l
       6
0
NukfrorCommented:
The final command above shows "6" because the final example includes a sixth file descriptor to handle the pipe symbol in "| wc -l" command.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Unix OS

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.