HPUX: number of open files
Hallo,
I was looking some time for a good way to debug file handle related
problems. Maybe somebody can help me with some questions I have
(regarding HP-UX 11.* IA64):
- for a running application (not shell) can I find out what the
process' soft and hard limits for number of files (and sockets I
guess) is?
- for a running application, can I actually read the number of used
handles? (I only know the work around with lsof -p, but I am not sure
how reliable I can get to the real count)
Besides that I wonder if a process reaches the soft limit or the
system wide nfile limit, is there a counter or log event I can monitor
for?
And finally, If I read the man pages right, the soft/hardlimit of a
login session is defined by the kernel tunables maxfiles and
maxfiles_lim and there is no project/group specific settings build
into HPUX (unlike PAM/limits.conf for Linux or Projects for Solaris)
Greetings
Bernd
--
[url]http://itblog.eckenfels.net[/url] (german)
Re: HPUX: number of open files
[email]bernd.eckenfels@googlemail.com[/email] wrote:[color=blue]
> - for a running application (not shell) can I find out what the
> process' soft and hard limits for number of files (and sockets I
> guess) is?[/color]
You can call getrlimit(2). Use RLIMIT_NOFILE.
[color=blue]
> - for a running application, can I actually read the number of used
> handles? (I only know the work around with lsof -p, but I am not sure
> how reliable I can get to the real count)[/color]
I suppose you could use pstat_getfile2(2) to get a list of the files.
[color=blue]
> Besides that I wonder if a process reaches the soft limit or the
> system wide nfile limit, is there a counter or log event I can monitor
> for?[/color]
For nfile, you can use: kcusage nfile
[color=blue]
> the soft/hardlimit of a
> login session is defined by the kernel tunables maxfiles and
> maxfiles_lim and there is no project/group specific settings built
> into HP-UX[/color]
Yes. Unless ulimit -n (POSIX shell only) is used to set them smaller,
either in /etc/profile or ~/.profile.
Re: HPUX: number of open files
Hello Dennis,
thanks for your hints:
On 10 Nov., 22:24, Dennis Handly <dhan...@convex.hp.com> wrote:[color=blue]
> You can call getrlimit(2). *Use RLIMIT_NOFILE.[/color]
Yes, but I want to do that from outside the application. I think I can
get it to spawn a shell, so that would be the easiest. Just wondered
if one could remote attach an debugger or have some /proc/<pid> info
(like Linux).
[color=blue]
> For nfile, you can use: kcusage nfile[/color]
Very good, found that. I guess with 11i it is dynamic/unlimited
usually anyway.
Greetings
Bernd
PS: why is ksh not supporting the NOFILE, isnt that one of the more
important resource limits?
Re: HPUX: number of open files
[email]bernd.eckenfels@googlemail.com[/email] wrote:[color=blue]
> Hallo,
>
> I was looking some time for a good way to debug file handle related
> problems. Maybe somebody can help me with some questions I have
> (regarding HP-UX 11.* IA64):
>
> - for a running application (not shell) can I find out what the
> process' soft and hard limits for number of files (and sockets I
> guess) is?
>
> - for a running application, can I actually read the number of used
> handles? (I only know the work around with lsof -p, but I am not sure
> how reliable I can get to the real count)[/color]
Don't know for HP-UX. Solaris has pfiles.
[color=blue]
>
> Besides that I wonder if a process reaches the soft limit or the
> system wide nfile limit, is there a counter or log event I can monitor
> for?[/color]
syslog file, HP-UX normally has /var/adm/syslog/syslog.log
[color=blue]
>
> And finally, If I read the man pages right, the soft/hardlimit of a
> login session is defined by the kernel tunables maxfiles and
> maxfiles_lim and there is no project/group specific settings build
> into HPUX (unlike PAM/limits.conf for Linux or Projects for Solaris)
>[/color]
These limits belong to the process environment, so Unix inheritance
takes place.
A shell spawned from your application is a child, and can give nothing
to its parent (only to its children).
But a shell wrapper like this will do it:
#!/bin/sh
ulimit -n 512
exec /path/to/application "$@"
--
echo imhcea\.lophc.tcs.hmo |
sed 's2\(....\)\(.\{5\}\)2\2\122;s1\(.\)\(.\)1\2\11g;1s;\.;::;2'
Re: HPUX: number of open files
Bernd Eckenfels wrote:[color=blue]
> but I want to do that from outside the application.[/color]
Do what? Get the limit? The limit is normally the same for everyone.
Get how many files currently open? pstat_getfile2(2)
[color=blue]
> if one could remote attach an debugger[/color]
I'm not sure what a debugger could tell you.
[color=blue]
> PS: why is ksh not supporting the NOFILE, isn't that one of the more
> important resource limits?[/color]
No, I would expect the data size to be more important. And ksh has
always been johnny come lately with uname.