Article 3807 of vmsnet.sysmgt:
In article <ftn_2.200.116.9_34045b3e_P=84r.Wikenmo@p9.cw.ct.se>, p=84r.wikenmo@p9.cw.ct.se (P=84r Wikenmo) writes:
=Hi All , hope you are having a nice day
=
=Thank's all of you have helped me with this!
=I have been playing around with the ACCOUNTING command, and that seem to
=be a possible way to go.
=There is one problem though.
=When someone logs in from a terminal that is connected to the terminal-
=server, DEC 90TL, it is not possible to see which serverport that terminal is
=connected to.The "Terminal" field just shows a figure that is incremented by
=one for each login, eg. LTA5531, LTA5532 etc.

You want to use the TT_PHYDEVNAM value, and to log things to a file at the time
of the login.  You can put code in your SYS$SYLOGIN procedure to do this.  If
you've got virtual terminals enable, then you'll want to also disable the
reconnect option on the accounts you want to monitor, and place something that
emulates LOGINOUT's reconnect option in your SYS$SYLOGIN.  The way I handle it
here is to:
	1)  Grant all users the rightslist identifier LOG_INFO;
	2)  Create a file that's writeable by anybody holding that identifier;
	3)  Modify the accounts to disable control-y and reconnects;
	4)  Have SYS$SYLOGIN:
		1)  Run a procedure (enclosed below) to log the login to the
		    file from step 2 and run an installed privileged image
		    (source included below; program is installed with CMKRNL
		    priv)) which revokes the identifier;
		2)  Enable control-Y;
		3)  Execute a procedure (enclosed below) that emulates
		    LOGINOUT's reconnect option.

=One of the reasons for wanting this feature at all, is to bee able to
=monitor the activities on the modem-port.
=The modem is connected to LTA206, so I'd really like to tell which logins
=have been done on that particular port.

$! LOG_INFO.COM:  Log information about the source of a login.
$	SET NOON
$	TIME = F$TIME()
$	PID = F$GETJPI("", "PID")
$	VTERM = F$GETJPI("", "TERMINAL")
$	PTERM = F$GETDVI(VTERM, "TT_PHYDEVNAM")
$	IF PTERM .EQS. "" THEN PTERM = VTERM
$	ATERM = F$GETDVI(VTERM, "TT_ACCPORNAM")
$	IF ATERM .EQS. "" THEN ATERM = PTERM
$	NODE = F$TRNLNM("SYS$REM_NODE")
$	REMID = F$TRNLNM("SYS$REM_ID")
$	USER = F$GETJPI("", "USERNAME")
$	IF PTERM .EQS. "" THEN PTERM = VTERM
$	INFO = F$FAO("!AS!_!AS!_!AS!_!AS!_!AS!_!AS!_!AS!_!AS", TIME, USER, PID,-
		VTERM,PTERM, ATERM, NODE, REMID)
$	OPEN/APPEND/SHARE=WRITE FILE SYS$MANAGER:LOGINS.LOG
$	WRITE FILE INFO
$	CLOSE FILE
$	RUN SYS$SYSTEM:REVOKID
================================================================================
$! RECONNECT.COM - Emulate LOGINOUT's reconnect option
$	IF F$EXTRACT(0,3,F$GETJPI("","TERMINAL")) .NES. "VTA" THEN EXIT
$	MY_USERNAME = F$GETJPI("", "USERNAME")
$	CTX :=
$	FIRST_TERM :=
$	FIRST_PID :=
$	NTERMS = 0
$ LBL0:	PID = F$PID(CTX)
$	IF PID .EQS. "" THEN GOTO LBL3
$	IF F$GETJPI(PID, "USERNAME") .NES. MY_USERNAME THEN GOTO LBL0
$	THIS_TERM = F$GETJPI(PID, "TERMINAL")
$	IF THIS_TERM .EQS. "" THEN GOTO LBL0
$	IF F$EXTRACT(0, 3, THIS_TERM) .NES. "VTA" THEN GOTO LBL0
$	IF F$GETDVI(THIS_TERM, "TT_PHYDEVNAM") .NES. "" THEN GOTO LBL0
$	IF	NTERMS .EQ. 1
$	THEN	WRITE SYS$OUTPUT -
  			"    You have the following disconnected processes:"
