HPUX: number of open files - HP UX

This is a discussion on HPUX: number of open files - HP UX ; 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 ...

+ Reply to Thread
Results 1 to 5 of 5

Thread: HPUX: number of open files

  1. 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
    --
    http://itblog.eckenfels.net (german)

  2. Re: HPUX: number of open files

    bernd.eckenfels@googlemail.com wrote:
    > - 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?



    You can call getrlimit(2). Use RLIMIT_NOFILE.

    > - 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)



    I suppose you could use pstat_getfile2(2) to get a list of the files.

    > 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?



    For nfile, you can use: kcusage nfile

    > 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



    Yes. Unless ulimit -n (POSIX shell only) is used to set them smaller,
    either in /etc/profile or ~/.profile.

  3. Re: HPUX: number of open files

    Hello Dennis,

    thanks for your hints:

    On 10 Nov., 22:24, Dennis Handly wrote:
    > You can call getrlimit(2). *Use RLIMIT_NOFILE.


    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/ info
    (like Linux).

    > For nfile, you can use: kcusage nfile


    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?

  4. Re: HPUX: number of open files

    bernd.eckenfels@googlemail.com wrote:
    > 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)


    Don't know for HP-UX. Solaris has pfiles.

    >
    > 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?


    syslog file, HP-UX normally has /var/adm/syslog/syslog.log

    >
    > 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)
    >


    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;1 s;\.;::;2'

  5. Re: HPUX: number of open files

    Bernd Eckenfels wrote:
    > but I want to do that from outside the application.


    Do what? Get the limit? The limit is normally the same for everyone.
    Get how many files currently open? pstat_getfile2(2)

    > if one could remote attach an debugger


    I'm not sure what a debugger could tell you.

    > PS: why is ksh not supporting the NOFILE, isn't that one of the more
    > important resource limits?


    No, I would expect the data size to be more important. And ksh has
    always been johnny come lately with uname.

+ Reply to Thread