get_socket_info command macro
This macro makes it easy to select one or a set of TCP sockets and display their associated TCB and metering structures. You can select sockets based on 1 (example 1) or 2 (example 2) strings that are used to match lines from the netstat output.
Display Form
------------------------------- get_socket_info ------------------------------
match:
-and:
-pcb:
-meters: yes
-dump_pcb: yes
|
Arguments
match STRING
Is the first string used to match lines from the netstat display. You cannot provide a match STRING and a PCB-STRING.
-and STRING
Is the second string used to match lines from the output of the first match. This string is optional but if you provide it you must also provide a match STRING.
-pcb PCB-STRING
If you know the TCB address you can just provide it and bypass the netstat command and display -match steps. You cannot provide a PCB-STRING and a match STRING.
-meters cycle-YES/NO
If set to yes (default) will display metering output
-dump_pcb cycle-YES/NO
If set to yes (default) will display the TCB structure
Examples
Example 1:
This first example provides just the match string and cycles both -meters and -dump_pcb to no. The result is just a list of sockets that match the string. Since the match string is :3000 it will match any line where either the local or remote port is 3000. If this is all you want to do the command macro fnet.cm produces a more readable output with less overhead. The main purpose of this example is to show that multiple sockets can be matched at the same time.
get_socket_info :3000 -no_meters -no_dump_pcb
OpenVOS Release 17.0.1fx.ad, analyze_system Release 17.0.1fx.ad
Current process is 577, ptep 8CCA94C0, Noah_Davids.CAC
as: ============================================================
as: ============================================================
as:
as: 8c8617c0 tcp 0 0 *:3000 *:* LISTEN
as:
as: ============================================================
as: ============================================================
as:
as: 8ccfe8c0 tcp 0 0 164.152.77.128:49156 164.152.77.203:3000 ESTABLISHED
as:
as: ============================================================
as: ============================================================
as:
as: 8cdcd840 tcp 0 0 164.152.77.128:49159 164.152.77.34:3000 ESTABLISHED
as:
as: ============================================================
as: ============================================================
as:
as: 8cddbb80 tcp 0 0 164.152.77.128:3000 164.152.77.34:56688 ESTABLISHED
as:
as: ============================================================
as: ============================================================
as:
as: 8ce9e300 tcp 0 0 164.152.77.128:49208 164.152.77.11:3000 ESTABLISHED
as:
as: ready 15:23:52
|
Example 2:
This second example provides both the match and AND strings, still leaving both -meters and -dump_pcb to no. With two strings, in this case both port numbers you can select just one socket.
get_socket_info 3000 -and 56688 -no_meters -no_dump_pcb
OpenVOS Release 17.0.1fx.ad, analyze_system Release 17.0.1fx.ad
Current process is 577, ptep 8CCA94C0, Noah_Davids.CAC
as: ============================================================
as: ============================================================
as:
as: 8cddbb80 tcp 0 0 164.152.77.128:3000 164.152.77.34:56688 ESTABLISHED
as:
as: ready 15:31:23
|
Example 3:
You can also select just one socket by specifying an IP_address:port_number combination, as long as you pick the correct values. Notice that in the above list "164.152.77.34:3000" is not unique but 164.152.77.128:49159 is. Typically the IP_address:port_number of the client side of the connection will be unique. Depending on the application this could be the local side or the remote side. In this case it is the local side.
get_socket_info 164.152.77.128:49159 -no_meters -no_dump_pcb
OpenVOS Release 17.0.1fx.ad, analyze_system Release 17.0.1fx.ad
Current process is 577, ptep 8CCA94C0, Noah_Davids.CAC
as: ============================================================
as: ============================================================
as:
as: 8cdcd840 tcp 0 0 164.152.77.128:49159 164.152.77.34:3000 ESTABLISHED
as:
as: ready 15:37:32
|
Example 4:
You can specify any string, including a partial port number and part of the socket state. This example will get you a list of all the OSL inter-module listening sockets. The OSL port numbers are 3000 thru 3031 so matching :30 will get them all. However, sometimes you also get unexpected sockets that just happen to also match the strings, notice the last socket with a port number of 3099. This is not an OSL socket, but 3099 meets the match criteria.
get_socket_info :30 -and LIST -no_meters -no_dump_pcb
OpenVOS Release 17.0.1fx.ad, analyze_system Release 17.0.1fx.ad
Current process is 621, ptep 8977F000, Noah_Davids.CAC
as: ============================================================
as: ============================================================
as:
as: 8c8617c0 tcp 0 0 *:3000 *:* LISTEN
as:
as: ============================================================
as: ============================================================
as:
as: 8c862680 tcp 0 0 *:3001 *:* LISTEN
as:
as: ============================================================
as: ============================================================
as:
as: 8c8635c0 tcp 0 0 *:3002 *:* LISTEN
as:
as: ============================================================
. . . . .
as: ============================================================
as:
as: 8c8ffb40 tcp 0 0 *:3030 *:* LISTEN
as:
as: ============================================================
as: ============================================================
as:
as: 8c900a00 tcp 0 0 *:3031 *:* LISTEN
as:
as: ============================================================
as: ============================================================
as:
as: 8e4bc2c0 tcp 0 0 *:3099 *:* LISTEN
as:
as: ready 15:41:23
|
If you want to list all the sockets you can provide a match string of just the colon character (:). If you're interested in all of the ESTABLISTED sockets the match string ESTAB will work.
Example 5:
This example (finally) shows the output when the -meters and -dump_pcb arguments are left at their default values of yes. I've significantly truncated the output so it does take up multiple screens but you can see the line from netstat as well as the metering output and the TCB output. These structures will be output for every socket that matches the match and "and" strings.
get_socket_info 164.152.77.128:49159
OpenVOS Release 17.0.1fx.ad, analyze_system Release 17.0.1fx.ad
Current process is 621, ptep 8977F000, Noah_Davids.CAC
as: ============================================================
as: ============================================================
as:
as: 8cdcd840 tcp 0 0 164.152.77.128:49159 164.152.77.34:3000 ESTABLISHED
as:
as:
stcp_meters %phx_vos#m16 6:30:10 09-10-27 16:09:21
STCP Version 4 loaded 09-10-27 09:36:42 TCB @8CDCD840 09-10-27 09:39:11
Metering time: 6:30:10
segments received 46464 (avg 1.9847/sec)
total bytes 52228622 (avg 2231.03/sec)
using fast mode 52228622 (100% of total bytes)
flow controlled when received 0 (0% of segments rcvd)
data pending when received 0 (0% of segments rcvd)
received out of order 1 (0% of segments rcvd)
seqno before expected 1 (100% of out of order)
seqno after expected 0 (0% of out of order)
segment outside window 1 (0% of segments rcvd)
fast path 46464 (100% of segments rcvd)
urgent data 0 (0% of fast path)
. . . . .
recv window size 65535 (65535 max)
send seqn 05799839
send window size 32768 (32768 max)
send bytes pending 0
as: STCP_version 4
tcbstructure at 8CDCD840
*************** STCP TCB @ 8CDCD840 ************
flink 8CDD6B00
plink 8CDB2580
tcb_qptr 8CDCD640
tcb_state flag TS_ESTAB
state 00000607
ST_SR
ST_SS
ST_SA
. . . . .
START OF OS DEPENDENT STRUCTURES
SQH = 8CDCD480
SQH_NEXT = 00000001
SQH_PREV = 00000001
SQH_FIRST = 00000001
SQH_LAST = 00000001
sqh_vos_lock = 8CCB3180 (unlocked)
sqh_refcnt = 1
sqh_meterp = 8C84B780
sqh_no_interrupt_processing = 0
sqh_sq_list_status_flags = 00x
sqh_cpu_locked = -16
as: ready 16:10:08
|
Warnings
When dealing with large numbers of volatile sockets it is possible that a socket may be closed between the time that the netstat output was collected and the time that the metering and or TCB structures are displayed. This can result in an error or even the display of incorrect data. You should always look at the metering time to confirm that the socket has been meters for more than a few seconds and or the laddr, lport, faddr, fport values in the TCB to confirm that they match the netstat output.
get_socket_info :22 -and ESTAB
OpenVOS Release 17.0.1fx.ad, analyze_system Release 17.0.1fx.ad
Current process is 724, ptep 8E435000, Noah_Davids.CAC
as: ============================================================
as: ============================================================
as:
as: 8ce8a100 tcp 0 48 164.152.77.128:22 164.152.77.50:2432 ESTABLISHED
as:
as:
stcp_meters %phx_vos#m16 0:00:31 09-10-28 09:42:03
STCP Version 4 loaded 09-10-27 09:36:42 TCB @8CE8A100 09-10-28 09:41:32
Metering time: 0:01:31
. . . .
send window size 15408 (16384 max)
send bytes pending 0
as: STCP_version 4
tcbstructure at 8CE8A100
*************** STCP TCB @ 8CE8A100 ************
flink 00000000
plink 8CF28740
tcb_qptr 8E4BD9C0
tcb_state flag TS_ESTAB
state 00000707
ST_SR
ST_SS
ST_SA
ST_ACK
ST_RCV
ST_SND
dev 77
work 00000008
FL_ACK
tickid 6734473
opt_flag 37
laddr A4984D80
lport 22
fport 2432
faddr A4984D32
. . . .
|
get_socket_info.cm
& get_socket_info begins here
&
& get_socket_info.cm
& version 1.0 09-09-09 This macro started off as get_connection_meters.cm
& See http://community.stratus.com
& /blog/openvos/whither-tcp-statistics
& I added the command to also dump the PCB and argument
& to run either the stcp_meters or dump_onetcb commands
& (or both). Also to limit the netstat output to just
& TCP sockets
& version 1.1 09-10-27 Added the -all_sockets argument to the netstat
& command so that LISTENING sockets can be found.
& Changed arguments from -local and -remote to match
& -and, and made match positional and -and optional.
& version 1.2 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.
&
&begin_parameters
MATCH match:string
AND option (-and),string
PCB option (-pcb),string
METERS switch (-meters),=1
DUMP_PCB switch (-dump_pcb),=1
&end_parameters
&
& make sure extraneous stuff isn't echoed into the results file
&if (process_type) = 'batch' &then &do
set_ready -format off
&echo no_command_lines
&end
&
&if (length &PCB&) > 0
&then &do
&if (length &MATCH&) > 0
&then &goto ERROR_ADDRESS
&if (length &AND&) > 0
&then &goto ERROR_ADDRESS
analyze_system -request_line (string stcp_meters &PCB& -all -long) -quit
&return
&end
&
&set_string FILE_1 (process_dir)>connect_stcp_meters_1.temp
&set_string FILE_2 (process_dir)>connect_stcp_meters_2.temp
&
&if (length &MATCH&) = 0
&then &goto ERROR_ADDRESS
attach_default_output &FILE_1&
netstat -numeric -PCB_addr -all_sockets -protocol tcp
detach_default_output
&
display &FILE_1& -match &MATCH& -output_path &FILE_2& -no_header
&if (length X&AND&) > 1
&then display &FILE_2& -match &AND& -output_path &FILE_1& -no_header
&else copy_file &FILE_2& &FILE_1& -delete
&
&attach_input
analyze_system
&set LINE 1
&label AGAIN
&set_string CONNECTION (contents &FILE_1& &LINE& -hold)
&if (end_of_file &FILE_1&) = 1 &then &do
&if &LINE& = 1
&then &goto ERROR_NOT_FOUND
&else &do
quit
&return
&end
&end
&
..display_line ============================================================
..display_line ============================================================
..display_line
..display_line &CONNECTION&
..display_line
&set_string PCB (substr (string &CONNECTION&) 1 8)
&if &METERS& &then stcp_meters &PCB& -all -long
&if &DUMP_PCB& &then dump_onetcb &PCB&
&set LINE (calc &LINE& + 1)
&goto AGAIN
&
&
&label ERROR_NOT_FOUND
quit
display_line
display_line
display_line Could not find specified connection in netstat output
display_line &MATCH& &AND&
&return
&
&label ERROR_ADDRESS
display_line
display_line You must enter either a PCB or MATCH or MATCH and "AND"
display_line Usage:
display_line ' get_socket_info -pcb PCB [-no_meters] [-no_dump_pcb]'
display_line ' or'
display_line ' get_socket_info MATCH [-no_meters] [-no_dump_pcb]'
display_line ' or'
display_line ' get_socket_info MATCH -and AND [-no_meters] [-no_dump_pcb]'
&return
&
& get_socket_info ends here
|
This page was last modified on 10-11-26
Send comments and suggestions
to ndav1@cox.net