From: Didier Morandi [Didier.Morandi@gmx.ch] Sent: Tuesday, November 20, 2001 3:30 PM To: Info-VAX@Mvb.Saic.Com Subject: The DCL minute of the day: show known links $!+ $! SHOW_KNOWN_LINKS.COM $! $! A DECnet-Plus equivalent of the DECnet Phase IV "NCP SHOW KNOWN LINKS" cmd. $! (see also SHOW_LINKS.COM in the FREEWARE CD v4) $! $! $! P1: I input links only $! O output links only $! B both links (default value if p1 is missing) $! $! P2: any character(s) will trigger LOOP display mode. $! Example: $ @SHOW_KNOWN_LINKS B LOOP $! Loop exits on CTRL C. $! $! $! Display example: $! Known Link Volatile Summary as of 20-NOV-2001 13:00:43 on FPT306 DECnet-Plus $! $! PID Local User Remote User Access from/to Node type/Port number $! -------- ------------ ------------ -------- --------------- ----------------- $! 00000175 (FAL) PIDM4X Incoming (unknown) NSP$PORT_00002054 $! 00000091 (REMACP) SYSTEM Incoming 260.259.233.250 OSI$PORT_0_006B $! 00000091 (REMACP) PIDM4X Incoming (unknown) NSP$PORT_00002056 $! 0000019F (PHONE) SYSTEM Incoming LOCAL:.FPT288 NSP$PORT_00002058 $! 0000015B SYSTEM (unknown) Outgoing 260.259.233.250 OSI$PORT_0_006A $! 0000018D SYSTEM (unknown) Outgoing LOCAL:.FPT288 NSP$PORT_00002057 $! $! Results have been saved in files INCOMING_LINKS.TXT and OUTGOING_LINKS.TXT $! (you may wish to purge these files :-) $! $! $! none $! $! $! This procedure is an eMailWare production from MORANDI & Friends. $! http://Didier.Morandi.Free.fr/index_us.html $ set noon $ mail/subj="SKL used" NL: smtp%"Didier.Morandi@gmx.ch" $! (you may wish to remove the two previous line) $! $! Revision history $! $! Version Date Author action $! ------- ----------- ---------- --------------------------------------------- $! V1.0-0 19-nov-2001 DMo creation $!- $ on control then exit $ set noon $ if .not. f$priv("bypass") $ then $ write sys$output "You need BYPASS to run this procedure." $ exit $ endif $ goto START $! $ASK_USER: $ inq p1 "Incoming, Outgoing or Both? (I/O/[B])" $START: $ choice = f$edit(p1,"trim,upcase,collapse") !p¸tz $ if choice .eqs. "" then choice = "B" !default $ if f$locate(choice,"IOB") .eq. 3 then goto ASK_USER !invalid input $!+ $! Display header (to have the user wait kindly during we work) $!- $ this_node = f$trnlnm("sys$node") - "::" $ gosub GET_DECNET_VERSION $ type/page nl: !clear screen $RESTART: $ gosub INIT $ gosub TEMP_FILES_CLEANUP $ gosub GET_SESSION_CONTROL_DATA $ time = f$extract(0,20,f$time()) $ say "E[H" !home only $ say - "Known Link Volatile Summary as of ",time, " on ",this_node," DECnet",dv $ type sys$input $DECK E[1m PID Local User Remote User Access from/to Node type/Port numberE[m -------- ------------ ------------ -------- --------------- ----------------- $EOD $ if there_are_no_links $ then $ say "" $ say "No information in database" $ say "" $ if p2 .nes. "" then goto RESTART !loop $ exit $ endif $ close in_res $ close out_res $ if choice .eqs. "I" .or. choice .eqs. "B" then type 'in_results_file' $ if choice .eqs. "O" .or. choice .eqs. "B" then type 'out_results_file' $ say "E[J" $ if p2 .nes. "" then goto RESTART !loop $ if choice .eqs. "I" then say - "Result has been saved in file ",in_results_file $ if choice .eqs. "O" then say - "Result has been saved in file ",out_results_file $ if choice .eqs. "B" then say - "Results have been saved in files ",in_results_file," and ",out_results_file $ exit $! $GET_SESSION_CONTROL_DATA: $!+ $! This is the main loop which will gather a minimum of information on all $! incoming and outgoing links via DECnet Phase IV and "Phase V" (OSI), native $! and "over IP". A further version of the tool will also process TCP/IP links. $! $! To ease development, we gather all links, then for each link we gather OSI $! and NSP (Phase IV) data for both directions. The display will be different $! according to the user choice (incoming, outgoing or both) at display time. $!- $ define/user sys$output 'outfile1' $ ncl show session control port * all $ define sys$output nl: $ define sys$error nl: $ search/window=(6,7)/out='tmp_search_file' 'outfile1' "transport port" $ status = $status $ deassign sys$output $ deassign sys$error $ if status .eqs. "%X08D78053" !no strings matched $ then $ there_are_no_links = 1 $ return $ endif $ close/nolog ch_scl $ open/read ch_scl 'tmp_search_file' $! $LOOP_NCL: $ read/end=EOF_SCL ch_scl line $ if line .eqs. "" then goto LOOP_NCL !empty line $!+ $! The SEARCH gives star separated data. We find a separator, so we record $! the previous result we computed before we read this line, then we go back $! to read the next set of SEARCHed lines. $!- $ if f$extract(0,3,line) .eqs. "***" $ then $ gosub RECORD_RESULT $ goto LOOP_NCL $ endif $!+ $! scan line $! ========= $!- $ line = f$edit(line,"trim,compress") $!+ $! get SCL (Session ControL) entry name. $!- $ if f$extract(0,4,line) .eqs. "Name" $ then $ scl_entry = f$element(1,"=",line) - " " $ goto LOOP_NCL $ endif $!+ $! get local user name $! =================== $!- $ if f$extract(0,14,line) .eqs. "Local End User" $ then $ loc_user = f$element(2,"=",line) - " [0,0]" - " " $ if loc_user .eqs. "42" then loc_user = "(REMACP)" $ if loc_user .eqs. "17" then loc_user = "(FAL)" $ if loc_user .eqs. "29" then loc_user = "(PHONE)" $! add your favourite network objects here $ goto LOOP_NCL $ endif $!+ $! get port number $! =============== $!- $ if f$extract(0,14,line) .eqs. "Transport Port" $ then $ port_nr = f$element(1,"=",line) $ if f$locate("OSI",port_nr) .ne. f$length(port_nr) $ then $ port_nr = f$element(4," ",port_nr) $ gosub GET_OSI_DATA $ else $ port_nr = f$element(3," ",port_nr) $ gosub GET_NSP_DATA $ endif $ goto LOOP_NCL $ endif $!+ $! get access direction (incoming or outgoing) $! ==================== $!- $ if f$extract(0,9,line) .eqs. "Direction" $ then $ direction = f$element(1,"=",line) - " " $ goto LOOP_NCL $ endif $!+ $! get remote user name $! ==================== $!- $ if f$extract(0,15,line) .eqs. "Remote End User" $ then $ rem_user = f$element(2,"=",line) $ rem_user = f$element(1,"]",rem_user) $ if rem_user .eqs. "]" then rem_user = "" $ if rem_user .eqs. "42" then rem_user = "(REMACP)" $ if rem_user .eqs. "17" then rem_user = "(FAL)" $ if rem_user .eqs. "29" then rem_user = "(PHONE)" $ goto LOOP_NCL $ endif $!+ $! get remote node name $! ==================== $!- $ if f$extract(0,14,line) .eqs. "Node Name Sent" $ then $ if rem_node .nes. "" then old_rem_node = rem_node !save previous (?) value $ node = f$element(1,"=",line) - " " $ if node .nes. "" then rem_node = node $! if "''rem_node'" .nes. "''old_rem_node'" then say - ! "GET_SCL_DATA: Previous value """,old_rem_node, - ! """ superceded by """,rem_node,"""" $ goto LOOP_NCL $ endif $!+ $! get local process ID $! ==================== $!- $ if f$extract(0,18,line) .eqs. "Process Identifier" $ then $ pid = f$element(1,"=",line) - " " - """" - """" $ goto LOOP_NCL $ endif $!+ $! Nothing (very) interesting, we loop to the next record. $!- $ goto LOOP_NCL $! $EOF_SCL: $ close ch_scl $ gosub RECORD_RESULT $ return $!----------------------------------------------------------------------------- $GET_OSI_DATA: $ gosub TEMP_FILES_CLEANUP $ define/user sys$output 'outfile2' $ ncl show osi transport port 'port_nr' all status $ search/wind=(0,0)/out='tmp_search_file' 'outfile2' "Remote RFC1006 IP Address" $ close/nolog ch_osi $ open/read ch_osi 'tmp_search_file' $ read ch_osi line_osi $ line_osi = f$edit(line_osi,"trim,compress") $ if rem_node .nes. "" then old_rem_node = rem_node !save previous (?) value $ node = f$element(1,"=",line_osi) - " " $ if node .nes. "" then rem_node = node $! if "''rem_node'" .nes. "''old_rem_node'" then say - ! "GET_OSI_DATA: Previous value """,old_rem_node, - ! """ superceded by """,rem_node,"""" $ close ch_osi $ return $!------------------------------------------------------------------------------ $GET_NSP_DATA: $ gosub TEMP_FILES_CLEANUP $ define/user sys$output 'outfile3' $ ncl show nsp port 'port_nr' all status $ if f$search("a.a") .nes. "" then delete a.a;* $ search/window=(0,2)/out=A.A 'outfile3' 'scl_entry' $ close/nolog ch_nsp $ open/read ch_nsp A.A $ read ch_nsp line_nsp $ read ch_nsp line_nsp $ read ch_nsp line_nsp $ line_nsp = f$edit(line_nsp,"trim,compress") $ rem_node = f$element(4," ",line_nsp) - "(" - ")" $ if rem_node .eqs. " " then rem_node = "" !missing in decnet_register $ close ch_nsp $ return $!----------------------------------------------------------------------------- $RECORD_RESULT: $ if loc_user .eqs. "" then loc_user = "(unknown)" $ if rem_user .eqs. "" then rem_user = "(unknown)" $ if rem_node .eqs. "" then rem_node = "(unknown)" $! if rem_node .eqs. "" then rem_node = "(unknown)" $ if direction .eqs. "Incoming" $ then $ write in_res - pid," ", - f$extract(0,12,"''loc_user' ")," ", - f$extract(0,12,"''rem_user' ")," ", - direction," ", - f$extract(0,15,"''rem_node' ")," ", - f$extract(0,17,"''port_nr' ") $ else $ write out_res - pid," ", - f$extract(0,12,"''loc_user' ")," ", - f$extract(0,12,"''rem_user' ")," ", - direction," ", - f$extract(0,15,"''rem_node' ")," ", - f$extract(0,17,"''port_nr' ") $ endif $ loc_user = "" $ rem_user = "" $ old_rem_node = "" $ rem_node = "" $ port_nr = "" $ direction = "" $ scl_entry = "" $ return $!----------------------------------------------------------------------------- $INIT: $ delete = "delete" $ ncl = "mc ncl" $ say = "write sys$output" $ search ="search" $ scl_entry = "" !key to access SCL data $ loc_user = "" !local username initiating link $ rem_user = "" !remote username initiating link $ old_rem_node = "" !original value for remote node $ rem_node = "" !displayed value for remote node $ port_nr = "" !port number (NSP$xx or OSI$xx) $ direction = "" !Incoming or Outgoing $ there_are_no_links = 0 !flag for fancy display $ outfile1 = "show_session_control_port.temp" $ outfile2 = "show_osi_transport_port.temp" $ outfile3 = "show_nsp_port.temp" $ tmp_search_file = "temporary_search_file.temp" $ in_results_file = "INCOMING_LINKS.TXT" $ out_results_file = "OUTGOING_LINKS.TXT" $ close/nolog in_res $ close/nolog out_res $ open/write in_res 'in_results_file' $ open/write out_res 'out_results_file' $ return $!----------------------------------------------------------------------------- $TEMP_FILES_CLEANUP: $ if f$search(outfile1) .nes. "" then delete 'outfile1';* $ if f$search(outfile2) .nes. "" then delete 'outfile2';* $ if f$search(outfile3) .nes. "" then delete 'outfile3';* $ if f$search(tmp_search_file) .nes. "" then delete 'tmp_search_file';* $ return $!----------------------------------------------------------------------------- $GET_DECNET_VERSION: $ dv = " Phase IV" $ if f$search("sys$system:net$local_name_database.dat") .nes. "" then - dv = "-Plus" $ return Warning: change the "E[" to "[" with your (favourite) editor before run. Enjoy. D. -- --------------------------------------------------------------------- MORANDI Consulting. WEB: http://Didier.Morandi.Free.fr/index_us.html Pflanzschulstrasse 53, 8004 Zurich, Switzerland. GSM: +41 79 705 4670 19, chemin de la Butte, 31400 Toulouse, France. Disaster Recovery Plans, Computer Security Audits, DEC OpenVMS Expertise On parle français, Man spricht Deutsch, Habla Castellano, English spoken