$		WRITE SYS$OUTPUT "Terminal   Process name    Image name"
$		WRITE SYS$OUTPUT F$FAO("!11AS!16AS!AS", FIRST_TERM, FIRST_NAME,-
			FIRST_IMAGE)
$	ENDIF
$	THIS_NAME = F$GETJPI(PID, "PRCNAM")
$	THIS_IMAGE = F$GETJPI(PID, "IMAGNAME")
$	IF THIS_IMAGE .EQS. "" THEN THIS_IMAGE = "(none)"
$ LBL1:	IF F$LOCATE("]", THIS_IMAGE) .EQS. F$LENGTH(THIS_IMAGE) THEN GOTO LBL2
$	THIS_IMAGE = THIS_IMAGE - F$ELEMENT(0, "]", THIS_IMAGE) - "]"
$	GOTO LBL1
$ LBL2:	IF (NTERMS .EQ. 0)
$	THEN
$		FIRST_TERM = THIS_TERM
$		FIRST_NAME = THIS_NAME
$		FIRST_IMAGE = THIS_IMAGE
$	ELSE
$		WRITE SYS$OUTPUT F$FAO("!11AS!16AS!AS", THIS_TERM, THIS_NAME,-
			THIS_IMAGE)
$	ENDIF
$	NTERMS = NTERMS + 1
$	GOTO LBL0
$ LBL3: IF NTERMS .EQ. 0 THEN EXIT
$	IF	NTERMS .GT. 1
$	THEN	PROMPT=F$FAO("Enter terminal to connect to [!AS]: ", FIRST_TERM)
$		READ/PROMPT="''PROMPT'" SYS$COMMAND TERMINAL
$		TERMINAL = F$EDIT(TERMINAL, "UPCASE")
$		IF TERMINAL .EQS. "" THEN TERMINAL = FIRST_TERM
$		IF	F$EXTRACT(0,1,TERMINAL) .NES. "N"
$		THEN	WRITE SYS$OUTPUT ""
$			CONNECT 'TERMINAL'
$		ENDIF
$		EXIT
$	ELSE
$		WRITE SYS$OUTPUT -
			"    You have the following disconnected process:"
$		WRITE SYS$OUTPUT "Terminal   Process name    Image name"
$		WRITE SYS$OUTPUT F$FAO("!11AS!16AS!AS", FIRST_TERM, FIRST_NAME,-
			FIRST_IMAGE)
$		READ/PROMPT="Connect to above listed process [YES]: " -
			SYS$COMMAND FUBAR
$		FUBAR = FUBAR + "Y"
$		IF	FUBAR
$		THEN	WRITE SYS$OUTPUT ""
$			CONNECT 'FIRST_TERM'
$		ENDIF
$	ENDIF
$	EXIT
================================================================================
/* REVOKID.C -- Revoke the identifier LOG_INFO */
#include descrip
revokid()
{	$DESCRIPTOR(name, "LOG_INFO");
	SYS$EXIT(SYS$REVOKID(0, 0, 0, &name, 0));
}     
--------------------------------------------------------------------------------
Carl J Lydick | INTERnet: CARL@SOL1.GPS.CALTECH.EDU | NSI/HEPnet: SOL1::CARL

Disclaimer:  Hey, I understand VAXen and VMS.  That's what I get paid for.  My
understanding of astronomy is purely at the amateur level (or below).  So
unless what I'm saying is directly related to VAX/VMS, don't hold me or my
organization responsible for it.  If it IS related to VAX/VMS, you can try to
hold me responsible for it, but my organization had nothing to do with it.


