From: Malcolm MacArthur [malcolmix@neverness.freeserve.co.uk] Sent: Thursday, March 21, 2002 3:53 PM To: Info-VAX@Mvb.Saic.Com Subject: DECWHO.COM (was Re: Suggested enhancement. for DECterm.) >"Fred Zwarts" wrote in message news:a79o3r$r95$1@info.service.rug.nl... >For easier tracing the location of the users of a system, >it would be advantageous to define the remote port info >of the FTA device of a DECterm to the properties of the >related DISPLAY, e.g.: TCP/host.domain:1.0, or >DECNET/host:0.0. > >What do you think of it? Well, I already made my views clear in another message ;-) In the interim, you and others might find this command procedure useful. Not cluster aware (shows DECterms on local node only). Requires WORLD and whatever you need to examine channels in SDA (CMKRNL?). Only a tad longer than the more convenient SHOW USERS /FULL ;-) -Malcolm. -=-=-=-=-=-=-=-=-=-=-=-=-=- $! DECWHO.COM - Find out which users are on DECterms. $! and where they are. $! $! Malcolm MacArthur, 21 March 2002 $! $ num_controllers ==0 $ num_decterms==0 $! Step 1: Find the DECW$TE_nnnn terminal controller processes. $! $ pipe show sys | search sys$pipe "DECW$TE_" /out=SYS$SCRATCH:DECW$TE.TMP $! $! Get the PIDs... $ open /write output sys$scratch:decwusers.tmp $ open /read infile SYS$SCRATCH:decw$te.tmp $ loop: $ read /end=endfile infile rec $ pid = f$element(0," ",rec) $! $! Find the terminals connected to this controller.. $! $ call list_terminals 'pid $ goto loop $ endfile: $ close infile $ deleteeee /nolog /noconf SYS$SCRATCH:DECW$TE.TMP; $ close output $ sort sys$scratch:decwusers.tmp sys$scratch:decwusers2.tmp $ deleteee /nolog /noconf SYS$SCRATCH:decwusers.tmp; $ write sys$output - " OpenVMS DECterm Processes at ''f$time()'" $ write sys$output - " Total number of DECterm controllers = ''num_controllers', "+ - "number of DECterms = ''num_decterms'" $ write sys$output f$fao("!/ !12AS !6AS !16AS !8AS !8AS", - "Username","Node","Process Name"," PID","Terminal") $ type sys$scratch:decwusers2.tmp $ deleteee /nolog /noconfirm sys$scratch:decwusers2.tmp; $ list_terminals: SUBROUTINE $! $! Create a temp file to run SDA $! $ open /write outfile SYS$SCRATCH:RUNSDA.TMP $ write outfile "$ define /user sys$output SYS$SCRATCH:SDACHANS.TMP" $ write outfile "$ ANALYZE /SYSTEM" $ write outfile "SHOW PROCESS /ID=''p1' /CHANNELS" $ write outfile "$" $ close outfile $ @SYS$SCRATCH:RUNSDA.TMP $ deleteeeee /nolog /noconf SYS$SCRATCH:RUNSDA.TMP; $! type /page=save sys$scratch:sdachans.tmp $! Find the WSAnn: device... $ search /output=SYS$SCRATCH:WSACHAN.TMP SYS$SCRATCH:SDACHANS.TMP - /KEY=(pos:40,siz:3) "WSA" $! Then the FTAnn: devices... $ search /output=SYS$SCRATCH:FTACHANS.TMP SYS$SCRATCH:SDACHANS.TMP - /KEY=(pos:40,siz:3) "FTA" $! open the file with the WSAnn: device in it... $ open /read infile2 sys$scratch:WSACHAN.TMP $ read infile2 rec $ close infile2 $ wsadev = f$element(2," ",f$edit(rec,"TRIM,COMPRESS")) $ deleteeeee /nolog /noconf SYS$SCRATCH:SDACHANS.TMP; $ define /user sys$output nla0: $ show display/symbol 'wsadev $ accpornam = decw$display_transport+"/"+decw$display_node+":"+ - decw$display_server+"."+decw$display_screen $! Write out a record for the DECterm controller... $ username = f$getjpi(p1,"USERNAME") $ node = f$getjpi(p1,"NODENAME") $ prcnam = f$getjpi(p1,"PRCNAM") $ if f$length(accpornam) .le. 8 then - write output f$fao(" !12AS !6AS !16AS !8AS !8AS (!AS)", - username, node, prcnam, p1, wsadev, accpornam+ " [Controller]") $ if f$length(accpornam) .gt. 8 then - write output f$fao(" !12AS !6AS !16AS !8AS !8AS!/!#* (!AS)", - username, node, prcnam, p1, wsadev, - 65-f$length(accpornam),accpornam+" [Controller]") $ num_controllers == num_controllers+1 $! well, wasn't that easy! ;-) Now, get the user names for the terminals... $ open /read infile2 sys$scratch:ftachans.tmp $ ftaloop: $ read /end=nomoreterms infile2 rec $ ftadev = f$element(2," ",f$edit(rec,"TRIM,COMPRESS")) $ ownpid = f$getdvi(ftadev,"PID") $ if ownpid .eqs. "00000000" ! No process... $ then $ username="" $ node = f$getdvi(ftadev,"HOST_NAME") $ prcnam = "" $ else $ username = f$getjpi(ownpid,"USERNAME") $ node = f$getjpi(ownpid,"NODENAME") $ prcnam = f$getjpi(ownpid,"PRCNAM") $ imagname = f$getjpi(ownpid,"IMAGNAME") $ image = f$parse(imagname,,,"NAME") $ if imagname .eqs. "LOGINOUT" then username = "" $ endif $ if f$length(accpornam) .le. 21 then - write output f$fao(" !12AS !6AS !16AS !8AS !8AS (!AS)", - username, node, prcnam, ownpid, ftadev, accpornam) $ if f$length(accpornam) .gt. 21 then - write output f$fao(" !12AS !6AS !16AS !8AS !8AS!/!#* (!AS)", - username, node, prcnam, ownpid, ftadev, - 78-f$length(accpornam),accpornam) $ num_decterms == num_decterms+1 $ goto ftaloop $ nomoreterms: $ close infile2 $ deleteee /nolog /noconf sys$scratch:ftachans.tmp; $ ENDSUBROUTINE > F.Z.