Listing processes attached to an STCP TCP socket

Blue Bar separator

This page describes the tcp_device_owners.cm macro that will do a who_locked on all the STCP devices associated with TCP sockets. This is not quiet the same thing as all STCP TCP sockets since it will not include ESTABLISHED OSL connections. It also does not include UDP sockets. However, it is much faster than the list_process_network.cm and list_all_process_network.cm macros. If your purpose is to locate a process that is using more sockets then it should this is probably the macro for you. PROVIDED that you have the GNU library installed since the macro requires the use of perl which is part of the GNU Library.

Update 2013-01-17: It turns out that while this macro will list all the processes with a socket bound to a port it will miss any process with an unbound socket. For this reason it is recommended that you do not run this macro. Instead try the stcp_device_lockers macro. In addition the stcp_device_lockers macro does not use analyze_system or require Perl.

Example 1 shows an interactive execution of the macro. You will note that it uses analyze_system which means it can only be executed by a privileged process, If you are going to run this as a started process you must use the -privileged argument to the start_process command. Since sockets are dynamic it is possible that a device found with analyze_system has been closed by the time that the who_locked command is executed. In that event an error is printed at the command line and in the output file you will see the who_locked command but no output. You will also note that there are devices listed other than STCP clone devices.

tcp_device_owners
OpenVOS Release 17.0.1aj, analyze_system Release 17.0.1aj
Current process is 617, ptep 8E159A80, Noah_Davids.CAC
as:  as:
List of devices generated, building Perl script
Perl script generated, about to run this may take a while
who_locked: The specified device name is not known to the system.
     %phx_vos#stcp.m15_3075
Check the file %phx_vos#m16_mas>SysAdmin>Noah_Davids>tcp_device_owners_list

ready  08:04:29
d %phx_vos#m16_mas>SysAdmin>Noah_Davids>tcp_device_owners_list

%phx_vos#m16_mas>SysAdmin>Noah_Davids>tcp_device_owners_list  09-04-29 08:05:56

tcp_device_owners.cm executed on 09-04-29 at 08:04:26

who_locked #stcp.m16_1
stcp.m16_1:
     Object is write locked by Overseer.System (telnetd) on module %phx_vos#m16
          executing telnetd.pm.
who_locked #stcp.m16_2
stcp.m16_2:
     Object is write locked by Overseer.System (ftpd) on module %phx_vos#m16
          executing ftpd.pm.
who_locked #stcp.m16_41
stcp.m16_41:
     Object is write locked by root.root (sshd) on module %phx_vos#m16
          executing sshd.pm.
who_locked #stcp.m16_42
stcp.m16_42:
     Object is write locked by root.root (sshd) on module %phx_vos#m16
          executing sshd.pm.
who_locked #stcp.m16_43
stcp.m16_43:
     Object is write locked by root.root (sshd) on module %phx_vos#m16
          executing sshd.pm.
. . . 
who_locked #stcp.m16_3075
who_locked #cpc_lapb.m16_0
cpc_lapb.m16_0:
     Object is write locked by Overseer.System (aria31) on module %phx_vos#m16
          executing x25_cpc.pm.
who_locked #cpc_lapb.m16_1
cpc_lapb.m16_1:
     Object is write locked by Overseer.System (aria33) on module %phx_vos#m16
          executing x25_cpc.pm.
who_locked #cpc_lapb.m16_2
cpc_lapb.m16_2:
     Object is write locked by Overseer.System (aria34) on module %phx_vos#m16
          executing x25_cpc.pm.
who_locked #cpc_lapb.m16_3
cpc_lapb.m16_3:
     Object is write locked by Overseer.System (aria91) on module %phx_vos#m16
          executing x25_cpc.pm.
who_locked #cpc_lapb.m16_4
cpc_lapb.m16_4:
     Object is write locked by Overseer.System (aria95) on module %phx_vos#m16
          executing x25_cpc.pm.
Example 1

The output in example 1 is interesting but it might be difficult to spot the process (or processes) that have more than the expected number of devices attached. One way to make this more evident is to sort the output file and look at the "Object is write locked" lines. Example 2 shows this. You will not be able to tell what devices the process has locked but you will be able to see how many there are.

sort tcp_device_owners_list -output_path tcp_device_owners_list_sorted          
ready  08:25:50

d tcp_device_owners_list_sorted -match 'Object is'

