in reply to Relating AF_INET sockets to processes using Perl

'lsof' works I think by using the /proc filesystem if available, or by examining kernel memory directly otherwise (the utility is sgid 'kmem').

If you have a /proc filesystem maybe a perl-only solution is possible, but otherwise you'll really want to invoke lsof. It has a special -F option to produce output designed to be easily parsable by awk/perl scripts.

I hope this helps you get started

  • Comment on Re: Relating AF_INET sockets to processes using Perl

Replies are listed 'Best First'.
Re: Re: Relating AF_INET sockets to processes using Perl
by SIGSEGV (Sexton) on Mar 05, 2003 at 08:31 UTC
    xmath,

    on a Linux box I'd definetly make use of the marvelous /proc virtual filesystem.
    Unfortunately does HP-UX lack such a feature.

    I think HP-UX offers a /dev/kmem for kernel space queries. But since I never accessed that special device deliberately (I'm also hesitant because I wouldn't want to tamper with the kernel of a production server while I don't know the implications of privileged access to the kernel data), I simply don't know how to retrieve data from there.

    I think you are right that probably calling lsof and parsing its dump would be the easiest option.