Get process ids of all processes associated with a given ip-address

Get process ids of all processes associated with a given ip-address

Post by Johannes Mülle » Sat, 14 Feb 1998 04:00:00

we use Solaris 2.5 with client server users under Windows NT against an
Oracle DB.
How can we determine the process ids associated to a given ip-address ?
The clients have no tty, so a ps -t ... won't function.



1. Process id's and their associated process names

Processes on UNIX do not have names in the way that they do on other
systems (eg, VMS).  If you mean the file system name (argv[0]) of a program
running as a process, the most machine independent you are going to get is
to popen("ps -favourite_switches") and parse it out of there.  You can use
the first title line of the output to set up a set of column indices for
the fields to improve machine independent if you want.

At the other end of the scale are vendor-specific interfaces to the kernel
process structures:

        /procs  (SVr4, Digital UNIX, OSF-1, Solaris 5.x)
        getproc(), getuser() (AIX - memory failing - check documentation)
        pstat() (HPUX, undocumented but easy to follow header file)

Or you could use a privileged process to open /dev/kmem, get the proc
offset from /unix, seek and read the process table from that address in
/dev/kmem.  Once you get to the correct proctab entry, you might be lucky
and find that some kind kernel programmer has placed the name you want in
there for administrative purposes.  Check /usr/include/sys/proc.h to see
what you might expect when you get there!  On other system, you might get
what you want from the u-structure - but this is swappable, so if the
process is not in memory, you will have to ferret about in the paging areas
to find it.  Again, something what you want might be right there in the
u-structure, other times, you might have to traverse the call stack of the
process, looking for its argc, argv, and envp.

Are you feeling strong?

Finally - be warned, a process is (usually) allowed to change its argv[0],
so what you read might not be what you expected.

2. forgot passwd

3. Can't associate a process-id (PID) to TCP/IP Ports

4. OSR5 and FTP ONNET 2.0 probs

5. Getting the process ID of a new process

6. weird network problem (0/1)

7. Finding out User Id given Process id

8. How to check for a broken socket under solaris?

9. HELP on Mapping IP Address to Process ID

10. Getting list of all interfaces and associated IP addresses

11. Multistream Process Append Process ID To Beginning Of Log

12. How do I get the process GROUP ID of the signaling process?