%phx_vos#m16_mas>SysAdmin>Noah_Davids>tcp_device_owners_list_sorted  09-04-29 08

     Object is write locked by Apache.SysAdmin (httpd) on module %phx_vos#m16
     Object is write locked by Apache.SysAdmin (httpd) on module %phx_vos#m16
     Object is write locked by Apache.SysAdmin (httpd) on module %phx_vos#m16
     Object is write locked by Apache.SysAdmin (httpd) on module %phx_vos#m16
     Object is write locked by Apache.SysAdmin (httpd) on module %phx_vos#m16
     Object is write locked by Agent1.SysAdmin (agentmgr) on module
     Object is write locked by Agent1.SysAdmin (agentmgr) on module
     Object is write locked by Agent1.SysAdmin (datamgr) on module
     Object is write locked by Agent1.SysAdmin (datamgr) on module
     Object is write locked by Agent1.SysAdmin (servd) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System.SysAdmin (osl_daemon) on module
     Object is write locked by Overseer.System (aria31) on module %phx_vos#m16
     Object is write locked by Overseer.System (aria33) on module %phx_vos#m16
     Object is write locked by Overseer.System (aria34) on module %phx_vos#m16
     Object is write locked by Overseer.System (aria91) on module %phx_vos#m16
     Object is write locked by Overseer.System (aria95) on module %phx_vos#m16
     Object is write locked by Overseer.System (aria96) on module %phx_vos#m16
     Object is write locked by Overseer.System (aria97) on module %phx_vos#m16
     Object is write locked by Overseer.System (ftpd) on module %phx_vos#m16
     Object is write locked by Overseer.System (telnetd) on module %phx_vos#m16
     Object is write locked by root.root (httpd) on module %phx_vos#m16
     Object is write locked by root.root (ndmpd) on module %phx_vos#m16
     Object is write locked by root.root (smbd) on module %phx_vos#m16
     Object is write locked by root.root (smbd) on module %phx_vos#m16
     Object is write locked by root.root (smbd) on module %phx_vos#m16
     Object is write locked by root.root (smbd) on module %phx_vos#m16
     Object is write locked by root.root (sshd) on module %phx_vos#m16
     Object is write locked by root.root (sshd) on module %phx_vos#m16
     Object is write locked by root.root (sshd) on module %phx_vos#m16
     Object is write locked by root.root (sshd) on module %phx_vos#m16
     Object is write locked by root.root (stcp_inetd) on module %phx_vos#m16
     Object is write locked by root.root (stcp_inetd) on module %phx_vos#m16
     Object is write locked by root.root (stcp_inetd) on module %phx_vos#m16
     Object is write locked by root.root (stcp_inetd) on module %phx_vos#m16
     Object is write locked by root.root (stcp_inetd) on module %phx_vos#m16
     Object is write locked by root.root (stcp_inetd) on module %phx_vos#m16

ready  08:26:21
Example 2

Once a process is identified you can search the tcp_device_owners_list file to associate the process to a device.

tcp_device_owners.cm

& tcp_device_owners starts here                                                 
&
& Version 0.00 08-11-03
& Version 1.00 09-04-29 added some progress messages
& Version 1.10 10-11-26 added disclaimer
& noah.davids@stratus.com
&
& This software is provided on an "AS IS" basis, WITHOUT ANY WARRANTY OR ANY
& SUPPORT OF ANY KIND. The AUTHOR SPECIFICALLY DISCLAIMS ANY IMPLIED WARRANTIES
& OF MERCHANTABILITY OR FITNESS FOR ANY PARTICULAR PURPOSE.  This disclaimer
& applies, despite any verbal representations of any kind provided by the
& author or anyone else.
&
&attach_input
&set_string CWD (current_dir)
change_current_dir (process_dir)
attach_default_output tcp_device_owners_list
display_line tcp_device_owners.cm executed on (date) at (time)
display_line
detach_default_output
analyze_system
..attach_default_output tcp_device_list
match dv; dump_stcbq -full
..detach_default_output
quit
&
display_line
display_line List of devices generated, building Perl script
&
line_edit -no_keystrokes -no_backup -no_verbose
insert
open ($INFILE, "tcp_device_list");

while ($_  = <$INFILE>)
{
 ($device) = (m/^.*\((.*)\)/x);
 if (length ($device) > 1)
    {
    print "who_locked #" .  $device . "\n";
    @args = ("who_locked", "#" . $device);
    system (@args)
    }
}

.
write tcp_device_owners.pl
quit
&
display_line Perl script generated, about to run this may take a while
&
attach_default_output tcp_device_owners_list -append
perl (process_dir)>tcp_device_owners.pl
detach_default_output
change_current_dir &CWD&
copy_file (process_dir)>tcp_device_owners_list tcp_device_owners_list -delete
&
display_line Check the file &CWD&>tcp_device_owners_list
display_line
& tcp_device_owners ends here


Blue Bar separator
This page was last modified on 13-01-18
mailbox Send comments and suggestions
to ndav1@cox.net